aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/lpr/lpd/printjob.c
diff options
context:
space:
mode:
authorGarance A Drosehn <gad@FreeBSD.org>2001-03-12 00:22:03 +0000
committerGarance A Drosehn <gad@FreeBSD.org>2001-03-12 00:22:03 +0000
commit28b051021ac96f217826c06625ed5cb4afd525eb (patch)
tree9a0f68a8a753de0f358b80f1dc6c3198e8dded7a /usr.sbin/lpr/lpd/printjob.c
parent86f7cedfda77d102a9d92875e71d64fc5301080f (diff)
Improve a few error messages wrt if= filters on remote print queues.
Notes
Notes: svn path=/head/; revision=74124
Diffstat (limited to 'usr.sbin/lpr/lpd/printjob.c')
-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 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);
}