From 0a860f59d06301709a4f60ffa37e2a39fe52c492 Mon Sep 17 00:00:00 2001 From: gad Date: Mon, 12 Mar 2001 00:22:03 +0000 Subject: [PATCH] Improve a few error messages wrt if= filters on remote print queues. --- usr.sbin/lpr/lpd/printjob.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c index 740a1c54d441..e4e9838af833 100644 --- a/usr.sbin/lpr/lpd/printjob.c +++ b/usr.sbin/lpr/lpd/printjob.c @@ -956,10 +956,20 @@ sendfile(pp, type, file, format) struct stat stb; FILE *fp; char buf[BUFSIZ]; - int sizerr, resp, closedpr; + int closedpr, resp, sizerr, statrc; - if (lstat(file, &stb) < 0 || (f = open(file, O_RDONLY)) < 0) + statrc = lstat(file, &stb); + if (statrc < 0) { + syslog(LOG_ERR, "%s: error from lstat(%s): %m", + pp->printer, file); return(ERROR); + } + f = open(file, O_RDONLY); + if (f < 0) { + syslog(LOG_ERR, "%s: error from open(%s,O_RDONLY): %m", + pp->printer, file); + 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 something @@ -977,10 +987,11 @@ sendfile(pp, type, file, format) if (type == '\3') { if (pp->filters[LPF_INPUT]) { /* - * We're sending something with an ifilter, we have to - * run the ifilter and store the output as a - * temporary file (tfile)... the protocol requires us - * to send the file size + * We're sending something with an ifilter. We have to + * run the ifilter and store the output as a temporary + * spool file (tfile...), because the protocol requires + * us to send the file size before we start sending any + * of the data. */ char *av[15]; int n; @@ -1054,8 +1065,12 @@ sendfile(pp, type, file, format) unlink(tfile); return(FILTERERR); } - if (fstat(tfd, &stb) < 0) /* the size of tfile */ + statrc = fstat(tfd, &stb); /* to find size of tfile */ + if (statrc < 0) { + syslog(LOG_ERR, "%s: error processing 'if', fstat(%s): %m", + pp->printer, tfile); return(ERROR); + } f = tfd; lseek(f,0,SEEK_SET); } else if (ofilter) { @@ -1083,7 +1098,10 @@ sendfile(pp, type, file, format) while ((i = wait(NULL)) > 0 && i != ofilter) ; ofilter = 0; - if (fstat(tfd, &stb) < 0) { /* the size of tfile */ + statrc = fstat(tfd, &stb); /* to find size of tfile */ + if (statrc < 0) { + syslog(LOG_ERR, "%s: error processing 'of', fstat(%s): %m", + pp->printer, tfile); openpr(pp); return(ERROR); }