diff options
author | gad <gad@FreeBSD.org> | 2000-11-08 00:52:11 +0000 |
---|---|---|
committer | gad <gad@FreeBSD.org> | 2000-11-08 00:52:11 +0000 |
commit | 5e67b84726d3d9d0da6a93b03eaf0055f0fe0e3c (patch) | |
tree | 4935bb27c11074b5b4d489c0e81592c4f5a790b6 /usr.sbin/lpr | |
parent | 34d0ad4986a2d93f4c82f3a76e6f76f284c9e7a4 (diff) | |
download | FreeBSD-src-5e67b84726d3d9d0da6a93b03eaf0055f0fe0e3c.zip FreeBSD-src-5e67b84726d3d9d0da6a93b03eaf0055f0fe0e3c.tar.gz |
Fix 'printit()' to ignore some lines it doesn't recognize (most likely
coming from lprNG hosts), and print a more helpful error msg for others.
Diffstat (limited to 'usr.sbin/lpr')
-rw-r--r-- | usr.sbin/lpr/lpd/extern.h | 1 | ||||
-rw-r--r-- | usr.sbin/lpr/lpd/printjob.c | 27 |
2 files changed, 24 insertions, 4 deletions
diff --git a/usr.sbin/lpr/lpd/extern.h b/usr.sbin/lpr/lpd/extern.h index 70c536d..d4b4966 100644 --- a/usr.sbin/lpr/lpd/extern.h +++ b/usr.sbin/lpr/lpd/extern.h @@ -38,6 +38,7 @@ extern char scnkey[][HEIGHT]; /* in lpdchar.c */ extern char fromb[]; +extern int lflag; /* in lpd.c */ struct printer; struct termios; diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c index 23f2dbb..51e1b6d 100644 --- a/usr.sbin/lpr/lpd/printjob.c +++ b/usr.sbin/lpr/lpd/printjob.c @@ -339,8 +339,9 @@ printit(pp, file) char *file; { register int i; - char *cp; - int bombed = OK; + char *cp; + int bombed = OK; + int didignorehdr = 0; /* * open control file; ignore if no longer there. @@ -489,7 +490,22 @@ printit(pp, file) continue; default: /* some file to print */ - switch (i = print(pp, line[0], line+1)) { + /* only lowercase cmd-codes include a file-to-print */ + if ((line[0] < 'a') || (line[0] > 'z')) { + /* ignore any other lines */ + if (lflag <= 1) + continue; + if (!didignorehdr) { + syslog(LOG_INFO, "%s: in %s :", + pp->printer, file); + didignorehdr = 1; + } + syslog(LOG_INFO, "%s: ignoring line: '%c' %s", + pp->printer, line[0], &line[1]); + continue; + } + i = print(pp, line[0], line+1); + switch (i) { case ERROR: if (bombed == OK) bombed = FATALERR; @@ -566,8 +582,11 @@ print(pp, format, file) union wait status; struct stat stb; - if (lstat(file, &stb) < 0 || (fi = open(file, O_RDONLY)) < 0) + if (lstat(file, &stb) < 0 || (fi = open(file, O_RDONLY)) < 0) { + syslog(LOG_INFO, "%s: unable to open %s ('%c' line)", + pp->printer, file, format); return(ERROR); + } /* * Check to see if data file is a symbolic link. If so, it should * still point to the same file or someone is trying to print |