Ultrix (3.1) modifications to 4.3BSD syslogd
John T Kohl
jtkohl at MIT.EDU
Fri Feb 1 08:59:09 AEST 1991
Attached is a shar file with some brief instructions and a makefile to
convert the syslogd on ftp.uu.net to work with old 4.2-style syslog()
programs, such as those found on Ultrix 3.1. I've not tested this
stuff on Ultrix 4.x, since I don't have such a beast to play with.
Shar and enjoy!
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: README Makefile ultrix.syslogd.patches nsyslog.conf
# Wrapped by jtkohl at quicksilver on Thu Jan 31 13:57:30 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(1156 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
XHow to get a 4.3-Tahoe+ syslogd to work on an Ultrix 3.1 system, and
Xthrow out the old ultrix 4.2 syslog:
X
X1. pick up the following files from ftp.uu.net, and put them into a
Xsource directory:
X
X/bsd-sources/sys/sys/syslog.h
X/bsd-sources/include/paths.h
X/bsd-sources/lib/libutil/daemon.c
X/bsd-sources/lib/libc/string/strerror.c
X/bsd-sources/lib/libc/net/herror.c
X/bsd-sources/usr.bin/wall/ttymsg.c
X/bsd-sources/lib/libc/gen/syslog.c
X/bsd-sources/usr.sbin/syslogd/syslogd.c
X/bsd-sources/usr.sbin/syslogd/pathnames.h
X
X2. symlink sys to point to .:
X ln -s . sys
X
X3. apply the enclosed patches:
X patch <ultrix.syslogd.patches
X
X4. edit Makefile, turning on or off Zephyr(*) as appropriate for your site.
X
X5. type 'make'
X
X6. look at nsyslog.conf and edit as appropriate. Install into
X/etc/nsyslog.conf. Put syslogd wherever you want to.
X
X7. If you want to write or port programs using the 4.3BSD syslogging
Xfunctions, make sure it gets this version of syslog.h and compiles in
Xthe new syslog.c.
X
X8. beware of pathnames if you turn off COMPAT42
X
X[*. If you want to pick up Zephyr sources or read about it, anonymous FTP to
X athena-dist.mit.edu:/pub/zephyr/ ]
X
END_OF_FILE
if test 1156 -ne `wc -c <'README'`; then
echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(934 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
XCFLAGS= $(DBG) $(INCLUDES) $(DEFINES)
XDBG=-O
XINCLUDES=-I.
X# use these lines if you have zephyr
XDEFINES=-YPOSIX -DNO_KLOG -DCOMPAT42 -DZEPHYR
XZLIBS=-lzephyr -lcom_err -lkrb
X
X#use these if you don't
X# you can nuke ZLIBS if you don't turn on ZEPHYR
X#DEFINES=-YPOSIX -DNO_KLOG -DCOMPAT42 -DZEPHYR
X#ZLIBS=
X
X
XOFILES=syslogd.o herror.o daemon.o strerror.o ttymsg.o
X
Xsyslogd: $(OFILES)
X $(CC) $(CFLAGS) -o syslogd $(OFILES) $(ZLIBS)
X
X#
X# -YPOSIX (on ultrix means) set -DPOSIX
X# -DPOSIX means you have <unistd.h>
X# -DNO_KLOG means you don't have /dev/klog (kernel syslogging)
X# -DCOMPAT42 means you want to be compatible with programs using
X# 4.2 syslog() calls
X# -DZEPHYR means you want to enable forwarding of syslog stuff via Zephyr
X# [if you turn this on, target entries like "!user" go via wall/write
X# style, and entries like "user" go via Zephyr]
X# -DTAHOE_SOCKETS means you have the type and length fields in your socket
X# structures.
END_OF_FILE
if test 934 -ne `wc -c <'Makefile'`; then
echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'ultrix.syslogd.patches' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'ultrix.syslogd.patches'\"
else
echo shar: Extracting \"'ultrix.syslogd.patches'\" \(26306 characters\)
sed "s/^X//" >'ultrix.syslogd.patches' <<'END_OF_FILE'
X*** pristine-syslogd.c Thu Jan 31 11:58:58 1991
X--- syslogd.c Thu Jan 31 13:29:47 1991
X***************
X*** 24,30 ****
X #endif /* not lint */
X
X #ifndef lint
X! static char sccsid[] = "@(#)syslogd.c 5.42 (Berkeley) 6/29/90";
X #endif /* not lint */
X
X /*
X--- 24,30 ----
X #endif /* not lint */
X
X #ifndef lint
X! static char sccsid[] = "@(#)syslogd.c 5.42 (Berkeley) 6/29/90, with ultrix/zephyr/COMPAT42 mods";
X #endif /* not lint */
X
X /*
X***************
X*** 47,52 ****
X--- 47,57 ----
X * Author: Eric Allman
X * extensive changes by Ralph Campbell
X * more extensive changes by Eric Allman (again)
X+ #ifdef ZEPHYR
X+ * changes for Zephyr and a little dynamic allocation
X+ * by Jon Rochlis (MIT), July 1987
X+ #endif
X+ * COMPAT42 changes by John Kohl (MIT/DEC), December 1990
X */
X
X #define MAXLINE 1024 /* maximum line length */
X***************
X*** 62,68 ****
X--- 67,75 ----
X #include <sys/wait.h>
X #include <sys/socket.h>
X #include <sys/file.h>
X+ #ifndef NO_KLOG
X #include <sys/msgbuf.h>
X+ #endif
X #include <sys/uio.h>
X #include <sys/un.h>
X #include <sys/time.h>
X***************
X*** 69,83 ****
X--- 76,101 ----
X #include <sys/resource.h>
X #include <sys/signal.h>
X
X+ #ifdef ZEPHYR
X+ #include <zephyr/zephyr.h>
X+ #else
X #include <netinet/in.h>
X+ #endif /* ZEPHYR */
X #include <netdb.h>
X
X+ #ifdef macII
X+ #include <sys/types.h>
X+ #include <time.h>
X+ #endif
X+
X #include <utmp.h>
X #include <setjmp.h>
X #include <stdio.h>
X #include <ctype.h>
X #include <string.h>
X+ #ifdef POSIX
X #include <unistd.h>
X+ #endif
X #include "pathnames.h"
X
X #define SYSLOG_NAMES
X***************
X*** 88,97 ****
X--- 106,132 ----
X char *PidFile = _PATH_LOGPID;
X char ctty[] = _PATH_CONSOLE;
X
X+ #ifdef COMPAT42
X+ struct in_addr localhostaddr;
X+ #endif
X+
X #define FDMASK(fd) (1 << (fd))
X
X #define dprintf if (Debug) printf
X
X+ #ifndef UT_NAMESIZE
X+ #define UT_NAMESIZE 8
X+ #endif
X+ #ifndef _PATH_UTMP
X+ #define _PATH_UTMP UTMP_FILE
X+ #endif
X+
X+ #ifdef ZEPHYR
X+ #define UNAMESIZE ANAME_SZ+INST_SZ+REALM_SZ /* 8 isn't good enough anymore */
X+ #else
X+ #define UNAMESIZE UT_NAMESIZE
X+ #endif
X+
X #define MAXUNAMES 20 /* maximum number of user names */
X
X /*
X***************
X*** 115,121 ****
X time_t f_time; /* time this was last written */
X u_char f_pmask[LOG_NFACILITIES+1]; /* priority mask */
X union {
X! char f_uname[MAXUNAMES][UT_NAMESIZE+1];
X struct {
X char f_hname[MAXHOSTNAMELEN+1];
X struct sockaddr_in f_addr;
X--- 150,156 ----
X time_t f_time; /* time this was last written */
X u_char f_pmask[LOG_NFACILITIES+1]; /* priority mask */
X union {
X! char f_uname[MAXUNAMES][UNAMESIZE+1];
X struct {
X char f_hname[MAXHOSTNAMELEN+1];
X struct sockaddr_in f_addr;
X***************
X*** 126,131 ****
X--- 161,167 ----
X char f_lasttime[16]; /* time of last occurrence */
X char f_prevhost[MAXHOSTNAMELEN+1]; /* host from which recd. */
X int f_prevpri; /* pri of f_prevline */
X+ int f_prevfac; /* fac of f_prevline */
X int f_prevlen; /* length of f_prevline */
X int f_prevcount; /* repetition cnt of prevline */
X int f_repeatcount; /* number of "repeated" msgs */
X***************
X*** 151,160 ****
X #define F_FORW 4 /* remote machine */
X #define F_USERS 5 /* list of users */
X #define F_WALL 6 /* everyone logged on */
X
X! char *TypeNames[7] = {
X "UNUSED", "FILE", "TTY", "CONSOLE",
X "FORW", "USERS", "WALL"
X };
X
X struct filed *Files;
X--- 187,202 ----
X #define F_FORW 4 /* remote machine */
X #define F_USERS 5 /* list of users */
X #define F_WALL 6 /* everyone logged on */
X+ #define F_ZEPHYR 7 /* use zephyr notification system */
X
X! char *TypeNames[8] = {
X "UNUSED", "FILE", "TTY", "CONSOLE",
X "FORW", "USERS", "WALL"
X+ #ifdef ZEPHYR
X+ ,"ZEPHYR"
X+ #else
X+ ,0
X+ #endif
X };
X
X struct filed *Files;
X***************
X*** 170,178 ****
X--- 212,276 ----
X int MarkInterval = 20 * 60; /* interval between marks in seconds */
X int MarkSeq = 0; /* mark sequence number */
X
X+ #ifdef ZEPHYR
X+ ZNotice_t znotice; /* for zephyr notices */
X+ #endif
X+
X+ extern int sys_nerr;
X+ extern char *sys_errlist[];
X+
X extern int errno;
X extern char *ctime(), *index(), *calloc();
X
X+ #ifndef max
X+ #define max(a,b) ((a) > (b) ? (a) : (b))
X+ #endif
X+
X+ #ifdef ZEPHYR
X+
X+ /* private copies here, since the facility/priority names in the header file
X+ are not in numerical order, and we need a no-gap table */
X+
X+ CODE FacNames[] = {
X+ "kern", LOG_KERN,
X+ "user", LOG_USER,
X+ "mail", LOG_MAIL,
X+ "daemon", LOG_DAEMON,
X+ "auth", LOG_AUTH,
X+ "syslog", LOG_SYSLOG,
X+ "lpr", LOG_LPR,
X+ "news", LOG_NEWS,
X+ "uucp", LOG_UUCP,
X+ "cron", LOG_CRON,
X+ "reserved", -1,
X+ "reserved", -1,
X+ "reserved", -1,
X+ "reserved", -1,
X+ "reserved", -1,
X+ "compat", LOG_COMPAT,
X+ "local0", LOG_LOCAL0,
X+ "local1", LOG_LOCAL1,
X+ "local2", LOG_LOCAL2,
X+ "local3", LOG_LOCAL3,
X+ "local4", LOG_LOCAL4,
X+ "local5", LOG_LOCAL5,
X+ "local6", LOG_LOCAL6,
X+ "local7", LOG_LOCAL7,
X+ NULL, -1,
X+ };
X+ CODE PriNames[] = {
X+ "emerg", LOG_EMERG,
X+ "alert", LOG_ALERT,
X+ "crit", LOG_CRIT,
X+ "err", LOG_ERR,
X+ "warning", LOG_WARNING,
X+ "notice", LOG_NOTICE,
X+ "info", LOG_INFO,
X+ "debug", LOG_DEBUG,
X+ NULL, -1,
X+ };
X+ #endif
X+
X main(argc, argv)
X int argc;
X char **argv;
X***************
X*** 184,193 ****
X struct sockaddr_in sin, frominet;
X FILE *fp;
X int ch;
X! char line[MSG_BSIZE + 1];
X extern int optind;
X extern char *optarg;
X void die(), domark(), init(), reapchild();
X
X while ((ch = getopt(argc, argv, "df:m:p:")) != EOF)
X switch((char)ch) {
X--- 282,298 ----
X struct sockaddr_in sin, frominet;
X FILE *fp;
X int ch;
X! #ifdef MSG_BSIZE
X! char line[max(MSG_BSIZE,BUFSIZ) + 1];
X! #else
X! char line[BUFSIZ + 1];
X! #endif
X extern int optind;
X extern char *optarg;
X void die(), domark(), init(), reapchild();
X+ #ifdef COMPAT42
X+ localhostaddr.s_addr = htonl(0x7f000001L); /* 127.0.0.1 */
X+ #endif
X
X while ((ch = getopt(argc, argv, "df:m:p:")) != EOF)
X switch((char)ch) {
X***************
X*** 212,219 ****
X
X if (!Debug)
X daemon(0, 0);
X! else
X! setlinebuf(stdout);
X
X consfile.f_type = F_CONSOLE;
X (void) strcpy(consfile.f_un.f_fname, ctty);
X--- 317,330 ----
X
X if (!Debug)
X daemon(0, 0);
X! else {
X! #ifndef macII
X! setlinebuf(stdout);
X! #else
X! static char buf[BUFSIZ];
X! setvbuf (stdout, buf, _IOLBF, BUFSIZ);
X! #endif
X! }
X
X consfile.f_type = F_CONSOLE;
X (void) strcpy(consfile.f_un.f_fname, ctty);
X***************
X*** 225,232 ****
X--- 336,354 ----
X else
X LocalDomain = "";
X (void) signal(SIGTERM, die);
X+ #ifdef ultrix
X+ /* compiler otherwise chokes on the ? : */
X+ if (Debug) {
X+ (void) signal(SIGINT, die);
X+ (void) signal(SIGQUIT, die);
X+ } else {
X+ (void) signal(SIGINT, SIG_IGN);
X+ (void) signal(SIGQUIT, SIG_IGN);
X+ }
X+ #else
X (void) signal(SIGINT, Debug ? die : SIG_IGN);
X (void) signal(SIGQUIT, Debug ? die : SIG_IGN);
X+ #endif
X (void) signal(SIGCHLD, reapchild);
X (void) signal(SIGALRM, domark);
X (void) alarm(TIMERINTVL);
X***************
X*** 237,243 ****
X (void) strncpy(sunx.sun_path, LogName, sizeof sunx.sun_path);
X funix = socket(AF_UNIX, SOCK_DGRAM, 0);
X if (funix < 0 || bind(funix, (struct sockaddr *) &sunx,
X! sizeof(sunx.sun_family)+sizeof(sunx.sun_len)+
X strlen(sunx.sun_path)) < 0 ||
X chmod(LogName, 0666) < 0) {
X (void) sprintf(line, "cannot create %s", LogName);
X--- 359,368 ----
X (void) strncpy(sunx.sun_path, LogName, sizeof sunx.sun_path);
X funix = socket(AF_UNIX, SOCK_DGRAM, 0);
X if (funix < 0 || bind(funix, (struct sockaddr *) &sunx,
X! sizeof(sunx.sun_family)+
X! #ifdef TAHOE_SOCKETS
X! sizeof(sunx.sun_len)+
X! #endif
X strlen(sunx.sun_path)) < 0 ||
X chmod(LogName, 0666) < 0) {
X (void) sprintf(line, "cannot create %s", LogName);
X***************
X*** 266,271 ****
X--- 391,400 ----
X InetInuse = 1;
X }
X }
X+ #ifdef NO_KLOG
X+ klogm = 0;
X+ fklog = 0;
X+ #else
X if ((fklog = open(_PATH_KLOG, O_RDONLY, 0)) >= 0)
X klogm = FDMASK(fklog);
X else {
X***************
X*** 272,277 ****
X--- 401,407 ----
X dprintf("can't open %s (%d)\n", _PATH_KLOG, errno);
X klogm = 0;
X }
X+ #endif
X
X /* tuck my process id away */
X fp = fopen(PidFile, "w");
X***************
X*** 282,287 ****
X--- 412,427 ----
X
X dprintf("off & running....\n");
X
X+ #ifdef ZEPHYR
X+ /* initialize zephyr stuff */
X+ bzero (&znotice, sizeof (znotice));
X+ znotice.z_kind = UNSAFE;
X+ znotice.z_class = "SYSLOG";
X+ znotice.z_class_inst = LocalHostName;
X+ znotice.z_default_format = "Syslog message from $instance, level $opcode:\n$message";
X+ (void) ZInitialize ();
X+ #endif
X+
X init();
X (void) signal(SIGHUP, init);
X
X***************
X*** 317,323 ****
X (struct sockaddr *) &fromunix, &len);
X if (i > 0) {
X line[i] = '\0';
X! printline(LocalHostName, line);
X } else if (i < 0 && errno != EINTR)
X logerror("recvfrom unix");
X }
X--- 457,463 ----
X (struct sockaddr *) &fromunix, &len);
X if (i > 0) {
X line[i] = '\0';
X! printline(LocalHostName, line, 0);
X } else if (i < 0 && errno != EINTR)
X logerror("recvfrom unix");
X }
X***************
X*** 329,335 ****
X extern char *cvthname();
X
X line[i] = '\0';
X! printline(cvthname(&frominet), line);
X } else if (i < 0 && errno != EINTR)
X logerror("recvfrom inet");
X }
X--- 469,483 ----
X extern char *cvthname();
X
X line[i] = '\0';
X! #ifdef COMPAT42
X! /* if it matches the localhost loopback,
X! this is an old client, so humor him. */
X! if (frominet.sin_addr.s_addr ==
X! localhostaddr.s_addr)
X! printline(cvthname(&frominet), line, 1);
X! else
X! #endif
X! printline(cvthname(&frominet), line, 0);
X } else if (i < 0 && errno != EINTR)
X logerror("recvfrom inet");
X }
X***************
X*** 343,356 ****
X exit(1);
X }
X
X /*
X * Take a raw input line, decode the message, and print the message
X * on the appropriate log files.
X */
X
X! printline(hname, msg)
X char *hname;
X char *msg;
X {
X register char *p, *q;
X register int c;
X--- 491,522 ----
X exit(1);
X }
X
X+ #ifdef COMPAT42
X+ int convert_oldpri[] = {
X+ LOG_COMPAT|LOG_EMERG, /* there is no 0 */
X+ LOG_COMPAT|LOG_ALERT, /* old LOG_ALERT */
X+ LOG_COMPAT|LOG_ALERT, /* old LOG_SALERT */
X+ LOG_COMPAT|LOG_CRIT, /* old LOG_EMERG */
X+ LOG_COMPAT|LOG_ERR, /* old LOG_ERROR */
X+ LOG_COMPAT|LOG_WARNING, /* old LOG_CRIT */
X+ LOG_COMPAT|LOG_WARNING, /* old LOG_WARNING */
X+ LOG_COMPAT|LOG_NOTICE, /* old LOG_NOTICE */
X+ LOG_COMPAT|LOG_INFO, /* old LOG_INFO */
X+ LOG_COMPAT|LOG_DEBUG, /* old LOG_DEBUG */
X+ };
X+ int noldpri = sizeof(convert_oldpri)/sizeof(convert_oldpri[0]);
X+ #endif
X+
X+
X /*
X * Take a raw input line, decode the message, and print the message
X * on the appropriate log files.
X */
X
X! printline(hname, msg, oldcompat)
X char *hname;
X char *msg;
X+ int oldcompat;
X {
X register char *p, *q;
X register int c;
X***************
X*** 367,372 ****
X--- 533,546 ----
X if (*p == '>')
X ++p;
X }
X+ #ifdef COMPAT42
X+ if (oldcompat) {
X+ if (pri > 0 && pri < noldpri)
X+ pri = convert_oldpri[pri];
X+ else
X+ pri = LOG_MAKEPRI(LOG_COMPAT, LOG_ERR);
X+ }
X+ #endif
X if (pri &~ (LOG_FACMASK|LOG_PRIMASK))
X pri = DEFUPRI;
X
X***************
X*** 435,440 ****
X--- 609,630 ----
X
X time_t now;
X
X+ #ifndef O_NOCTTY
X+ void
X+ untty()
X+ {
X+ int i;
X+
X+ if (!Debug) {
X+ i = open("/dev/tty", O_RDWR);
X+ if (i >= 0) {
X+ (void) ioctl(i, (int) TIOCNOTTY, (char *)0);
X+ (void) close(i);
X+ }
X+ }
X+ }
X+ #endif
X+
X /*
X * Log a message to the appropriate log files, users, etc. based on
X * the priority.
X***************
X*** 483,492 ****
X /* log the message to the particular outputs */
X if (!Initialized) {
X f = &consfile;
X f->f_file = open(ctty, O_WRONLY, 0);
X
X if (f->f_file >= 0) {
X! fprintlog(f, flags, msg);
X (void) close(f->f_file);
X }
X (void) sigsetmask(omask);
X--- 673,689 ----
X /* log the message to the particular outputs */
X if (!Initialized) {
X f = &consfile;
X+ #ifdef O_NOCTTY
X+ f->f_file = open(ctty, O_WRONLY|O_NOCTTY, 0);
X+ #else
X f->f_file = open(ctty, O_WRONLY, 0);
X+ #endif
X
X if (f->f_file >= 0) {
X! #ifndef O_NOCTTY
X! untty();
X! #endif
X! fprintlog(f, flags, msg, fac, prilev);
X (void) close(f->f_file);
X }
X (void) sigsetmask(omask);
X***************
X*** 523,535 ****
X * in the future.
X */
X if (now > REPEATTIME(f)) {
X! fprintlog(f, flags, (char *)NULL);
X BACKOFF(f);
X }
X } else {
X /* new line, save it */
X if (f->f_prevcount)
X! fprintlog(f, 0, (char *)NULL);
X f->f_repeatcount = 0;
X (void) strncpy(f->f_lasttime, timestamp, 15);
X (void) strncpy(f->f_prevhost, from,
X--- 720,732 ----
X * in the future.
X */
X if (now > REPEATTIME(f)) {
X! fprintlog(f, flags, (char *)NULL, fac, prilev);
X BACKOFF(f);
X }
X } else {
X /* new line, save it */
X if (f->f_prevcount)
X! fprintlog(f, 0, (char *)NULL, fac, prilev);
X f->f_repeatcount = 0;
X (void) strncpy(f->f_lasttime, timestamp, 15);
X (void) strncpy(f->f_prevhost, from,
X***************
X*** 537,548 ****
X if (msglen < MAXSVLINE) {
X f->f_prevlen = msglen;
X f->f_prevpri = pri;
X (void) strcpy(f->f_prevline, msg);
X! fprintlog(f, flags, (char *)NULL);
X } else {
X f->f_prevline[0] = 0;
X f->f_prevlen = 0;
X! fprintlog(f, flags, msg);
X }
X }
X }
X--- 734,746 ----
X if (msglen < MAXSVLINE) {
X f->f_prevlen = msglen;
X f->f_prevpri = pri;
X+ f->f_prevfac = fac;
X (void) strcpy(f->f_prevline, msg);
X! fprintlog(f, flags, (char *)NULL, fac, prilev);
X } else {
X f->f_prevline[0] = 0;
X f->f_prevlen = 0;
X! fprintlog(f, flags, msg, fac, prilev);
X }
X }
X }
X***************
X*** 549,570 ****
X (void) sigsetmask(omask);
X }
X
X! fprintlog(f, flags, msg)
X register struct filed *f;
X int flags;
X char *msg;
X {
X struct iovec iov[6];
X register struct iovec *v;
X register int l;
X char line[MAXLINE + 1], repbuf[80], greetings[200];
X
X v = iov;
X if (f->f_type == F_WALL) {
X v->iov_base = greetings;
X! v->iov_len = sprintf(greetings,
X "\r\n\7Message from syslogd@%s at %.24s ...\r\n",
X f->f_prevhost, ctime(&now));
X v++;
X v->iov_base = "";
X v->iov_len = 0;
X--- 747,776 ----
X (void) sigsetmask(omask);
X }
X
X! fprintlog(f, flags, msg, fac, prilev)
X register struct filed *f;
X int flags;
X char *msg;
X+ int fac;
X+ int prilev;
X {
X struct iovec iov[6];
X register struct iovec *v;
X register int l;
X char line[MAXLINE + 1], repbuf[80], greetings[200];
X+ #ifdef ZEPHYR
X+ char pri_fac_str[MAXLINE];
X+ int zcode;
X+ register int i;
X+ #endif
X
X v = iov;
X if (f->f_type == F_WALL) {
X v->iov_base = greetings;
X! (void) sprintf(greetings,
X "\r\n\7Message from syslogd@%s at %.24s ...\r\n",
X f->f_prevhost, ctime(&now));
X+ v->iov_len = strlen(greetings);
X v++;
X v->iov_base = "";
X v->iov_len = 0;
X***************
X*** 589,596 ****
X v->iov_len = strlen(msg);
X } else if (f->f_prevcount > 1) {
X v->iov_base = repbuf;
X! v->iov_len = sprintf(repbuf, "last message repeated %d times",
X f->f_prevcount);
X } else {
X v->iov_base = f->f_prevline;
X v->iov_len = f->f_prevlen;
X--- 795,803 ----
X v->iov_len = strlen(msg);
X } else if (f->f_prevcount > 1) {
X v->iov_base = repbuf;
X! (void) sprintf(repbuf, "last message repeated %d times",
X f->f_prevcount);
X+ v->iov_len = strlen(repbuf);
X } else {
X v->iov_base = f->f_prevline;
X v->iov_len = f->f_prevlen;
X***************
X*** 607,614 ****
X
X case F_FORW:
X dprintf(" %s\n", f->f_un.f_forw.f_hname);
X! l = sprintf(line, "<%d>%.15s %s", f->f_prevpri,
X iov[0].iov_base, iov[4].iov_base);
X if (l > MAXLINE)
X l = MAXLINE;
X if (sendto(finet, line, l, 0, &f->f_un.f_forw.f_addr,
X--- 814,822 ----
X
X case F_FORW:
X dprintf(" %s\n", f->f_un.f_forw.f_hname);
X! (void) sprintf(line, "<%d>%.15s %s", f->f_prevpri,
X iov[0].iov_base, iov[4].iov_base);
X+ l = strlen(line);
X if (l > MAXLINE)
X l = MAXLINE;
X if (sendto(finet, line, l, 0, &f->f_un.f_forw.f_addr,
X***************
X*** 662,667 ****
X--- 870,905 ----
X (void) fsync(f->f_file);
X break;
X
X+ #ifdef ZEPHYR
X+ case F_ZEPHYR:
X+ (void) sprintf(line, "%.15s [%s] %s",
X+ iov[0].iov_base,
X+ iov[2].iov_base,
X+ iov[4].iov_base);
X+ (void) sprintf(pri_fac_str, "%s.%s",
X+ FacNames[fac].c_name,
X+ PriNames[(prilev & LOG_PRIMASK)].c_name);
X+ znotice.z_message = line;
X+ /* include the null just in case */
X+ znotice.z_message_len = strlen (line) + 1;
X+ znotice.z_opcode = pri_fac_str;
X+ dprintf (" z_opcode %s\n", pri_fac_str);
X+ for (i = 0; i < MAXUNAMES; i++) {
X+ if (!f->f_un.f_uname[i][0])
X+ break;
X+ /* map "*" into null recipient and therefore
X+ anybody who is listening */
X+ if (strcmp (f->f_un.f_uname[i], "*") == 0)
X+ znotice.z_recipient = "";
X+ else
X+ znotice.z_recipient = f->f_un.f_uname[i];
X+ zcode = ZSendNotice (&znotice, ZNOAUTH);
X+ if (zcode != 0)
X+ logerror (error_message (zcode));
X+ }
X+ break;
X+ #endif
X+
X case F_USERS:
X case F_WALL:
X dprintf("\n");
X***************
X*** 752,757 ****
X--- 990,1000 ----
X dprintf("Malformed from address\n");
X return ("???");
X }
X+ #ifdef COMPAT42
X+ /* don't bother looking up 127.0.0.1, it's us. */
X+ if (f->sin_addr.s_addr == localhostaddr.s_addr)
X+ return(LocalHostName);
X+ #endif
X hp = gethostbyaddr(&f->sin_addr, sizeof(struct in_addr), f->sin_family);
X if (hp == 0) {
X dprintf("Host name for your address (%s) unknown\n",
X***************
X*** 781,787 ****
X dprintf("flush %s: repeated %d times, %d sec.\n",
X TypeNames[f->f_type], f->f_prevcount,
X repeatinterval[f->f_repeatcount]);
X! fprintlog(f, 0, (char *)NULL);
X BACKOFF(f);
X }
X }
X--- 1024,1030 ----
X dprintf("flush %s: repeated %d times, %d sec.\n",
X TypeNames[f->f_type], f->f_prevcount,
X repeatinterval[f->f_repeatcount]);
X! fprintlog(f, 0, (char *)NULL, f->f_prevfac, f->f_prevpri);
X BACKOFF(f);
X }
X }
X***************
X*** 814,820 ****
X for (f = Files; f != NULL; f = f->f_next) {
X /* flush any pending output */
X if (f->f_prevcount)
X! fprintlog(f, 0, (char *)NULL);
X }
X if (sig) {
X dprintf("syslogd: exiting on signal %d\n", sig);
X--- 1057,1063 ----
X for (f = Files; f != NULL; f = f->f_next) {
X /* flush any pending output */
X if (f->f_prevcount)
X! fprintlog(f, 0, (char *)NULL, f->f_prevfac, f->f_prevpri);
X }
X if (sig) {
X dprintf("syslogd: exiting on signal %d\n", sig);
X***************
X*** 848,860 ****
X for (f = Files; f != NULL; f = next) {
X /* flush any pending output */
X if (f->f_prevcount)
X! fprintlog(f, 0, (char *)NULL);
X
X switch (f->f_type) {
X case F_FILE:
X case F_TTY:
X case F_CONSOLE:
X- case F_FORW:
X (void) close(f->f_file);
X break;
X }
X--- 1091,1102 ----
X for (f = Files; f != NULL; f = next) {
X /* flush any pending output */
X if (f->f_prevcount)
X! fprintlog(f, 0, (char *)NULL, f->f_prevfac, f->f_prevpri);
X
X switch (f->f_type) {
X case F_FILE:
X case F_TTY:
X case F_CONSOLE:
X (void) close(f->f_file);
X break;
X }
X***************
X*** 920,925 ****
X--- 1162,1168 ----
X break;
X
X case F_USERS:
X+ case F_ZEPHYR:
X for (i = 0; i < MAXUNAMES && *f->f_un.f_uname[i]; i++)
X printf("%s, ", f->f_un.f_uname[i]);
X break;
X***************
X*** 1025,1031 ****
X hp = gethostbyname(p);
X if (hp == NULL) {
X extern int h_errno, h_nerr;
X! extern char **h_errlist;
X
X logerror((u_int)h_errno < h_nerr ?
X h_errlist[h_errno] : "Unknown error");
X--- 1268,1274 ----
X hp = gethostbyname(p);
X if (hp == NULL) {
X extern int h_errno, h_nerr;
X! extern char *h_errlist[];
X
X logerror((u_int)h_errno < h_nerr ?
X h_errlist[h_errno] : "Unknown error");
X***************
X*** 1041,1064 ****
X
X case '/':
X (void) strcpy(f->f_un.f_fname, p);
X! if ((f->f_file = open(p, O_WRONLY|O_APPEND, 0)) < 0) {
X f->f_file = F_UNUSED;
X logerror(p);
X break;
X }
X! if (isatty(f->f_file))
X f->f_type = F_TTY;
X! else
X f->f_type = F_FILE;
X if (strcmp(p, ctty) == 0)
X f->f_type = F_CONSOLE;
X break;
X
X case '*':
X f->f_type = F_WALL;
X break;
X!
X! default:
X for (i = 0; i < MAXUNAMES && *p; i++) {
X for (q = p; *q && *q != ','; )
X q++;
X--- 1284,1322 ----
X
X case '/':
X (void) strcpy(f->f_un.f_fname, p);
X! #ifdef O_NOCTTY
X! #define FLAGS O_WRONLY|O_APPEND|O_NOCTTY
X! #else
X! #define FLAGS O_WRONLY|O_APPEND
X! #endif
X! if ((f->f_file = open(p, FLAGS, 0)) < 0) {
X! #undef FLAGS
X f->f_file = F_UNUSED;
X logerror(p);
X break;
X }
X! if (isatty(f->f_file)) {
X f->f_type = F_TTY;
X! #ifndef O_NOCTTY
X! untty();
X! #endif
X! } else
X f->f_type = F_FILE;
X if (strcmp(p, ctty) == 0)
X f->f_type = F_CONSOLE;
X break;
X
X+ #ifndef ZEPHYR
X case '*':
X f->f_type = F_WALL;
X break;
X! #else
X! case '!':
X! p++;
X! if (*p == '*') {
X! f->f_type = F_WALL;
X! break;
X! }
X for (i = 0; i < MAXUNAMES && *p; i++) {
X for (q = p; *q && *q != ','; )
X q++;
X***************
X*** 1072,1077 ****
X--- 1330,1356 ----
X p = q;
X }
X f->f_type = F_USERS;
X+ break;
X+ #endif
X+
X+ default:
X+ for (i = 0; i < MAXUNAMES && *p; i++) {
X+ for (q = p; *q && *q != ','; )
X+ q++;
X+ (void) strncpy(f->f_un.f_uname[i], p, UNAMESIZE);
X+ if ((q - p) > UNAMESIZE)
X+ f->f_un.f_uname[i][UNAMESIZE] = '\0';
X+ else
X+ f->f_un.f_uname[i][q - p] = '\0';
X+ while (*q == ',' || *q == ' ')
X+ q++;
X+ p = q;
X+ }
X+ #ifdef ZEPHYR
X+ f->f_type = F_ZEPHYR;
X+ #else
X+ f->f_type = F_USERS;
X+ #endif
X break;
X }
X }
X*** pristine-syslog.h Thu Jan 31 12:18:55 1991
X--- syslog.h Thu Jan 31 13:26:30 1991
X***************
X*** 17,23 ****
X * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
X * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X *
X! * @(#)syslog.h 7.16 (Berkeley) 6/28/90
X */
X
X /*
X--- 17,23 ----
X * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
X * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X *
X! * @(#)syslog.h 7.16 (Berkeley) 6/28/90, with COMPAT42 mods
X */
X
X /*
X***************
X*** 80,85 ****
X--- 80,86 ----
X #define LOG_NEWS (7<<3) /* network news subsystem */
X #define LOG_UUCP (8<<3) /* UUCP subsystem */
X #define LOG_CRON (9<<3) /* clock daemon */
X+ #define LOG_COMPAT (15<<3) /* compatibility with 4.2 syslog */
X /* other codes through 15 reserved for system use */
X #define LOG_LOCAL0 (16<<3) /* reserved for local use */
X #define LOG_LOCAL1 (17<<3) /* reserved for local use */
X***************
X*** 98,103 ****
X--- 99,105 ----
X #ifdef SYSLOG_NAMES
X CODE facilitynames[] = {
X "auth", LOG_AUTH,
X+ "compat", LOG_COMPAT,
X "cron", LOG_CRON,
X "daemon", LOG_DAEMON,
X "kern", LOG_KERN,
X*** pristine-pathnames.h Thu Jan 31 13:20:23 1991
X--- pathnames.h Thu Jan 31 13:21:00 1991
X***************
X*** 16,22 ****
X * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
X * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X *
X! * @(#)pathnames.h 5.3 (Berkeley) 6/1/90
X */
X
X #include <paths.h>
X--- 16,22 ----
X * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
X * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X *
X! * @(#)pathnames.h 5.3 (Berkeley) 6/1/90, with COMPAT42 mods
X */
X
X #include <paths.h>
X***************
X*** 23,27 ****
X--- 23,32 ----
X
X #define _PATH_KLOG "/dev/klog"
X #define _PATH_LOG "/dev/log"
X+ #ifdef COMPAT42
X+ #define _PATH_LOGCONF "/etc/nsyslog.conf"
X+ #define _PATH_LOGPID "/etc/nsyslog.pid"
X+ #else
X #define _PATH_LOGCONF "/etc/syslog.conf"
X #define _PATH_LOGPID "/var/run/syslog.pid"
X+ #endif
X*** pristine-syslog.c Thu Jan 31 13:49:38 1991
X--- syslog.c Thu Jan 31 13:56:42 1991
X***************
X*** 18,24 ****
X */
X
X #if defined(LIBC_SCCS) && !defined(lint)
X! static char sccsid[] = "@(#)syslog.c 5.28 (Berkeley) 6/27/90";
X #endif /* LIBC_SCCS and not lint */
X
X /*
X--- 18,24 ----
X */
X
X #if defined(LIBC_SCCS) && !defined(lint)
X! static char sccsid[] = "@(#)syslog.c 5.28 (Berkeley) 6/27/90, with varags changes";
X #endif /* LIBC_SCCS and not lint */
X
X /*
X***************
X*** 37,42 ****
X--- 37,48 ----
X * Modified to use UNIX domain IPC by Ralph Campbell
X */
X
X+ #ifdef __STDC__
X+ #include <stdarg.h>
X+ #else
X+ #include <varargs.h>
X+ #endif
X+
X #include <sys/types.h>
X #include <sys/socket.h>
X #include <sys/file.h>
X***************
X*** 46,52 ****
X #include <sys/wait.h>
X #include <netdb.h>
X #include <string.h>
X- #include <varargs.h>
X #include <paths.h>
X #include <stdio.h>
X
X--- 52,57 ----
X***************
X*** 58,68 ****
X static char *LogTag = "syslog"; /* string to tag the entry with */
X static int LogFacility = LOG_USER; /* default facility code */
X
X! syslog(pri, fmt, args)
X! int pri, args;
X! char *fmt;
X {
X! vsyslog(pri, fmt, &args);
X }
X
X vsyslog(pri, fmt, ap)
X--- 63,85 ----
X static char *LogTag = "syslog"; /* string to tag the entry with */
X static int LogFacility = LOG_USER; /* default facility code */
X
X! #ifdef __STDC__
X! syslog(int pri, const char *fmt, ...)
X! #else
X! syslog(pri, fmt, va_alist)
X! int pri;
X! char *fmt;
X! va_dcl
X! #endif
X {
X! va_list pvar;
X! #ifdef __STDC__
X! va_start(pvar, fmt);
X! #else
X! va_start(pvar);
X! #endif
X! vsyslog(pri, fmt, pvar);
X! va_end(pvar);
X }
X
X vsyslog(pri, fmt, ap)
X***************
X*** 149,156 ****
X--- 166,178 ----
X * output the message to the console; don't worry about
X * blocking, if console blocks everything will.
X */
X+ #ifdef O_NOCTTY
X+ if ((fd = open(_PATH_CONSOLE, O_NOCTTY|O_WRONLY, 0)) < 0)
X+ return;
X+ #else
X if ((fd = open(_PATH_CONSOLE, O_WRONLY, 0)) < 0)
X return;
X+ #endif
X (void)strcat(tbuf, "\r\n");
X cnt += 2;
X p = index(tbuf, '>') + 1;
END_OF_FILE
if test 26306 -ne `wc -c <'ultrix.syslogd.patches'`; then
echo shar: \"'ultrix.syslogd.patches'\" unpacked with wrong size!
fi
# end of 'ultrix.syslogd.patches'
fi
if test -f 'nsyslog.conf' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'nsyslog.conf'\"
else
echo shar: Extracting \"'nsyslog.conf'\" \(299 characters\)
sed "s/^X//" >'nsyslog.conf' <<'END_OF_FILE'
X# Syslog daemon configuration file
X#
X# WARNING: Due to a bug in syslogd, the *.level messages must appear
X# first on the line.
X#
X*.panic !*
X*.alert;auth.notice /dev/console
X*.warning;kern.debug /usr/adm/messages
Xauth.notice /usr/adm/sulog
Xmail.info;compat.info /usr/spool/mqueue/syslog
END_OF_FILE
if test 299 -ne `wc -c <'nsyslog.conf'`; then
echo shar: \"'nsyslog.conf'\" unpacked with wrong size!
fi
# end of 'nsyslog.conf'
fi
echo shar: End of shell archive.
exit 0
--
John Kohl <jtkohl at ATHENA.MIT.EDU> or <jtkohl at MIT.EDU>
Digital Equipment Corporation/Project Athena
(The above opinions are MINE. Don't put my words in somebody else's mouth!)
More information about the Alt.sources
mailing list