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.37 (requested by th...
details: https://anonhg.NetBSD.org/src/rev/6008d9e877a3
branches: netbsd-1-6
changeset: 529709:6008d9e877a3
user: he <he%NetBSD.org@localhost>
date: Sat Dec 07 23:15:55 2002 +0000
description:
Pull up revision 1.37 (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/printjob.c | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diffs (48 lines):
diff -r 63a03c715bbc -r 6008d9e877a3 usr.sbin/lpr/lpd/printjob.c
--- a/usr.sbin/lpr/lpd/printjob.c Sat Dec 07 23:05:28 2002 +0000
+++ b/usr.sbin/lpr/lpd/printjob.c Sat Dec 07 23:15:55 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: printjob.c,v 1.31.2.1 2002/12/07 21:48:39 he Exp $ */
+/* $NetBSD: printjob.c,v 1.31.2.2 2002/12/07 23:15:55 he Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -45,7 +45,7 @@
#if 0
static char sccsid[] = "@(#)printjob.c 8.7 (Berkeley) 5/10/95";
#else
-__RCSID("$NetBSD: printjob.c,v 1.31.2.1 2002/12/07 21:48:39 he Exp $");
+__RCSID("$NetBSD: printjob.c,v 1.31.2.2 2002/12/07 23:15:55 he Exp $");
#endif
#endif /* not lint */
@@ -150,17 +150,24 @@
struct stat stb;
struct queue *q, **qp;
struct queue **queue;
- int i, nitems;
+ int i, nitems, fd;
off_t pidoff;
int errcnt, count = 0;
init(); /* set up capabilities */
- (void)write(STDOUT_FILENO, "", 1); /* ack that daemon is started */
- (void)close(STDERR_FILENO); /* set up log file */
- if (open(LF, O_WRONLY|O_APPEND, 0664) < 0) {
+ (void)write(STDOUT_FILENO, "", 1); /* ack that daemon is started */
+
+ /* set up 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);
+
setgid(getegid());
pid = getpid(); /* for use with lprm */
setpgrp(0, pid);
Home |
Main Index |
Thread Index |
Old Index