home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-02-01 | 25.7 KB | 1,089 lines |
- *** pristine-syslogd.c Thu Jan 31 11:58:58 1991
- --- syslogd.c Thu Jan 31 13:29:47 1991
- ***************
- *** 24,30 ****
- #endif /* not lint */
-
- #ifndef lint
- ! static char sccsid[] = "@(#)syslogd.c 5.42 (Berkeley) 6/29/90";
- #endif /* not lint */
-
- /*
- --- 24,30 ----
- #endif /* not lint */
-
- #ifndef lint
- ! static char sccsid[] = "@(#)syslogd.c 5.42 (Berkeley) 6/29/90, with ultrix/zephyr/COMPAT42 mods";
- #endif /* not lint */
-
- /*
- ***************
- *** 47,52 ****
- --- 47,57 ----
- * Author: Eric Allman
- * extensive changes by Ralph Campbell
- * more extensive changes by Eric Allman (again)
- + #ifdef ZEPHYR
- + * changes for Zephyr and a little dynamic allocation
- + * by Jon Rochlis (MIT), July 1987
- + #endif
- + * COMPAT42 changes by John Kohl (MIT/DEC), December 1990
- */
-
- #define MAXLINE 1024 /* maximum line length */
- ***************
- *** 62,68 ****
- --- 67,75 ----
- #include <sys/wait.h>
- #include <sys/socket.h>
- #include <sys/file.h>
- + #ifndef NO_KLOG
- #include <sys/msgbuf.h>
- + #endif
- #include <sys/uio.h>
- #include <sys/un.h>
- #include <sys/time.h>
- ***************
- *** 69,83 ****
- --- 76,101 ----
- #include <sys/resource.h>
- #include <sys/signal.h>
-
- + #ifdef ZEPHYR
- + #include <zephyr/zephyr.h>
- + #else
- #include <netinet/in.h>
- + #endif /* ZEPHYR */
- #include <netdb.h>
-
- + #ifdef macII
- + #include <sys/types.h>
- + #include <time.h>
- + #endif
- +
- #include <utmp.h>
- #include <setjmp.h>
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
- + #ifdef POSIX
- #include <unistd.h>
- + #endif
- #include "pathnames.h"
-
- #define SYSLOG_NAMES
- ***************
- *** 88,97 ****
- --- 106,132 ----
- char *PidFile = _PATH_LOGPID;
- char ctty[] = _PATH_CONSOLE;
-
- + #ifdef COMPAT42
- + struct in_addr localhostaddr;
- + #endif
- +
- #define FDMASK(fd) (1 << (fd))
-
- #define dprintf if (Debug) printf
-
- + #ifndef UT_NAMESIZE
- + #define UT_NAMESIZE 8
- + #endif
- + #ifndef _PATH_UTMP
- + #define _PATH_UTMP UTMP_FILE
- + #endif
- +
- + #ifdef ZEPHYR
- + #define UNAMESIZE ANAME_SZ+INST_SZ+REALM_SZ /* 8 isn't good enough anymore */
- + #else
- + #define UNAMESIZE UT_NAMESIZE
- + #endif
- +
- #define MAXUNAMES 20 /* maximum number of user names */
-
- /*
- ***************
- *** 115,121 ****
- time_t f_time; /* time this was last written */
- u_char f_pmask[LOG_NFACILITIES+1]; /* priority mask */
- union {
- ! char f_uname[MAXUNAMES][UT_NAMESIZE+1];
- struct {
- char f_hname[MAXHOSTNAMELEN+1];
- struct sockaddr_in f_addr;
- --- 150,156 ----
- time_t f_time; /* time this was last written */
- u_char f_pmask[LOG_NFACILITIES+1]; /* priority mask */
- union {
- ! char f_uname[MAXUNAMES][UNAMESIZE+1];
- struct {
- char f_hname[MAXHOSTNAMELEN+1];
- struct sockaddr_in f_addr;
- ***************
- *** 126,131 ****
- --- 161,167 ----
- char f_lasttime[16]; /* time of last occurrence */
- char f_prevhost[MAXHOSTNAMELEN+1]; /* host from which recd. */
- int f_prevpri; /* pri of f_prevline */
- + int f_prevfac; /* fac of f_prevline */
- int f_prevlen; /* length of f_prevline */
- int f_prevcount; /* repetition cnt of prevline */
- int f_repeatcount; /* number of "repeated" msgs */
- ***************
- *** 151,160 ****
- #define F_FORW 4 /* remote machine */
- #define F_USERS 5 /* list of users */
- #define F_WALL 6 /* everyone logged on */
-
- ! char *TypeNames[7] = {
- "UNUSED", "FILE", "TTY", "CONSOLE",
- "FORW", "USERS", "WALL"
- };
-
- struct filed *Files;
- --- 187,202 ----
- #define F_FORW 4 /* remote machine */
- #define F_USERS 5 /* list of users */
- #define F_WALL 6 /* everyone logged on */
- + #define F_ZEPHYR 7 /* use zephyr notification system */
-
- ! char *TypeNames[8] = {
- "UNUSED", "FILE", "TTY", "CONSOLE",
- "FORW", "USERS", "WALL"
- + #ifdef ZEPHYR
- + ,"ZEPHYR"
- + #else
- + ,0
- + #endif
- };
-
- struct filed *Files;
- ***************
- *** 170,178 ****
- --- 212,276 ----
- int MarkInterval = 20 * 60; /* interval between marks in seconds */
- int MarkSeq = 0; /* mark sequence number */
-
- + #ifdef ZEPHYR
- + ZNotice_t znotice; /* for zephyr notices */
- + #endif
- +
- + extern int sys_nerr;
- + extern char *sys_errlist[];
- +
- extern int errno;
- extern char *ctime(), *index(), *calloc();
-
- + #ifndef max
- + #define max(a,b) ((a) > (b) ? (a) : (b))
- + #endif
- +
- + #ifdef ZEPHYR
- +
- + /* private copies here, since the facility/priority names in the header file
- + are not in numerical order, and we need a no-gap table */
- +
- + CODE FacNames[] = {
- + "kern", LOG_KERN,
- + "user", LOG_USER,
- + "mail", LOG_MAIL,
- + "daemon", LOG_DAEMON,
- + "auth", LOG_AUTH,
- + "syslog", LOG_SYSLOG,
- + "lpr", LOG_LPR,
- + "news", LOG_NEWS,
- + "uucp", LOG_UUCP,
- + "cron", LOG_CRON,
- + "reserved", -1,
- + "reserved", -1,
- + "reserved", -1,
- + "reserved", -1,
- + "reserved", -1,
- + "compat", LOG_COMPAT,
- + "local0", LOG_LOCAL0,
- + "local1", LOG_LOCAL1,
- + "local2", LOG_LOCAL2,
- + "local3", LOG_LOCAL3,
- + "local4", LOG_LOCAL4,
- + "local5", LOG_LOCAL5,
- + "local6", LOG_LOCAL6,
- + "local7", LOG_LOCAL7,
- + NULL, -1,
- + };
- + CODE PriNames[] = {
- + "emerg", LOG_EMERG,
- + "alert", LOG_ALERT,
- + "crit", LOG_CRIT,
- + "err", LOG_ERR,
- + "warning", LOG_WARNING,
- + "notice", LOG_NOTICE,
- + "info", LOG_INFO,
- + "debug", LOG_DEBUG,
- + NULL, -1,
- + };
- + #endif
- +
- main(argc, argv)
- int argc;
- char **argv;
- ***************
- *** 184,193 ****
- struct sockaddr_in sin, frominet;
- FILE *fp;
- int ch;
- ! char line[MSG_BSIZE + 1];
- extern int optind;
- extern char *optarg;
- void die(), domark(), init(), reapchild();
-
- while ((ch = getopt(argc, argv, "df:m:p:")) != EOF)
- switch((char)ch) {
- --- 282,298 ----
- struct sockaddr_in sin, frominet;
- FILE *fp;
- int ch;
- ! #ifdef MSG_BSIZE
- ! char line[max(MSG_BSIZE,BUFSIZ) + 1];
- ! #else
- ! char line[BUFSIZ + 1];
- ! #endif
- extern int optind;
- extern char *optarg;
- void die(), domark(), init(), reapchild();
- + #ifdef COMPAT42
- + localhostaddr.s_addr = htonl(0x7f000001L); /* 127.0.0.1 */
- + #endif
-
- while ((ch = getopt(argc, argv, "df:m:p:")) != EOF)
- switch((char)ch) {
- ***************
- *** 212,219 ****
-
- if (!Debug)
- daemon(0, 0);
- ! else
- ! setlinebuf(stdout);
-
- consfile.f_type = F_CONSOLE;
- (void) strcpy(consfile.f_un.f_fname, ctty);
- --- 317,330 ----
-
- if (!Debug)
- daemon(0, 0);
- ! else {
- ! #ifndef macII
- ! setlinebuf(stdout);
- ! #else
- ! static char buf[BUFSIZ];
- ! setvbuf (stdout, buf, _IOLBF, BUFSIZ);
- ! #endif
- ! }
-
- consfile.f_type = F_CONSOLE;
- (void) strcpy(consfile.f_un.f_fname, ctty);
- ***************
- *** 225,232 ****
- --- 336,354 ----
- else
- LocalDomain = "";
- (void) signal(SIGTERM, die);
- + #ifdef ultrix
- + /* compiler otherwise chokes on the ? : */
- + if (Debug) {
- + (void) signal(SIGINT, die);
- + (void) signal(SIGQUIT, die);
- + } else {
- + (void) signal(SIGINT, SIG_IGN);
- + (void) signal(SIGQUIT, SIG_IGN);
- + }
- + #else
- (void) signal(SIGINT, Debug ? die : SIG_IGN);
- (void) signal(SIGQUIT, Debug ? die : SIG_IGN);
- + #endif
- (void) signal(SIGCHLD, reapchild);
- (void) signal(SIGALRM, domark);
- (void) alarm(TIMERINTVL);
- ***************
- *** 237,243 ****
- (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.sun_family)+sizeof(sunx.sun_len)+
- strlen(sunx.sun_path)) < 0 ||
- chmod(LogName, 0666) < 0) {
- (void) sprintf(line, "cannot create %s", LogName);
- --- 359,368 ----
- (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.sun_family)+
- ! #ifdef TAHOE_SOCKETS
- ! sizeof(sunx.sun_len)+
- ! #endif
- strlen(sunx.sun_path)) < 0 ||
- chmod(LogName, 0666) < 0) {
- (void) sprintf(line, "cannot create %s", LogName);
- ***************
- *** 266,271 ****
- --- 391,400 ----
- InetInuse = 1;
- }
- }
- + #ifdef NO_KLOG
- + klogm = 0;
- + fklog = 0;
- + #else
- if ((fklog = open(_PATH_KLOG, O_RDONLY, 0)) >= 0)
- klogm = FDMASK(fklog);
- else {
- ***************
- *** 272,277 ****
- --- 401,407 ----
- dprintf("can't open %s (%d)\n", _PATH_KLOG, errno);
- klogm = 0;
- }
- + #endif
-
- /* tuck my process id away */
- fp = fopen(PidFile, "w");
- ***************
- *** 282,287 ****
- --- 412,427 ----
-
- dprintf("off & running....\n");
-
- + #ifdef ZEPHYR
- + /* initialize zephyr stuff */
- + bzero (&znotice, sizeof (znotice));
- + znotice.z_kind = UNSAFE;
- + znotice.z_class = "SYSLOG";
- + znotice.z_class_inst = LocalHostName;
- + znotice.z_default_format = "Syslog message from $instance, level $opcode:\n$message";
- + (void) ZInitialize ();
- + #endif
- +
- init();
- (void) signal(SIGHUP, init);
-
- ***************
- *** 317,323 ****
- (struct sockaddr *) &fromunix, &len);
- if (i > 0) {
- line[i] = '\0';
- ! printline(LocalHostName, line);
- } else if (i < 0 && errno != EINTR)
- logerror("recvfrom unix");
- }
- --- 457,463 ----
- (struct sockaddr *) &fromunix, &len);
- if (i > 0) {
- line[i] = '\0';
- ! printline(LocalHostName, line, 0);
- } else if (i < 0 && errno != EINTR)
- logerror("recvfrom unix");
- }
- ***************
- *** 329,335 ****
- extern char *cvthname();
-
- line[i] = '\0';
- ! printline(cvthname(&frominet), line);
- } else if (i < 0 && errno != EINTR)
- logerror("recvfrom inet");
- }
- --- 469,483 ----
- extern char *cvthname();
-
- line[i] = '\0';
- ! #ifdef COMPAT42
- ! /* if it matches the localhost loopback,
- ! this is an old client, so humor him. */
- ! if (frominet.sin_addr.s_addr ==
- ! localhostaddr.s_addr)
- ! printline(cvthname(&frominet), line, 1);
- ! else
- ! #endif
- ! printline(cvthname(&frominet), line, 0);
- } else if (i < 0 && errno != EINTR)
- logerror("recvfrom inet");
- }
- ***************
- *** 343,356 ****
- exit(1);
- }
-
- /*
- * Take a raw input line, decode the message, and print the message
- * on the appropriate log files.
- */
-
- ! printline(hname, msg)
- char *hname;
- char *msg;
- {
- register char *p, *q;
- register int c;
- --- 491,522 ----
- exit(1);
- }
-
- + #ifdef COMPAT42
- + int convert_oldpri[] = {
- + LOG_COMPAT|LOG_EMERG, /* there is no 0 */
- + LOG_COMPAT|LOG_ALERT, /* old LOG_ALERT */
- + LOG_COMPAT|LOG_ALERT, /* old LOG_SALERT */
- + LOG_COMPAT|LOG_CRIT, /* old LOG_EMERG */
- + LOG_COMPAT|LOG_ERR, /* old LOG_ERROR */
- + LOG_COMPAT|LOG_WARNING, /* old LOG_CRIT */
- + LOG_COMPAT|LOG_WARNING, /* old LOG_WARNING */
- + LOG_COMPAT|LOG_NOTICE, /* old LOG_NOTICE */
- + LOG_COMPAT|LOG_INFO, /* old LOG_INFO */
- + LOG_COMPAT|LOG_DEBUG, /* old LOG_DEBUG */
- + };
- + int noldpri = sizeof(convert_oldpri)/sizeof(convert_oldpri[0]);
- + #endif
- +
- +
- /*
- * Take a raw input line, decode the message, and print the message
- * on the appropriate log files.
- */
-
- ! printline(hname, msg, oldcompat)
- char *hname;
- char *msg;
- + int oldcompat;
- {
- register char *p, *q;
- register int c;
- ***************
- *** 367,372 ****
- --- 533,546 ----
- if (*p == '>')
- ++p;
- }
- + #ifdef COMPAT42
- + if (oldcompat) {
- + if (pri > 0 && pri < noldpri)
- + pri = convert_oldpri[pri];
- + else
- + pri = LOG_MAKEPRI(LOG_COMPAT, LOG_ERR);
- + }
- + #endif
- if (pri &~ (LOG_FACMASK|LOG_PRIMASK))
- pri = DEFUPRI;
-
- ***************
- *** 435,440 ****
- --- 609,630 ----
-
- time_t now;
-
- + #ifndef O_NOCTTY
- + void
- + untty()
- + {
- + int i;
- +
- + if (!Debug) {
- + i = open("/dev/tty", O_RDWR);
- + if (i >= 0) {
- + (void) ioctl(i, (int) TIOCNOTTY, (char *)0);
- + (void) close(i);
- + }
- + }
- + }
- + #endif
- +
- /*
- * Log a message to the appropriate log files, users, etc. based on
- * the priority.
- ***************
- *** 483,492 ****
- /* log the message to the particular outputs */
- if (!Initialized) {
- f = &consfile;
- f->f_file = open(ctty, O_WRONLY, 0);
-
- if (f->f_file >= 0) {
- ! fprintlog(f, flags, msg);
- (void) close(f->f_file);
- }
- (void) sigsetmask(omask);
- --- 673,689 ----
- /* log the message to the particular outputs */
- if (!Initialized) {
- f = &consfile;
- + #ifdef O_NOCTTY
- + f->f_file = open(ctty, O_WRONLY|O_NOCTTY, 0);
- + #else
- f->f_file = open(ctty, O_WRONLY, 0);
- + #endif
-
- if (f->f_file >= 0) {
- ! #ifndef O_NOCTTY
- ! untty();
- ! #endif
- ! fprintlog(f, flags, msg, fac, prilev);
- (void) close(f->f_file);
- }
- (void) sigsetmask(omask);
- ***************
- *** 523,535 ****
- * in the future.
- */
- if (now > REPEATTIME(f)) {
- ! fprintlog(f, flags, (char *)NULL);
- BACKOFF(f);
- }
- } else {
- /* new line, save it */
- if (f->f_prevcount)
- ! fprintlog(f, 0, (char *)NULL);
- f->f_repeatcount = 0;
- (void) strncpy(f->f_lasttime, timestamp, 15);
- (void) strncpy(f->f_prevhost, from,
- --- 720,732 ----
- * in the future.
- */
- if (now > REPEATTIME(f)) {
- ! fprintlog(f, flags, (char *)NULL, fac, prilev);
- BACKOFF(f);
- }
- } else {
- /* new line, save it */
- if (f->f_prevcount)
- ! fprintlog(f, 0, (char *)NULL, fac, prilev);
- f->f_repeatcount = 0;
- (void) strncpy(f->f_lasttime, timestamp, 15);
- (void) strncpy(f->f_prevhost, from,
- ***************
- *** 537,548 ****
- if (msglen < MAXSVLINE) {
- f->f_prevlen = msglen;
- f->f_prevpri = pri;
- (void) strcpy(f->f_prevline, msg);
- ! fprintlog(f, flags, (char *)NULL);
- } else {
- f->f_prevline[0] = 0;
- f->f_prevlen = 0;
- ! fprintlog(f, flags, msg);
- }
- }
- }
- --- 734,746 ----
- if (msglen < MAXSVLINE) {
- f->f_prevlen = msglen;
- f->f_prevpri = pri;
- + f->f_prevfac = fac;
- (void) strcpy(f->f_prevline, msg);
- ! fprintlog(f, flags, (char *)NULL, fac, prilev);
- } else {
- f->f_prevline[0] = 0;
- f->f_prevlen = 0;
- ! fprintlog(f, flags, msg, fac, prilev);
- }
- }
- }
- ***************
- *** 549,570 ****
- (void) sigsetmask(omask);
- }
-
- ! fprintlog(f, flags, msg)
- register struct filed *f;
- int flags;
- char *msg;
- {
- struct iovec iov[6];
- register struct iovec *v;
- register int l;
- char line[MAXLINE + 1], repbuf[80], greetings[200];
-
- v = iov;
- if (f->f_type == F_WALL) {
- v->iov_base = greetings;
- ! v->iov_len = sprintf(greetings,
- "\r\n\7Message from syslogd@%s at %.24s ...\r\n",
- f->f_prevhost, ctime(&now));
- v++;
- v->iov_base = "";
- v->iov_len = 0;
- --- 747,776 ----
- (void) sigsetmask(omask);
- }
-
- ! fprintlog(f, flags, msg, fac, prilev)
- register struct filed *f;
- int flags;
- char *msg;
- + int fac;
- + int prilev;
- {
- struct iovec iov[6];
- register struct iovec *v;
- register int l;
- char line[MAXLINE + 1], repbuf[80], greetings[200];
- + #ifdef ZEPHYR
- + char pri_fac_str[MAXLINE];
- + int zcode;
- + register int i;
- + #endif
-
- v = iov;
- if (f->f_type == F_WALL) {
- v->iov_base = greetings;
- ! (void) sprintf(greetings,
- "\r\n\7Message from syslogd@%s at %.24s ...\r\n",
- f->f_prevhost, ctime(&now));
- + v->iov_len = strlen(greetings);
- v++;
- v->iov_base = "";
- v->iov_len = 0;
- ***************
- *** 589,596 ****
- v->iov_len = strlen(msg);
- } else if (f->f_prevcount > 1) {
- v->iov_base = repbuf;
- ! v->iov_len = sprintf(repbuf, "last message repeated %d times",
- f->f_prevcount);
- } else {
- v->iov_base = f->f_prevline;
- v->iov_len = f->f_prevlen;
- --- 795,803 ----
- v->iov_len = strlen(msg);
- } else if (f->f_prevcount > 1) {
- v->iov_base = repbuf;
- ! (void) sprintf(repbuf, "last message repeated %d times",
- f->f_prevcount);
- + v->iov_len = strlen(repbuf);
- } else {
- v->iov_base = f->f_prevline;
- v->iov_len = f->f_prevlen;
- ***************
- *** 607,614 ****
-
- case F_FORW:
- dprintf(" %s\n", f->f_un.f_forw.f_hname);
- ! l = sprintf(line, "<%d>%.15s %s", f->f_prevpri,
- iov[0].iov_base, iov[4].iov_base);
- if (l > MAXLINE)
- l = MAXLINE;
- if (sendto(finet, line, l, 0, &f->f_un.f_forw.f_addr,
- --- 814,822 ----
-
- case F_FORW:
- dprintf(" %s\n", f->f_un.f_forw.f_hname);
- ! (void) sprintf(line, "<%d>%.15s %s", f->f_prevpri,
- iov[0].iov_base, iov[4].iov_base);
- + l = strlen(line);
- if (l > MAXLINE)
- l = MAXLINE;
- if (sendto(finet, line, l, 0, &f->f_un.f_forw.f_addr,
- ***************
- *** 662,667 ****
- --- 870,905 ----
- (void) fsync(f->f_file);
- break;
-
- + #ifdef ZEPHYR
- + case F_ZEPHYR:
- + (void) sprintf(line, "%.15s [%s] %s",
- + iov[0].iov_base,
- + iov[2].iov_base,
- + iov[4].iov_base);
- + (void) sprintf(pri_fac_str, "%s.%s",
- + FacNames[fac].c_name,
- + PriNames[(prilev & LOG_PRIMASK)].c_name);
- + znotice.z_message = line;
- + /* include the null just in case */
- + znotice.z_message_len = strlen (line) + 1;
- + znotice.z_opcode = pri_fac_str;
- + dprintf (" z_opcode %s\n", pri_fac_str);
- + for (i = 0; i < MAXUNAMES; i++) {
- + if (!f->f_un.f_uname[i][0])
- + break;
- + /* map "*" into null recipient and therefore
- + anybody who is listening */
- + if (strcmp (f->f_un.f_uname[i], "*") == 0)
- + znotice.z_recipient = "";
- + else
- + znotice.z_recipient = f->f_un.f_uname[i];
- + zcode = ZSendNotice (&znotice, ZNOAUTH);
- + if (zcode != 0)
- + logerror (error_message (zcode));
- + }
- + break;
- + #endif
- +
- case F_USERS:
- case F_WALL:
- dprintf("\n");
- ***************
- *** 752,757 ****
- --- 990,1000 ----
- dprintf("Malformed from address\n");
- return ("???");
- }
- + #ifdef COMPAT42
- + /* don't bother looking up 127.0.0.1, it's us. */
- + if (f->sin_addr.s_addr == localhostaddr.s_addr)
- + return(LocalHostName);
- + #endif
- hp = gethostbyaddr(&f->sin_addr, sizeof(struct in_addr), f->sin_family);
- if (hp == 0) {
- dprintf("Host name for your address (%s) unknown\n",
- ***************
- *** 781,787 ****
- dprintf("flush %s: repeated %d times, %d sec.\n",
- TypeNames[f->f_type], f->f_prevcount,
- repeatinterval[f->f_repeatcount]);
- ! fprintlog(f, 0, (char *)NULL);
- BACKOFF(f);
- }
- }
- --- 1024,1030 ----
- dprintf("flush %s: repeated %d times, %d sec.\n",
- TypeNames[f->f_type], f->f_prevcount,
- repeatinterval[f->f_repeatcount]);
- ! fprintlog(f, 0, (char *)NULL, f->f_prevfac, f->f_prevpri);
- BACKOFF(f);
- }
- }
- ***************
- *** 814,820 ****
- for (f = Files; f != NULL; f = f->f_next) {
- /* flush any pending output */
- if (f->f_prevcount)
- ! fprintlog(f, 0, (char *)NULL);
- }
- if (sig) {
- dprintf("syslogd: exiting on signal %d\n", sig);
- --- 1057,1063 ----
- for (f = Files; f != NULL; f = f->f_next) {
- /* flush any pending output */
- if (f->f_prevcount)
- ! fprintlog(f, 0, (char *)NULL, f->f_prevfac, f->f_prevpri);
- }
- if (sig) {
- dprintf("syslogd: exiting on signal %d\n", sig);
- ***************
- *** 848,860 ****
- for (f = Files; f != NULL; f = next) {
- /* flush any pending output */
- if (f->f_prevcount)
- ! fprintlog(f, 0, (char *)NULL);
-
- switch (f->f_type) {
- case F_FILE:
- case F_TTY:
- case F_CONSOLE:
- - case F_FORW:
- (void) close(f->f_file);
- break;
- }
- --- 1091,1102 ----
- for (f = Files; f != NULL; f = next) {
- /* flush any pending output */
- if (f->f_prevcount)
- ! fprintlog(f, 0, (char *)NULL, f->f_prevfac, f->f_prevpri);
-
- switch (f->f_type) {
- case F_FILE:
- case F_TTY:
- case F_CONSOLE:
- (void) close(f->f_file);
- break;
- }
- ***************
- *** 920,925 ****
- --- 1162,1168 ----
- break;
-
- case F_USERS:
- + case F_ZEPHYR:
- for (i = 0; i < MAXUNAMES && *f->f_un.f_uname[i]; i++)
- printf("%s, ", f->f_un.f_uname[i]);
- break;
- ***************
- *** 1025,1031 ****
- hp = gethostbyname(p);
- if (hp == NULL) {
- extern int h_errno, h_nerr;
- ! extern char **h_errlist;
-
- logerror((u_int)h_errno < h_nerr ?
- h_errlist[h_errno] : "Unknown error");
- --- 1268,1274 ----
- hp = gethostbyname(p);
- if (hp == NULL) {
- extern int h_errno, h_nerr;
- ! extern char *h_errlist[];
-
- logerror((u_int)h_errno < h_nerr ?
- h_errlist[h_errno] : "Unknown error");
- ***************
- *** 1041,1064 ****
-
- case '/':
- (void) strcpy(f->f_un.f_fname, p);
- ! if ((f->f_file = open(p, O_WRONLY|O_APPEND, 0)) < 0) {
- f->f_file = F_UNUSED;
- logerror(p);
- break;
- }
- ! if (isatty(f->f_file))
- f->f_type = F_TTY;
- ! else
- f->f_type = F_FILE;
- if (strcmp(p, ctty) == 0)
- f->f_type = F_CONSOLE;
- break;
-
- case '*':
- f->f_type = F_WALL;
- break;
- !
- ! default:
- for (i = 0; i < MAXUNAMES && *p; i++) {
- for (q = p; *q && *q != ','; )
- q++;
- --- 1284,1322 ----
-
- case '/':
- (void) strcpy(f->f_un.f_fname, p);
- ! #ifdef O_NOCTTY
- ! #define FLAGS O_WRONLY|O_APPEND|O_NOCTTY
- ! #else
- ! #define FLAGS O_WRONLY|O_APPEND
- ! #endif
- ! if ((f->f_file = open(p, FLAGS, 0)) < 0) {
- ! #undef FLAGS
- f->f_file = F_UNUSED;
- logerror(p);
- break;
- }
- ! if (isatty(f->f_file)) {
- f->f_type = F_TTY;
- ! #ifndef O_NOCTTY
- ! untty();
- ! #endif
- ! } else
- f->f_type = F_FILE;
- if (strcmp(p, ctty) == 0)
- f->f_type = F_CONSOLE;
- break;
-
- + #ifndef ZEPHYR
- case '*':
- f->f_type = F_WALL;
- break;
- ! #else
- ! case '!':
- ! p++;
- ! if (*p == '*') {
- ! f->f_type = F_WALL;
- ! break;
- ! }
- for (i = 0; i < MAXUNAMES && *p; i++) {
- for (q = p; *q && *q != ','; )
- q++;
- ***************
- *** 1072,1077 ****
- --- 1330,1356 ----
- p = q;
- }
- f->f_type = F_USERS;
- + break;
- + #endif
- +
- + default:
- + for (i = 0; i < MAXUNAMES && *p; i++) {
- + for (q = p; *q && *q != ','; )
- + q++;
- + (void) strncpy(f->f_un.f_uname[i], p, UNAMESIZE);
- + if ((q - p) > UNAMESIZE)
- + f->f_un.f_uname[i][UNAMESIZE] = '\0';
- + else
- + f->f_un.f_uname[i][q - p] = '\0';
- + while (*q == ',' || *q == ' ')
- + q++;
- + p = q;
- + }
- + #ifdef ZEPHYR
- + f->f_type = F_ZEPHYR;
- + #else
- + f->f_type = F_USERS;
- + #endif
- break;
- }
- }
- *** pristine-syslog.h Thu Jan 31 12:18:55 1991
- --- syslog.h Thu Jan 31 13:26:30 1991
- ***************
- *** 17,23 ****
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- ! * @(#)syslog.h 7.16 (Berkeley) 6/28/90
- */
-
- /*
- --- 17,23 ----
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- ! * @(#)syslog.h 7.16 (Berkeley) 6/28/90, with COMPAT42 mods
- */
-
- /*
- ***************
- *** 80,85 ****
- --- 80,86 ----
- #define LOG_NEWS (7<<3) /* network news subsystem */
- #define LOG_UUCP (8<<3) /* UUCP subsystem */
- #define LOG_CRON (9<<3) /* clock daemon */
- + #define LOG_COMPAT (15<<3) /* compatibility with 4.2 syslog */
- /* other codes through 15 reserved for system use */
- #define LOG_LOCAL0 (16<<3) /* reserved for local use */
- #define LOG_LOCAL1 (17<<3) /* reserved for local use */
- ***************
- *** 98,103 ****
- --- 99,105 ----
- #ifdef SYSLOG_NAMES
- CODE facilitynames[] = {
- "auth", LOG_AUTH,
- + "compat", LOG_COMPAT,
- "cron", LOG_CRON,
- "daemon", LOG_DAEMON,
- "kern", LOG_KERN,
- *** pristine-pathnames.h Thu Jan 31 13:20:23 1991
- --- pathnames.h Thu Jan 31 13:21:00 1991
- ***************
- *** 16,22 ****
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- ! * @(#)pathnames.h 5.3 (Berkeley) 6/1/90
- */
-
- #include <paths.h>
- --- 16,22 ----
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- ! * @(#)pathnames.h 5.3 (Berkeley) 6/1/90, with COMPAT42 mods
- */
-
- #include <paths.h>
- ***************
- *** 23,27 ****
- --- 23,32 ----
-
- #define _PATH_KLOG "/dev/klog"
- #define _PATH_LOG "/dev/log"
- + #ifdef COMPAT42
- + #define _PATH_LOGCONF "/etc/nsyslog.conf"
- + #define _PATH_LOGPID "/etc/nsyslog.pid"
- + #else
- #define _PATH_LOGCONF "/etc/syslog.conf"
- #define _PATH_LOGPID "/var/run/syslog.pid"
- + #endif
- *** pristine-syslog.c Thu Jan 31 13:49:38 1991
- --- syslog.c Thu Jan 31 13:56:42 1991
- ***************
- *** 18,24 ****
- */
-
- #if defined(LIBC_SCCS) && !defined(lint)
- ! static char sccsid[] = "@(#)syslog.c 5.28 (Berkeley) 6/27/90";
- #endif /* LIBC_SCCS and not lint */
-
- /*
- --- 18,24 ----
- */
-
- #if defined(LIBC_SCCS) && !defined(lint)
- ! static char sccsid[] = "@(#)syslog.c 5.28 (Berkeley) 6/27/90, with varags changes";
- #endif /* LIBC_SCCS and not lint */
-
- /*
- ***************
- *** 37,42 ****
- --- 37,48 ----
- * Modified to use UNIX domain IPC by Ralph Campbell
- */
-
- + #ifdef __STDC__
- + #include <stdarg.h>
- + #else
- + #include <varargs.h>
- + #endif
- +
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <sys/file.h>
- ***************
- *** 46,52 ****
- #include <sys/wait.h>
- #include <netdb.h>
- #include <string.h>
- - #include <varargs.h>
- #include <paths.h>
- #include <stdio.h>
-
- --- 52,57 ----
- ***************
- *** 58,68 ****
- static char *LogTag = "syslog"; /* string to tag the entry with */
- static int LogFacility = LOG_USER; /* default facility code */
-
- ! syslog(pri, fmt, args)
- ! int pri, args;
- ! char *fmt;
- {
- ! vsyslog(pri, fmt, &args);
- }
-
- vsyslog(pri, fmt, ap)
- --- 63,85 ----
- static char *LogTag = "syslog"; /* string to tag the entry with */
- static int LogFacility = LOG_USER; /* default facility code */
-
- ! #ifdef __STDC__
- ! syslog(int pri, const char *fmt, ...)
- ! #else
- ! syslog(pri, fmt, va_alist)
- ! int pri;
- ! char *fmt;
- ! va_dcl
- ! #endif
- {
- ! va_list pvar;
- ! #ifdef __STDC__
- ! va_start(pvar, fmt);
- ! #else
- ! va_start(pvar);
- ! #endif
- ! vsyslog(pri, fmt, pvar);
- ! va_end(pvar);
- }
-
- vsyslog(pri, fmt, ap)
- ***************
- *** 149,156 ****
- --- 166,178 ----
- * output the message to the console; don't worry about
- * blocking, if console blocks everything will.
- */
- + #ifdef O_NOCTTY
- + if ((fd = open(_PATH_CONSOLE, O_NOCTTY|O_WRONLY, 0)) < 0)
- + return;
- + #else
- if ((fd = open(_PATH_CONSOLE, O_WRONLY, 0)) < 0)
- return;
- + #endif
- (void)strcat(tbuf, "\r\n");
- cnt += 2;
- p = index(tbuf, '>') + 1;
-