Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-6]: src/usr.sbin/lpr/lpd Pull up revision 1.17 (requested by th...
details: https://anonhg.NetBSD.org/src/rev/b59cd8dd65f5
branches: netbsd-1-6
changeset: 529710:b59cd8dd65f5
user: he <he%NetBSD.org@localhost>
date: Sat Dec 07 23:16:15 2002 +0000
description:
Pull up revision 1.17 (requested by thorpej in ticket #947):
Rather than relying on pure luck to get the log file on
STDERR_FILENO, explicitly dup2 the log file descriptor to
STDERR_FILENO and close the original.
diffstat:
usr.sbin/lpr/lpd/recvjob.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diffs (47 lines):
diff -r 6008d9e877a3 -r b59cd8dd65f5 usr.sbin/lpr/lpd/recvjob.c
--- a/usr.sbin/lpr/lpd/recvjob.c Sat Dec 07 23:15:55 2002 +0000
+++ b/usr.sbin/lpr/lpd/recvjob.c Sat Dec 07 23:16:15 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: recvjob.c,v 1.14 2001/12/04 22:52:44 christos Exp $ */
+/* $NetBSD: recvjob.c,v 1.14.2.1 2002/12/07 23:16:15 he Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -45,7 +45,7 @@
#if 0
static char sccsid[] = "@(#)recvjob.c 8.2 (Berkeley) 4/27/95";
#else
-__RCSID("$NetBSD: recvjob.c,v 1.14 2001/12/04 22:52:44 christos Exp $");
+__RCSID("$NetBSD: recvjob.c,v 1.14.2.1 2002/12/07 23:16:15 he Exp $");
#endif
#endif /* not lint */
@@ -91,7 +91,7 @@
recvjob(void)
{
struct stat stb;
- int status;
+ int status, fd;
/*
* Perform lookup for printer name or abbreviation
@@ -110,11 +110,16 @@
if (cgetstr(bp, "lo", &LO) == -1)
LO = DEFLOCK;
- (void)close(2); /* set up log file */
- if (open(LF, O_WRONLY|O_APPEND, 0664) < 0) {
+ /* Set up the log file. */
+ if ((fd = open(LF, O_WRONLY|O_APPEND, 0664)) < 0) {
syslog(LOG_ERR, "%s: %m", LF);
- (void)open(_PATH_DEVNULL, O_WRONLY);
+ fd = open(_PATH_DEVNULL, O_WRONLY);
}
+ if (fd > 0) {
+ (void) dup2(fd, STDERR_FILENO);
+ (void) close(fd);
+ } else
+ (void) close(STDERR_FILENO);
if (chdir(SD) < 0)
frecverr("%s: %s: %m", printer, SD);
Home |
Main Index |
Thread Index |
Old Index