--- 1.1 1993/03/23 22:53:28 +++ Makefile 1995/05/10 23:18:42 @@ -1,15 +1,22 @@ # @(#)Makefile 5.6 (Berkeley) 6/29/90 +CC=gcc PROG= syslogd SRCS= syslogd.c #.PATH: ${.CURDIR}/../../usr.bin/wall MAN8= syslogd.0 -#LDADD= -lutil +CFLAGS += -I/src/fearless/seth/src/proj/SOF/brimstone/include -DSECURENETS +LDADD= -lresolv -l44bsd -L/src/fearless/seth/src/proj/SOF/brimstone/BUILD/SunOS-4.1.3_U1-sun4m/lib -lsos -ldict -lfsma OBJ=${SRCS:.c=.o} +all: ${PROG} logger + ${PROG}: ${OBJ} - ${CC} -Bstatic ${CFLAGS} -o $@ ${OBJ} ${LDADD} + ${CC} -static ${CFLAGS} -o $@ ${OBJ} ${LDADD} + +logger: logger.o + ${CC} -static ${CFLAGS} -o $@ logger.o ${LDADD} clean: rm -f ${OBJ} ${PROG} *~ --- 1.1 1995/03/22 05:16:00 +++ logger.c 1995/03/22 05:16:27 @@ -80,7 +80,7 @@ argc--; if (freopen(*++argv, "r", stdin) == NULL) { - fprintf(stderrm"logger: "); + fprintf(stderr,"logger: "); perror(*argv); exit(1); } --- 1.1 1993/03/23 22:53:28 +++ syslogd.c 1995/05/10 23:30:22 @@ -1,11 +1,4 @@ /* -** Xkernel version 1.3 -** -** Xkernel changes by Seth Roberston -** -*/ - -/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. @@ -52,12 +45,17 @@ #include #include -#include #include #include #include +#ifndef SECURENETS #include +#endif /* !SECURENETS */ +#ifndef __bsdi__ #include +#endif /*__BSDi__*/ +#include +#include #include #include @@ -77,18 +75,20 @@ #include #include -#ifdef NORMAL -char *LogName = "/dev/log"; +#ifdef SECURENETS +#include "sos.h" +#define NOLOGSNETVIOSECS 300 /* 5 minutes between admin deny log messages */ +char *SnetsFile = "/etc/syslog.snets"; +SOS_Snets snets = NULL; +char *program = "syslog"; #endif + +char *LogName = "/dev/log"; + char *ConfFile = "/etc/syslog.conf"; -#ifdef NORMAL char *PidFile = "/etc/syslog.pid"; char ctty[] = "/dev/console"; -#else -char *PidFile = "/dev/null"; -char ctty[] = "/dev/console"; /* You might want to change this to /dev/null */ -#endif char panic_str[] = "panic:"; @@ -204,11 +204,7 @@ { register int i; register char *p; -#ifdef NORMAL int funix, finet, inetm, fklog, klogm, len; -#else - int finet, inetm, fklog, klogm, len; -#endif struct sockaddr_un sunx, fromunix; struct sockaddr_in sin, frominet; FILE *fp; @@ -231,12 +227,10 @@ Debug++; break; -#ifdef NORMAL case 'p': /* path */ if (p[2] != '\0') LogName = &p[2]; break; -#endif case 'm': /* mark interval */ if (p[2] != '\0') @@ -272,21 +266,26 @@ (void) signal(SIGQUIT, Debug ? die : SIG_IGN); (void) signal(SIGCHLD, reapchild); (void) signal(SIGALRM, doalarm); -#ifdef NORMAL (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); +#ifdef __bsdi__ + if (funix < 0 || bind(funix, (struct sockaddr *) &sunx, + sizeof(sunx.sun_family)+sizeof(sunx.sun_len)+ + strlen(sunx.sun_path)) < 0 || + chmod(LogName, 0666) < 0) { +#else /*__bsdi__*/ if (funix < 0 || bind(funix, (struct sockaddr *) &sunx, sizeof(sunx.sun_family)+strlen(sunx.sun_path)) < 0 || chmod(LogName, 0666) < 0) { +#endif /*__bsdi__*/ (void) sprintf(line, "cannot create %s", LogName); logerror(line); dprintf("cannot create %s (%d)\n", LogName, errno); die(0); } -#endif finet = socket(AF_INET, SOCK_DGRAM, 0); if (finet >= 0) { struct servent *sp; @@ -328,18 +327,10 @@ (void) signal(SIGHUP, init); for (;;) { -#ifdef NORMAL int nfds, readfds = FDMASK(funix) | inetm | klogm; -#else - int nfds, readfds = inetm | klogm; -#endif errno = 0; -#ifdef NORMAL dprintf("readfds = %#x\n", readfds, funix, finet, fklog); -#else - dprintf("readfds = %#x\n", readfds, finet, fklog); -#endif nfds = select(20, (fd_set *) &readfds, (fd_set *) NULL, (fd_set *) NULL, (struct timeval *) NULL); dprintf("got a message (%d, %#x)\n", nfds, readfds); @@ -361,7 +352,6 @@ klogm = 0; } } -#ifdef NORMAL if (readfds & FDMASK(funix)) { len = sizeof fromunix; i = recvfrom(funix, line, MAXLINE, 0, @@ -372,7 +362,6 @@ } else if (i < 0 && errno != EINTR) logerror("recvfrom unix"); } -#endif if (readfds & inetm) { len = sizeof frominet; i = recvfrom(finet, line, MAXLINE, 0, @@ -380,6 +369,25 @@ if (i > 0) { extern char *cvthname(); +#ifdef SECURENETS + if (snets && sos_CheckSecureNets(snets, frominet.sin_addr) != 1) + { + static int lastadmindeny = 0; + int curadmindeny; + char buf[100]; + + curadmindeny = time(NULL); + + if (curadmindeny > lastadmindeny + NOLOGSNETVIOSECS) + { + lastadmindeny = curadmindeny; + sprintf(buf, "Remote host %s is administratively prevented from logging", inet_ntoa(frominet.sin_addr)); + logerror(buf); + } + continue; + } +#endif /*SECURENETS*/ + line[i] = '\0'; printline(cvthname(&frominet), line, ALL); } else if (i < 0 && errno != EINTR) @@ -951,9 +959,7 @@ errno = 0; logerror(buf); } -#ifdef NORMAL (void) unlink(LogName); -#endif exit(0); } @@ -992,6 +998,16 @@ /* get the list of my addresses */ getmyaddr(); + +#ifdef SECURENETS + if (snets) + { + sos_FreeSecureNets(snets); + snets = NULL; + } + if (access(SnetsFile, R_OK) == 0) + snets = sos_LoadSecureNets_File(SnetsFile); +#endif /* open the configuration file */ if ((cf = fopen(ConfFile, "r")) == NULL) {