summaryrefslogtreecommitdiffstats
path: root/usr.sbin/lpr
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1995-04-27 04:56:10 +0000
committerjkh <jkh@FreeBSD.org>1995-04-27 04:56:10 +0000
commitdcf608f1a5f67dc5324dbfb1b38b592fcbef9ed9 (patch)
tree2b6d680c11d83c7bbc41270742b59c7def240a9b /usr.sbin/lpr
parente028135d855b37f7aacad442c7edbdbed78513c9 (diff)
downloadFreeBSD-src-dcf608f1a5f67dc5324dbfb1b38b592fcbef9ed9.zip
FreeBSD-src-dcf608f1a5f67dc5324dbfb1b38b592fcbef9ed9.tar.gz
Close PR:
>Number: 368 >Category: bin >Synopsis: Lpd doesn't log errors after failed exec >Description: If an exec done by lpd fails, nothing is sent to the system log indicating what went wrong. This is because lpd closes all of the file descriptors before doing the exec, thus closing the syslog file descriptor in the process. [Fix applied] Submitted by: pritc003@maroon.tc.umn.edu
Diffstat (limited to 'usr.sbin/lpr')
-rw-r--r--usr.sbin/lpr/lpd/printjob.c9
-rw-r--r--usr.sbin/lpr/runqueue/printjob.c9
2 files changed, 18 insertions, 0 deletions
diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c
index 889741e..41f7372 100644
--- a/usr.sbin/lpr/lpd/printjob.c
+++ b/usr.sbin/lpr/lpd/printjob.c
@@ -538,10 +538,12 @@ print(format, file)
if ((prchild = dofork(DORETURN)) == 0) { /* child */
dup2(fi, 0); /* file is stdin */
dup2(p[1], 1); /* pipe is stdout */
+ closelog();
for (n = 3; n < NOFILE; n++)
(void) close(n);
execl(_PATH_PR, "pr", width, length,
"-h", *title ? title : " ", "-F", 0);
+ openlog("lpd", LOG_PID, LOG_LPR);
syslog(LOG_ERR, "cannot execl %s", _PATH_PR);
exit(2);
}
@@ -651,9 +653,11 @@ start:
n = open(tempfile, O_WRONLY|O_CREAT|O_TRUNC, 0664);
if (n >= 0)
dup2(n, 2);
+ closelog();
for (n = 3; n < NOFILE; n++)
(void) close(n);
execv(prog, av);
+ openlog("lpd", LOG_PID, LOG_LPR);
syslog(LOG_ERR, "cannot execv %s", prog);
exit(2);
}
@@ -1008,6 +1012,7 @@ sendmail(user, bombed)
pipe(p);
if ((s = dofork(DORETURN)) == 0) { /* child */
dup2(p[0], 0);
+ closelog();
for (i = 3; i < NOFILE; i++)
(void) close(i);
if ((cp = rindex(_PATH_SENDMAIL, '/')) != NULL)
@@ -1016,6 +1021,8 @@ sendmail(user, bombed)
cp = _PATH_SENDMAIL;
sprintf(buf, "%s@%s", user, fromhost);
execl(_PATH_SENDMAIL, cp, buf, 0);
+ openlog("lpd", LOG_PID, LOG_LPR);
+ syslog(LOG_ERR, "cannot execl %s", _PATH_SENDMAIL);
exit(0);
} else if (s > 0) { /* parent */
dup2(p[1], 1);
@@ -1252,6 +1259,7 @@ openpr()
if ((ofilter = dofork(DOABORT)) == 0) { /* child */
dup2(p[0], 0); /* pipe is std in */
dup2(pfd, 1); /* printer is std out */
+ closelog();
for (i = 3; i < NOFILE; i++)
(void) close(i);
if ((cp = rindex(OF, '/')) == NULL)
@@ -1259,6 +1267,7 @@ openpr()
else
cp++;
execl(OF, cp, width, length, 0);
+ openlog("lpd", LOG_PID, LOG_LPR);
syslog(LOG_ERR, "%s: %s: %m", printer, OF);
exit(1);
}
diff --git a/usr.sbin/lpr/runqueue/printjob.c b/usr.sbin/lpr/runqueue/printjob.c
index 889741e..41f7372 100644
--- a/usr.sbin/lpr/runqueue/printjob.c
+++ b/usr.sbin/lpr/runqueue/printjob.c
@@ -538,10 +538,12 @@ print(format, file)
if ((prchild = dofork(DORETURN)) == 0) { /* child */
dup2(fi, 0); /* file is stdin */
dup2(p[1], 1); /* pipe is stdout */
+ closelog();
for (n = 3; n < NOFILE; n++)
(void) close(n);
execl(_PATH_PR, "pr", width, length,
"-h", *title ? title : " ", "-F", 0);
+ openlog("lpd", LOG_PID, LOG_LPR);
syslog(LOG_ERR, "cannot execl %s", _PATH_PR);
exit(2);
}
@@ -651,9 +653,11 @@ start:
n = open(tempfile, O_WRONLY|O_CREAT|O_TRUNC, 0664);
if (n >= 0)
dup2(n, 2);
+ closelog();
for (n = 3; n < NOFILE; n++)
(void) close(n);
execv(prog, av);
+ openlog("lpd", LOG_PID, LOG_LPR);
syslog(LOG_ERR, "cannot execv %s", prog);
exit(2);
}
@@ -1008,6 +1012,7 @@ sendmail(user, bombed)
pipe(p);
if ((s = dofork(DORETURN)) == 0) { /* child */
dup2(p[0], 0);
+ closelog();
for (i = 3; i < NOFILE; i++)
(void) close(i);
if ((cp = rindex(_PATH_SENDMAIL, '/')) != NULL)
@@ -1016,6 +1021,8 @@ sendmail(user, bombed)
cp = _PATH_SENDMAIL;
sprintf(buf, "%s@%s", user, fromhost);
execl(_PATH_SENDMAIL, cp, buf, 0);
+ openlog("lpd", LOG_PID, LOG_LPR);
+ syslog(LOG_ERR, "cannot execl %s", _PATH_SENDMAIL);
exit(0);
} else if (s > 0) { /* parent */
dup2(p[1], 1);
@@ -1252,6 +1259,7 @@ openpr()
if ((ofilter = dofork(DOABORT)) == 0) { /* child */
dup2(p[0], 0); /* pipe is std in */
dup2(pfd, 1); /* printer is std out */
+ closelog();
for (i = 3; i < NOFILE; i++)
(void) close(i);
if ((cp = rindex(OF, '/')) == NULL)
@@ -1259,6 +1267,7 @@ openpr()
else
cp++;
execl(OF, cp, width, length, 0);
+ openlog("lpd", LOG_PID, LOG_LPR);
syslog(LOG_ERR, "%s: %s: %m", printer, OF);
exit(1);
}
OpenPOWER on IntegriCloud