[17193] in Athena Bugs
Re: sgi 8.2.15: syslogd
daemon@ATHENA.MIT.EDU (John Hawkinson)
Mon Sep 20 22:32:10 1999
Date: Mon, 20 Sep 1999 22:31:54 -0400 (EDT)
Message-Id: <199909210231.WAA17810@mary-kay-commandos.mit.edu>
To: Joe Foley <foley@MIT.EDU>, Garry Zacheiss <zacheiss@MIT.EDU>,
source-reviewers@MIT.EDU
Cc: bugs@MIT.EDU
In-Reply-To: "[16507] in Athena Bugs"
From: John Hawkinson <jhawk@MIT.EDU>
| in fact, never worked for Irix, so you might want to make your bug
| report say "we shouldn't install something that's broken and allows
| people to shoot themselves in the foot." If you want technical detail
| of how I was able to make it delete /dev/log, I can probably recreate
| that.
Here's a patch to make sure that syslogd never deletes /dev/log
unless it's already a unix-domain socket.
--jhawk
Index: syslogd.c
===================================================================
RCS file: /afs/dev/source/repository/athena/lib/zephyr/clients/syslogd/syslogd.c,v
retrieving revision 1.21
diff -c -r1.21 syslogd.c
*** syslogd.c 1997/09/14 21:50:42 1.21
--- syslogd.c 1999/09/21 01:50:02
***************
*** 68,77 ****
--- 68,82 ----
#endif
#include <utmp.h>
#include <setjmp.h>
+
+ #include <sys/types.h>
+
#include <sys/socket.h>
+ #include <sys/stat.h>
#include <sys/un.h>
#include <sys/resource.h>
#include <sys/uio.h>
+
#include <netdb.h>
#ifdef STREAMS_LOG_DRIVER
#include <sys/stream.h>
***************
*** 276,283 ****
register int i;
register char *p;
int funix, inetm = 0, klogm, len;
! #ifndef STREAMS_LOG_DRIVER
struct sockaddr_un sunx, fromunix;
int fklog;
#endif
struct sockaddr_in sin, frominet;
--- 281,289 ----
register int i;
register char *p;
int funix, inetm = 0, klogm, len;
! struct stat st;
struct sockaddr_un sunx, fromunix;
+ #ifndef STREAMS_LOG_DRIVER
int fklog;
#endif
struct sockaddr_in sin, frominet;
***************
*** 406,426 ****
#endif
(void) alarm(TIMERINTVL);
! #ifndef STREAMS_LOG_DRIVER
! (void) unlink(LogName);
!
! sunx.sun_family = AF_UNIX;
! (void) strncpy(sunx.sun_path, LogName, sizeof sunx.sun_path);
! funix = socket(AF_UNIX, SOCK_DGRAM, 0);
! if (funix < 0 ||
! bind(funix, (struct sockaddr *) &sunx, sizeof(sunx)) < 0 ||
! chmod(LogName, 0666) < 0) {
! (void) sprintf(line, "cannot create %s", LogName);
! logerror(line);
! dprintf("cannot create %s (%d)\n", LogName, errno);
! die(0);
! }
! #else /* STREAMS_LOG_DRIVER */
if ((funix=open(LogName, O_RDONLY)) < 0) {
sprintf(line, "cannot open %s", LogName);
logerror(line);
--- 412,435 ----
#endif
(void) alarm(TIMERINTVL);
! /* Make sure that we only unlink /dev/log if we're on an OS where
! it is a unix domain socket. */
! if ((stat(LogName, &st) == 0) && (st.st_mode & S_IFIFO)) {
! (void) unlink(LogName);
!
! sunx.sun_family = AF_UNIX;
! (void) strncpy(sunx.sun_path, LogName, sizeof sunx.sun_path);
! funix = socket(AF_UNIX, SOCK_DGRAM, 0);
! if (funix < 0 ||
! bind(funix, (struct sockaddr *) &sunx, sizeof(sunx)) < 0 ||
! chmod(LogName, 0666) < 0) {
! (void) sprintf(line, "cannot create %s", LogName);
! logerror(line);
! dprintf("cannot create %s (%d)\n", LogName, errno);
! die(0);
! }
! }
! #ifdef STREAMS_LOG_DRIVER
if ((funix=open(LogName, O_RDONLY)) < 0) {
sprintf(line, "cannot open %s", LogName);
logerror(line);