summaryrefslogtreecommitdiffstats
path: root/usr.sbin/lpr/lpd
diff options
context:
space:
mode:
authorgad <gad@FreeBSD.org>2001-03-12 00:22:03 +0000
committergad <gad@FreeBSD.org>2001-03-12 00:22:03 +0000
commit0a860f59d06301709a4f60ffa37e2a39fe52c492 (patch)
tree3875f9fbd9c616913afc9f835d3c9e1504af42fb /usr.sbin/lpr/lpd
parent9e36d98ddb4d38a133e97e7c86b56b841173c7a6 (diff)
downloadFreeBSD-src-0a860f59d06301709a4f60ffa37e2a39fe52c492.zip
FreeBSD-src-0a860f59d06301709a4f60ffa37e2a39fe52c492.tar.gz
Improve a few error messages wrt if= filters on remote print queues.
Diffstat (limited to 'usr.sbin/lpr/lpd')
-rw-r--r--usr.sbin/lpr/lpd/printjob.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c
index 740a1c5..e4e9838 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);
}
OpenPOWER on IntegriCloud