summaryrefslogtreecommitdiff
path: root/clients/syslogd
diff options
context:
space:
mode:
Diffstat (limited to 'clients/syslogd')
-rw-r--r--clients/syslogd/Imakefile28
-rw-r--r--clients/syslogd/Makefile.in47
-rw-r--r--clients/syslogd/syslog.3184
-rw-r--r--clients/syslogd/syslog.c206
-rw-r--r--clients/syslogd/syslog.conf20
-rw-r--r--clients/syslogd/syslog.h5
-rw-r--r--clients/syslogd/syslogd.c433
7 files changed, 271 insertions, 652 deletions
diff --git a/clients/syslogd/Imakefile b/clients/syslogd/Imakefile
deleted file mode 100644
index 7700960..0000000
--- a/clients/syslogd/Imakefile
+++ /dev/null
@@ -1,28 +0,0 @@
-/**/# Copyright 1988 Massachusetts Institute of Technology.
-/**/#
-/**/# For copying and distribution information, see the file
-/**/# "mit-copyright.h".
-/**/#
-/**/# $Source$
-/**/# $Author$
-/**/# $Id$
-/**/#
-
-#ifdef _AIX
-MACHLIBS= -lsrc
-#endif
-
-SRCS = syslogd.c logger.c syslog.c
-
-DOBJS = syslogd.o
-LOBJS= logger.o syslog.o
-
-#ifdef SYSLOG_COMPAT42
-COMPAT = -DCOMPAT42
-SimpleProgram(logger,$(LOBJS),,$(ATHETCDIR))
-#endif
-
-XDEFS = -I. $(COMPAT)
-
-SimpleProgram(syslogd,$(DOBJS) $(ZLIB),$(ZLIBS) $(MACHLIBS),$(ATHRETCDIR))
-install_man(syslogd.8,syslogd.8)
diff --git a/clients/syslogd/Makefile.in b/clients/syslogd/Makefile.in
new file mode 100644
index 0000000..15c64da
--- /dev/null
+++ b/clients/syslogd/Makefile.in
@@ -0,0 +1,47 @@
+SHELL = /bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+datadir=@datadir@
+confdir=@confdir@
+sbindir=@sbindir@
+lsbindir=@lsbindir@
+
+includedir=${prefix}/include
+mandir=${prefix}/man
+libdir=${exec_prefix}/lib
+bindir=${exec_prefix}/bin
+
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+BUILDTOP=../..
+VPATH=@srcdir@
+CC=@CC@
+INSTALL=@INSTALL@
+
+DEBUG=-O
+CFLAGS=${DEBUG} -I${srcdir} -I${top_srcdir}/h -I${BUILDTOP}/h @CPPFLAGS@
+LDFLAGS=${DEBUG} -L${BUILDTOP}/lib/zephyr @ET_LDFLAGS@ @LDFLAGS@
+LIBS=-lzephyr @LIBS@ -lcom_err @SLIB@
+
+OBJS= syslogd.o
+
+all: syslogd
+
+syslogd: ${OBJS} ${BUILDTOP}/lib/zephyr/libzephyr.a @ETDEP@
+ ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
+
+check:
+
+install: syslogd
+ ${INSTALL} -m 755 -s syslogd ${DESTDIR}${sbindir}
+ ${INSTALL} -m 644 ${srcdir}/syslogd.8 ${DESTDIR}${mandir}/man8
+
+clean:
+ rm -f ${OBJS} syslogd
+
+${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h
+${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h
+
+.PHONY: all check install clean
+
diff --git a/clients/syslogd/syslog.3 b/clients/syslogd/syslog.3
deleted file mode 100644
index 8acef78..0000000
--- a/clients/syslogd/syslog.3
+++ /dev/null
@@ -1,184 +0,0 @@
-.\" Copyright (c) 1983 Regents of the University of California.
-.\" All rights reserved. The Berkeley software License Agreement
-.\" specifies the terms and conditions for redistribution.
-.\"
-.\" @(#)syslog.3 6.6 (Berkeley) 5/15/86
-.\"
-.TH SYSLOG 3 "May 15, 1986"
-.UC 5
-.SH NAME
-syslog, openlog, closelog, setlogmask \- control system log
-.SH SYNOPSIS
-.B "#include <syslog.h>
-.PP
-.B "openlog(ident, logopt, facility)
-.br
-.B "char *ident;
-.PP
-.B "syslog(priority, message, parameters ... )
-.br
-.B "char *message;
-.PP
-.B "closelog()
-.PP
-.B "setlogmask(maskpri)
-.SH DESCRIPTION
-.I Syslog
-arranges to write
-.I message
-onto the system log maintained by
-.IR syslogd (8).
-The message is tagged with
-.IR priority .
-The message looks like a
-.IR printf (3)
-string except that
-.B %m
-is replaced by the current error message (collected from
-.IR errno ).
-A trailing newline is added if needed.
-This message will be read by
-.IR syslogd (8)
-and written to the system console, log files, or forwarded to
-.I syslogd
-on another host as appropriate.
-.PP
-Priorities are encoded as a
-.I facility
-and a
-.IR level .
-The facility describes the part of the system
-generating the message.
-The level is selected from an ordered list:
-.IP LOG_EMERG \w'LOG_WARNING'u+3
-A panic condition.
-This is normally broadcast to all users.
-.IP LOG_ALERT \w'LOG_WARNING'u+3
-A condition that should be corrected immediately,
-such as a corrupted system database.
-.IP LOG_CRIT \w'LOG_WARNING'u+3
-Critical conditions,
-e.g., hard device errors.
-.IP LOG_ERR \w'LOG_WARNING'u+3
-Errors.
-.IP LOG_WARNING \w'LOG_WARNING'u+3
-Warning messages.
-.IP LOG_NOTICE \w'LOG_WARNING'u+3
-Conditions that are not error conditions,
-but should possibly be handled specially.
-.IP LOG_INFO \w'LOG_WARNING'u+3
-Informational messages.
-.IP LOG_DEBUG \w'LOG_WARNING'u+3
-Messages that contain information
-normally of use only when debugging a program.
-.PP
-If
-.I syslog
-cannot pass the message to
-.IR syslogd ,
-it will attempt to write the message on
-.I /dev/console
-if the LOG_CONS option is set (see below).
-.PP
-If special processing is needed,
-.I openlog
-can be called to initialize the log file.
-The parameter
-.I ident
-is a string that is prepended to every message.
-.I Logopt
-is a bit field indicating logging options.
-Current values for
-.I logopt
-are:
-.IP LOG_PID \w'LOG_WARNING'u+3
-log the process id with each message:
-useful for identifying instantiations of daemons.
-.IP LOG_CONS \w'LOG_WARNING'u+3
-Force writing messages to the console if unable to send it to
-.I syslogd.
-This option is safe to use in daemon processes that have no controlling
-terminal since
-.I syslog
-will fork before opening the console.
-.IP LOG_NDELAY \w'LOG_WARNING'u+3
-Open the connection to
-.I syslogd
-immediately.
-Normally the open is delayed
-until the first message is logged.
-Useful for programs that need to manage the
-order in which file descriptors are allocated.
-.IP LOG_NOWAIT \w'LOG_WARNING'u+3
-Don't wait for children forked to log messages on the console.
-This option should be used by processes that enable notification
-of child termination via SIGCHLD, as
-.I syslog
-may otherwise block waiting for a child whose exit status has already
-been collected.
-.PP
-The
-.I facility
-parameter encodes a default facility to be assigned to all messages
-that do not have an explicit facility encoded:
-.IP LOG_KERN \w'LOG_WARNING'u+3
-Messages generated by the kernel.
-These cannot be generated by any user processes.
-.IP LOG_USER \w'LOG_WARNING'u+3
-Messages generated by random user processes.
-This is the default facility identifier if none is specified.
-.IP LOG_MAIL \w'LOG_WARNING'u+3
-The mail system.
-.IP LOG_DAEMON \w'LOG_WARNING'u+3
-System daemons, such as
-.IR ftpd (8),
-.IR routed (8),
-etc.
-.IP LOG_AUTH \w'LOG_WARNING'u+3
-The authorization system:
-.IR login (1),
-.IR su (1),
-.IR getty (8),
-etc.
-.IP LOG_LPR \w'LOG_WARNING'u+3
-The line printer spooling system:
-.IR lpr (1),
-.IR lpc (8),
-.IR lpd (8),
-etc.
-.IP LOG_LOCAL0 \w'LOG_WARNING'u+3
-Reserved for local use.
-Similarly for LOG_LOCAL1 through LOG_LOCAL7.
-.PP
-.I Closelog
-can be used to close the log file.
-.PP
-.I Setlogmask
-sets the log priority mask to
-.I maskpri
-and returns the previous mask.
-Calls to
-.I syslog
-with a priority not set in
-.I maskpri
-are rejected.
-The mask for an individual priority
-.I pri
-is calculated by the macro LOG_MASK(\fIpri\fP);
-the mask for all priorities up to and including
-.I toppri
-is given by the macro LOG_UPTO(\fItoppri\fP).
-The default allows all priorities to be logged.
-.SH EXAMPLES
-.nf
-syslog(LOG_ALERT, "who: internal error 23");
-
-openlog("ftpd", LOG_PID, LOG_DAEMON);
-setlogmask(LOG_UPTO(LOG_ERR));
-syslog(LOG_INFO, "Connection from host %d", CallingHost);
-
-syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m");
-.fi
-.SH "SEE ALSO"
-logger(1),
-syslogd(8)
diff --git a/clients/syslogd/syslog.c b/clients/syslogd/syslog.c
deleted file mode 100644
index 378c987..0000000
--- a/clients/syslogd/syslog.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 1983, 1988 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of California at Berkeley. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)syslog.c 5.14 (Berkeley) 5/20/88";
-#endif /* LIBC_SCCS and not lint */
-
-
-/*
- * SYSLOG -- print message on log file
- *
- * This routine looks a lot like printf, except that it
- * outputs to the log file instead of the standard output.
- * Also:
- * adds a timestamp,
- * prints the module name in front of the message,
- * has some other formatting types (or will sometime),
- * adds a newline on the end of the message.
- *
- * The output of this routine is intended to be read by /etc/syslogd.
- *
- * Author: Eric Allman
- * Modified to use UNIX domain IPC by Ralph Campbell
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/file.h>
-#include <sys/signal.h>
-#include <syslog.h>
-#include <netdb.h>
-#include <string.h>
-
-#define MAXLINE 1024 /* max message size */
-#define NULL 0 /* manifest */
-
-#define PRIFAC(p) (((p) & LOG_FACMASK) >> 3)
- /* XXX should be in <syslog.h> */
-#define IMPORTANT LOG_ERR
-
-static char logname[] = "/dev/log";
-static char ctty[] = "/dev/console";
-
-static int LogFile = -1; /* fd for log */
-static int LogStat = 0; /* status bits, set by openlog() */
-static char *LogTag = "syslog"; /* string to tag the entry with */
-static int LogMask = 0xff; /* mask of priorities to be logged */
-static int LogFacility = LOG_USER; /* default facility code */
-
-static struct sockaddr SyslogAddr; /* AF_UNIX address of local logger */
-
-extern int errno, sys_nerr;
-extern char *sys_errlist[];
-
-syslog(pri, fmt, p0, p1, p2, p3, p4)
- int pri;
- char *fmt;
-{
- char buf[MAXLINE + 1], outline[MAXLINE + 1];
- register char *b, *f, *o;
- register int c;
- long now;
- int pid, olderrno = errno;
-
- /* see if we should just throw out this message */
- if ((unsigned) PRIFAC(pri) >= LOG_NFACILITIES ||
- (LOG_MASK(pri & LOG_PRIMASK) & LogMask) == 0 ||
- (pri &~ (LOG_PRIMASK|LOG_FACMASK)) != 0)
- return;
- if (LogFile < 0)
- openlog(LogTag, LogStat | LOG_NDELAY, 0);
-
- /* set default facility if none specified */
- if ((pri & LOG_FACMASK) == 0)
- pri |= LogFacility;
-
- /* build the message */
- o = outline;
- (void)sprintf(o, "<%d>", pri);
- o += strlen(o);
- time(&now);
- (void)sprintf(o, "%.15s ", ctime(&now) + 4);
- o += strlen(o);
- if (LogTag) {
- strcpy(o, LogTag);
- o += strlen(o);
- }
- if (LogStat & LOG_PID) {
- (void)sprintf(o, "[%d]", getpid());
- o += strlen(o);
- }
- if (LogTag) {
- strcpy(o, ": ");
- o += 2;
- }
-
- b = buf;
- f = fmt;
- while ((c = *f++) != '\0' && c != '\n' && b < &buf[MAXLINE]) {
- if (c != '%') {
- *b++ = c;
- continue;
- }
- if ((c = *f++) != 'm') {
- *b++ = '%';
- *b++ = c;
- continue;
- }
- if ((unsigned)olderrno > sys_nerr)
- (void)sprintf(b, "error %d", olderrno);
- else
- strcpy(b, sys_errlist[olderrno]);
- b += strlen(b);
- }
- *b++ = '\n';
- *b = '\0';
- (void)sprintf(o, buf, p0, p1, p2, p3, p4);
- c = strlen(outline);
- if (c > MAXLINE)
- c = MAXLINE;
-
- /* output the message to the local logger */
- if (sendto(LogFile, outline, c, 0, &SyslogAddr, sizeof SyslogAddr) >= 0)
- return;
- if (!(LogStat & LOG_CONS))
- return;
-
- /* output the message to the console */
- pid = vfork();
- if (pid == -1)
- return;
- if (pid == 0) {
- int fd;
-
- signal(SIGALRM, SIG_DFL);
- sigsetmask(sigblock(0L) & ~sigmask(SIGALRM));
- alarm(5);
- fd = open(ctty, O_WRONLY);
- alarm(0);
- strcat(o, "\r");
- o = index(outline, '>') + 1;
- write(fd, o, c + 1 - (o - outline));
- close(fd);
- _exit(0);
- }
- if (!(LogStat & LOG_NOWAIT))
- while ((c = wait((int *)0)) > 0 && c != pid)
- ;
-}
-
-/*
- * OPENLOG -- open system log
- */
-
-openlog(ident, logstat, logfac)
- char *ident;
- int logstat, logfac;
-{
- if (ident != NULL)
- LogTag = ident;
- LogStat = logstat;
- if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0)
- LogFacility = logfac;
- if (LogFile >= 0)
- return;
- SyslogAddr.sa_family = AF_UNIX;
- strncpy(SyslogAddr.sa_data, logname, sizeof SyslogAddr.sa_data);
- if (LogStat & LOG_NDELAY) {
- LogFile = socket(AF_UNIX, SOCK_DGRAM, 0);
- fcntl(LogFile, F_SETFD, 1);
- }
-}
-
-/*
- * CLOSELOG -- close the system log
- */
-
-closelog()
-{
-
- (void) close(LogFile);
- LogFile = -1;
-}
-
-/*
- * SETLOGMASK -- set the log mask level
- */
-setlogmask(pmask)
- int pmask;
-{
- int omask;
-
- omask = LogMask;
- if (pmask != 0)
- LogMask = pmask;
- return (omask);
-}
diff --git a/clients/syslogd/syslog.conf b/clients/syslogd/syslog.conf
deleted file mode 100644
index 52dc6b1..0000000
--- a/clients/syslogd/syslog.conf
+++ /dev/null
@@ -1,20 +0,0 @@
-# Syslog daemon configuration file
-#
-# $Header$
-# $Source$
-# $Author$
-#
-*.alert;kern.debug;auth.notice /dev/console
-*.alert;kern.debug;auth.notice jon
-*.notice;kern.debug /site/usr/adm/messages
-*.notice;kern.debug jon
-mail.info /site/usr/spool/mqueue/syslog
-mail.info jon
-local0.info jon
-# local0 is for rshd
-local1.info /site/usr/adm/sulog
-local1.info jon
-#local1 is for su
-*.panic !*
-local2.debug jon
-
diff --git a/clients/syslogd/syslog.h b/clients/syslogd/syslog.h
index 139742c..eee7ec0 100644
--- a/clients/syslogd/syslog.h
+++ b/clients/syslogd/syslog.h
@@ -19,6 +19,9 @@
#define LOG_LPR (6<<3) /* line printer subsystem */
#define LOG_NEWS (7<<3) /* network news subsystem */
#define LOG_UUCP (8<<3) /* UUCP subsystem */
+#define LOG_CRON (9<<3) /* clock daemon */
+#define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */
+#define LOG_FTP (11<<3) /* ftp daemon */
/* 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 */
@@ -47,7 +50,7 @@
#define LOG_INFO 6 /* informational */
#define LOG_DEBUG 7 /* debug-level messages */
-#define LOG_PRIMASK 0x0007 /* mask to extract priority part (internal) */
+#define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */
#define LOG_PRI(p) ((p) & LOG_PRIMASK) /* extract priority */
#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
diff --git a/clients/syslogd/syslogd.c b/clients/syslogd/syslogd.c
index 7a86006..5886fe8 100644
--- a/clients/syslogd/syslogd.c
+++ b/clients/syslogd/syslogd.c
@@ -45,6 +45,8 @@ static char sccsid[] = "@(#)syslogd.c 5.24 (Berkeley) 6/18/88";
* more extensive changes by Eric Allman (again)
* changes for Zephyr and a little dynamic allocation
* by Jon Rochlis (MIT), July 1987
+ * fixes, dynamic allocation, autoconf changes by Greg Hudson (MIT), 1995
+ * Solaris support by John Hawkinson (MIT), 1995
*/
#define MAXLINE 1024 /* maximum line length */
@@ -53,85 +55,51 @@ static char sccsid[] = "@(#)syslogd.c 5.24 (Berkeley) 6/18/88";
#define DEFSPRI (LOG_KERN|LOG_CRIT)
#define TIMERINTVL 30 /* interval for checking flush, mark */
-#ifdef SOLARIS
-#define MSG_BSIZE BUFSIZ
+#if defined(__sun__) && defined(__svr4__)
#define STREAMS_LOG_DRIVER
#endif
+#ifdef STREAMS_LOG_DRIVER
+#undef COMPAT42
+#endif
-#include <stdio.h>
-#include <sys/types.h>
-#include <time.h>
-#ifdef _IBMR2
-#include <sys/select.h>
+#include <sysdep.h>
+#ifdef HAVE_SRC
#include <spc.h> /* For support of the SRC system */
#endif
#include <utmp.h>
-#include <ctype.h>
-#include <string.h>
#include <setjmp.h>
-#include <fcntl.h>
-#include <syslog.h>
-#include <sys/param.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
#include <sys/socket.h>
-#include <sys/file.h>
-#ifndef COMPAT42
-#include <sys/msgbuf.h>
-#endif
-#include <sys/uio.h>
#include <sys/un.h>
-#include <sys/time.h>
#include <sys/resource.h>
-#include <sys/signal.h>
+#include <sys/uio.h>
#include <netdb.h>
-
#ifdef STREAMS_LOG_DRIVER
#include <sys/stream.h>
#include <sys/strlog.h>
#include <sys/log.h>
-
#include <poll.h>
#include <stropts.h>
#endif
-#ifdef POSIX
-#include <termios.h>
-#endif
-
#include <zephyr/zephyr.h>
+#include <com_err.h>
-extern int sys_nerr;
-#ifdef SUNOS
-extern char *sys_errlist[];
-#define strerror(n) sys_errlist[n]
-#endif
-
-#if defined(ultrix) || defined(POSIX)
-#define sighandler_type void
+#ifdef _PATH_VARRUN
+#define PIDDIR _PATH_VARRUN
#else
-#define sighandler_type int
+#define PIDDIR "/etc/"
#endif
#define CTTY "/dev/console"
char *LogName = "/dev/log";
-#ifdef COMPAT42
-char *ConfFile = "/etc/nsyslog.conf";
-char *PidFile = "/etc/nsyslog.pid";
-#else /* !COMPAT42 */
-char *ConfFile = "/etc/syslog.conf";
-char *PidFile = "/etc/syslog.pid";
-#endif /* COMPAT42 */
+char ConfFile[128];
+char PidFile[128];
char ctty[] = CTTY;
#define FDMASK(fd) (1 << (fd))
#define dprintf if (Debug) printf
-#define UNAMESZ ANAME_SZ+INST_SZ+REALM_SZ /* 8 isn't good enough anymore */
-#define UTMPNAMESZ 8
#define MAXUNAMES 20 /* maximum number of user names */
#define MAXFNAME 200 /* max file pathname length */
@@ -159,7 +127,7 @@ struct filed {
time_t f_time; /* time this was last written */
u_char f_pmask[LOG_NFACILITIES+1]; /* priority mask */
union {
- char f_uname[MAXUNAMES][UNAMESZ+1];
+ char *f_uname[MAXUNAMES];
struct {
char f_hname[MAXHOSTNAMELEN+1];
struct sockaddr_in f_addr;
@@ -215,6 +183,7 @@ int LogPort; /* port number for INET connections */
int Initialized = 0; /* set when we have initialized ourselves */
int MarkInterval = 20 * 60; /* interval between marks in seconds */
int MarkSeq = 0; /* mark sequence number */
+time_t now;
ZNotice_t znotice; /* for zephyr notices */
@@ -228,73 +197,95 @@ struct code {
};
struct code PriNames[] = {
- "panic", LOG_EMERG,
- "alert", LOG_ALERT,
- "crit", LOG_CRIT,
- "error", LOG_ERR,
- "warning", LOG_WARNING,
- "notice", LOG_NOTICE,
- "info", LOG_INFO,
- "debug", LOG_DEBUG,
- "none", NOPRI,
- "emerg", LOG_EMERG,
- "err", LOG_ERR,
- "warn", LOG_WARNING,
- NULL, -1
+ { "panic", LOG_EMERG },
+ { "alert", LOG_ALERT },
+ { "crit", LOG_CRIT },
+ { "error", LOG_ERR },
+ { "warning", LOG_WARNING },
+ { "notice", LOG_NOTICE },
+ { "info", LOG_INFO },
+ { "debug", LOG_DEBUG },
+ { "none", NOPRI },
+ { "emerg", LOG_EMERG },
+ { "err", LOG_ERR },
+ { "warn", LOG_WARNING },
+ { NULL, -1 }
};
/* reserved added so zephyr can use this table */
struct 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,
- "reserved", -1,
- "reserved", -1,
- "reserved", -1,
- "reserved", -1,
- "reserved", -1,
- "reserved", -1,
- "reserved", -1,
- "local0", LOG_LOCAL0,
- "local1", LOG_LOCAL1,
- "local2", LOG_LOCAL2,
- "local3", LOG_LOCAL3,
- "local4", LOG_LOCAL4,
- "local5", LOG_LOCAL5,
- "local6", LOG_LOCAL6,
- "local7", LOG_LOCAL7,
- "security", LOG_AUTH,
- "mark", LOG_MARK,
- NULL, -1
+ { "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 },
+ { "authpriv", LOG_AUTHPRIV },
+ { "ftp", LOG_FTP },
+ { "reserved", -1 },
+ { "reserved", -1 },
+ { "reserved", -1 },
+ { "cron", LOG_CRON },
+ { "local0", LOG_LOCAL0 },
+ { "local1", LOG_LOCAL1 },
+ { "local2", LOG_LOCAL2 },
+ { "local3", LOG_LOCAL3 },
+ { "local4", LOG_LOCAL4 },
+ { "local5", LOG_LOCAL5 },
+ { "local6", LOG_LOCAL6 },
+ { "local7", LOG_LOCAL7 },
+ { "security", LOG_AUTH },
+ { "mark", LOG_MARK },
+ { NULL, -1 }
};
-static sighandler_type
- die(),
- domark(),
- reapchild(),
- init(),
- endtty();
+static void usage __P((void));
+static void untty __P((void));
+static void printline __P((const char *hname, char *msg));
+#ifndef STREAMS_LOG_DRIVER
+static void printsys __P((char *msg));
+#endif
+static void logmsg __P((int pri, const char *msg, const char *from,
+ int flags));
+static void fprintlog __P((register struct filed *f, int flags,
+ const char *msg, int fac, int prilev));
+static RETSIGTYPE endtty __P((int sig));
+static void wallmsg __P((register struct filed *f, struct iovec *iov));
+static RETSIGTYPE reapchild __P((int sig));
+static const char *cvthname __P((struct sockaddr_in *f));
+static RETSIGTYPE domark __P((int sig));
+static void logerror __P((const char *type));
+static RETSIGTYPE die __P((int sig));
+static RETSIGTYPE init __P((int sig));
+static void cfline __P((char *line, register struct filed *f));
+static int decode __P((char *name, struct code *codetab));
+#ifdef HAVE_SRC
+static void handle_src __P((struct srcreq packet));
+static void send_src_reply __P((struct srcreq orig_packet, int rtncode,
+ char *packet, int len));
+#endif
-main(argc, argv)
+int main(argc, argv)
int argc;
char **argv;
{
register int i;
register char *p;
- int funix, inetm = 0, fklog, klogm, len;
+ int funix, inetm = 0, klogm, len;
+#ifndef STREAMS_LOG_DRIVER
struct sockaddr_un sunx, fromunix;
+ int fklog;
+#endif
struct sockaddr_in sin, frominet;
FILE *fp;
-#ifdef POSIX
+#ifdef _POSIX_VERSION
struct sigaction action;
#endif
-#ifdef _AIX
+#ifdef HAVE_SRC
int using_src = 1;
struct sockaddr srcsockaddr, fromsrc;
struct srcreq srcreq;
@@ -307,6 +298,8 @@ main(argc, argv)
char line[MSG_BSIZE + 1];
#endif
+ strcpy(ConfFile, "/etc/syslog.conf");
+ sprintf(PidFile, "%ssyslog.pid", PIDDIR);
while (--argc > 0) {
p = *++argv;
if (p[0] != '-')
@@ -314,7 +307,7 @@ main(argc, argv)
switch (p[1]) {
case 'f': /* configuration file */
if (p[2] != '\0')
- ConfFile = &p[2];
+ strcpy(ConfFile, &p[2]);
break;
case 'd': /* debug */
@@ -336,7 +329,7 @@ main(argc, argv)
}
}
-#ifdef _AIX
+#ifdef HAVE_SRC
addrlen = sizeof(struct sockaddr);
if (getsockname(0, &srcsockaddr, &addrlen) < 0) {
using_src = 0;
@@ -351,7 +344,7 @@ main(argc, argv)
#endif
if (!Debug) {
-#ifdef _AIX
+#ifdef HAVE_SRC
/* Don't fork if using SRC;
* SRC will think the program exited */
if (!using_src)
@@ -366,7 +359,7 @@ main(argc, argv)
(void) dup2(0, 2);
untty();
} else {
-#ifdef POSIX
+#ifdef _POSIX_VERSION
static char buf[BUFSIZ];
setvbuf (stdout, buf, _IOLBF, BUFSIZ);
#else
@@ -377,13 +370,13 @@ main(argc, argv)
consfile.f_type = F_CONSOLE;
(void) strcpy(consfile.f_un.f_fname, ctty);
(void) gethostname(LocalHostName, sizeof LocalHostName);
- if (p = strchr(LocalHostName, '.')) {
+ if ((p = strchr(LocalHostName, '.')) != NULL) {
*p++ = '\0';
LocalDomain = p;
}
else
LocalDomain = "";
-#ifdef POSIX
+#ifdef _POSIX_VERSION
action.sa_flags = 0;
sigemptyset(&action.sa_mask);
@@ -412,15 +405,15 @@ main(argc, argv)
(void) signal(SIGALRM, domark);
#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.sun_family)+strlen(sunx.sun_path)) < 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);
@@ -451,7 +444,6 @@ main(argc, argv)
finet = socket(AF_INET, SOCK_DGRAM, 0);
if (finet >= 0) {
struct servent *sp;
- int one = 1;
sp = getservbyname("syslog", "udp");
if (sp == NULL) {
@@ -465,7 +457,7 @@ main(argc, argv)
#ifdef COMPAT42
(void) close(finet);
#else
- if (bind(finet, &sin, sizeof(sin)) < 0) {
+ if (bind(finet, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
logerror("bind");
if (!Debug)
die(0);
@@ -475,25 +467,27 @@ main(argc, argv)
}
#endif /* COMPAT42 */
}
-#if defined(COMPAT42)
+#ifdef COMPAT42
InetInuse = 1;
inetm = 0;
klogm = 0;
-#elif defined(STREAMS_LOG_DRIVER)
+#else
+#ifdef STREAMS_LOG_DRIVER
klogm = 0;
-#else /* !COMPAT42, !STREAMS_LOG_DRIVER */
+#else
if ((fklog = open("/dev/klog", O_RDONLY)) >= 0)
klogm = FDMASK(fklog);
else {
dprintf("can't open /dev/klog (%d)\n", errno);
klogm = 0;
}
+#endif
#endif /* COMPAT42 */
/* tuck my process id away */
fp = fopen(PidFile, "w");
if (fp != NULL) {
- fprintf(fp, "%d\n", getpid());
+ fprintf(fp, "%d\n", (int) getpid());
(void) fclose(fp);
}
@@ -507,19 +501,14 @@ main(argc, argv)
znotice.z_default_format = "Syslog message from $instance, level $opcode:\n$message";
(void) ZInitialize ();
- init();
-#ifdef POSIX
+ init(0);
+#ifdef _POSIX_VERSION
action.sa_handler = init;
sigaction(SIGHUP, &action, NULL);
#else
(void) signal(SIGHUP, init);
#endif
-#ifndef STREAMS_LOG_DRIVER
- dprintf("fdmasks: funix=%d, inetm=%d, klogm=%d\n",
- FDMASK(funix), inetm, klogm);
-#endif
-
for (;;) {
int nfds;
#ifdef STREAMS_LOG_DRIVER
@@ -534,12 +523,12 @@ main(argc, argv)
readfds[POLLFD_unix].revents,
readfds[POLLFD_inet].fd,
readfds[POLLFD_inet].revents);
-
nfds = poll(readfds, 2, INFTIM);
#else /* STREAMS_LOG_DRIVER */
int readfds = FDMASK(funix) | inetm | klogm;
-#ifdef _AIX
+
+#ifdef HAVE_SRC
if (using_src)
readfds |= FDMASK(src_fd);
#endif
@@ -547,16 +536,15 @@ main(argc, argv)
dprintf("readfds = %#x\n", readfds);
nfds = select(20, (fd_set *) &readfds, (fd_set *) NULL,
(fd_set *) NULL, (struct timeval *) NULL);
- dprintf("got a message (%d, %#x)\n", nfds, readfds);
#endif /* STREAMS_LOG_DRIVER */
if (nfds == 0)
continue;
if (nfds < 0) {
if (errno != EINTR)
#ifdef STREAMS_LOG_DRIVER
- logerror("poll");
+ logerror("poll");
#else
- logerror("select");
+ logerror("select");
#endif
continue;
}
@@ -576,7 +564,10 @@ main(argc, argv)
i = getmsg(funix, &ctl, &dat, &flags);
if ((i==0)) {
#if (NLOGARGS != 3)
-#error This section of code assumes that NLOGARGS is 3. If that is not the case, this needs to be editted by hand. Sorry, but sed magic was too much for me.
+ error "This section of code assumes that NLOGARGS is 3.";
+ error "If that's not the case, this needs to be editted";
+ error "by hand. Sorry, but sed magic was too much for";
+ error "me.";
#else
{
char null[] = "", *p;
@@ -599,7 +590,7 @@ main(argc, argv)
} else if (i > 0) {
sprintf(line, "getmsg() > 1 (%X)", i);
logerror(line);
- }
+ }
}
#else /* STREAMS_LOG_DRIVER */
dprintf("got a message (%d, %#x)\n", nfds, readfds);
@@ -623,7 +614,7 @@ main(argc, argv)
printline(LocalHostName, line);
} else if (i < 0 && errno != EINTR)
logerror("recvfrom unix");
- }
+ }
#endif /* STREAMS_LOG_DRIVER */
#ifdef STREAMS_LOG_DRIVER
if (readfds[POLLFD_inet].revents & (POLLIN|POLLPRI)) {
@@ -631,16 +622,15 @@ main(argc, argv)
if (readfds & inetm) {
#endif
len = sizeof frominet;
- i = recvfrom(finet, line, MAXLINE, 0, &frominet, &len);
+ i = recvfrom(finet, line, MAXLINE, 0,
+ (struct sockaddr *) &frominet, &len);
if (i > 0) {
- extern char *cvthname();
-
line[i] = '\0';
printline(cvthname(&frominet), line);
} else if (i < 0 && errno != EINTR)
logerror("recvfrom inet");
}
-#ifdef _AIX
+#ifdef HAVE_SRC
dprintf("%d %d %d\n", using_src, readfds, FDMASK(src_fd));
if (using_src && (readfds & (FDMASK(src_fd)))) {
dprintf("got a src packet\n");
@@ -649,29 +639,33 @@ main(argc, argv)
&len);
dprintf("finished recvfrom, %d\n",i);
}
-/* if (i > 0) {
+#if 0
+ if (i > 0) {
handle_src(srcreq);
} else if (i < 0 && errno != EINTR)
logerror("recvfrom src");
- } */
-#endif /* _AIX */
+ }
+#endif
+#endif /* HAVE_SRC */
}
}
-usage()
+static void usage()
{
fprintf(stderr, "usage: syslogd [-d] [-mmarkinterval] [-ppath] [-fconffile]\n");
exit(1);
}
-untty()
+static void untty()
{
int i;
if (!Debug) {
i = open("/dev/tty", O_RDWR);
if (i >= 0) {
+#ifdef TIOCNOTTY /* Only necessary on old systems. */
(void) ioctl(i, (int) TIOCNOTTY, (char *)0);
+#endif
(void) close(i);
}
}
@@ -682,8 +676,8 @@ untty()
* on the appropriate log files.
*/
-printline(hname, msg)
- char *hname;
+static void printline(hname, msg)
+ const char *hname;
char *msg;
{
register char *p, *q;
@@ -727,7 +721,8 @@ printline(hname, msg)
* Take a raw input line from /dev/klog, split and format similar to syslog().
*/
-printsys(msg)
+#ifndef STREAMS_LOG_DRIVER
+static void printsys(msg)
char *msg;
{
register char *p, *q;
@@ -761,23 +756,22 @@ printsys(msg)
logmsg(pri, line, LocalHostName, flags);
}
}
-
-time_t now;
+#endif
/*
* Log a message to the appropriate log files, users, etc. based on
* the priority.
*/
-logmsg(pri, msg, from, flags)
+static void logmsg(pri, msg, from, flags)
int pri;
- char *msg, *from;
+ const char *msg, *from;
int flags;
{
register struct filed *f;
int fac, prilev, msglen;
- char *timestamp;
-#ifdef POSIX
+ const char *timestamp;
+#ifdef _POSIX_VERSION
sigset_t osig, sig;
#else
int omask;
@@ -785,7 +779,7 @@ logmsg(pri, msg, from, flags)
dprintf("logmsg: pri %o, flags %x, from %s, msg %s\n", pri, flags, from, msg);
-#ifdef POSIX
+#ifdef _POSIX_VERSION
(void) sigemptyset(&sig);
(void) sigaddset(&sig, SIGHUP);
(void) sigaddset(&sig, SIGALRM);
@@ -828,7 +822,7 @@ logmsg(pri, msg, from, flags)
fprintlog(f, flags, (char *)NULL, fac, prilev);
(void) close(f->f_file);
}
-#ifdef POSIX
+#ifdef _POSIX_VERSION
(void) sigprocmask(SIG_SETMASK, &osig, (sigset_t *)0);
#else
(void) sigsetmask(omask);
@@ -855,8 +849,8 @@ logmsg(pri, msg, from, flags)
!strcmp(from, f->f_prevhost)) {
(void) strncpy(f->f_lasttime, timestamp, 15);
f->f_prevcount++;
- dprintf("msg repeated %d times, %d sec of %d\n",
- f->f_prevcount, now - f->f_time,
+ dprintf("msg repeated %d times, %ld sec of %d\n",
+ f->f_prevcount, (long)(now - f->f_time),
repeatinterval[f->f_repeatcount]);
/*
* If domark would have logged this by now,
@@ -876,6 +870,7 @@ logmsg(pri, msg, from, flags)
(void) strncpy(f->f_lasttime, timestamp, 15);
(void) strncpy(f->f_prevhost, from,
sizeof(f->f_prevhost));
+ f->f_prevhost[sizeof(f->f_prevhost) - 1] = 0;
if (msglen < MAXSVLINE) {
f->f_prevlen = msglen;
f->f_prevpri = pri;
@@ -889,23 +884,23 @@ logmsg(pri, msg, from, flags)
}
}
}
-#ifdef POSIX
+#ifdef _POSIX_VERSION
(void) sigprocmask(SIG_SETMASK, &osig, (sigset_t *)0);
#else
(void) sigsetmask(omask);
#endif
}
-fprintlog(f, flags, msg, fac, prilev)
+static void fprintlog(f, flags, msg, fac, prilev)
register struct filed *f;
int flags;
- char *msg;
+ const char *msg;
int fac, prilev;
{
struct iovec iov[6];
register struct iovec *v = iov;
register int l;
- char line[MAXLINE + 1];
+ char line[MAXLINE + MAXHOSTNAMELEN + 21];
char repbuf[80];
char pri_fac_str[35];
int i;
@@ -924,7 +919,7 @@ fprintlog(f, flags, msg, fac, prilev)
v->iov_len = 1;
v++;
if (msg) {
- v->iov_base = msg;
+ v->iov_base = (char *) msg;
v->iov_len = strlen(msg);
} else if (f->f_prevcount > 1) {
(void) sprintf(repbuf, "last message repeated %d times",
@@ -953,9 +948,11 @@ fprintlog(f, flags, msg, fac, prilev)
if (l > MAXLINE)
l = MAXLINE;
#ifdef COMPAT42
- if (sendto(f->f_file, line, l, 0, &f->f_un.f_forw.f_addr,
+ if (sendto(f->f_file, line, l, 0,
+ (struct sockaddr *) &f->f_un.f_forw.f_addr,
#else
- if (sendto(finet, line, l, 0, &f->f_un.f_forw.f_addr,
+ if (sendto(finet, line, l, 0,
+ (struct sockaddr *) &f->f_un.f_forw.f_addr,
#endif
sizeof f->f_un.f_forw.f_addr) != l) {
int e = errno;
@@ -1013,6 +1010,11 @@ fprintlog(f, flags, msg, fac, prilev)
iov[0].iov_base,
iov[2].iov_base,
iov[4].iov_base);
+ if (!msg && f->f_prevcount > 1) {
+ /* Include previous line with Zephyrgram. */
+ sprintf(line + strlen(line), ":\n%*s",
+ f->f_prevlen, f->f_prevline);
+ }
(void) sprintf(pri_fac_str, "%s.%s",
FacNames[fac].c_name,
PriNames[(prilev & LOG_PRIMASK)].c_name);
@@ -1022,7 +1024,7 @@ fprintlog(f, flags, msg, fac, prilev)
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])
+ if (!f->f_un.f_uname[i])
break;
/* map "*" into null recipient and therefore
anybody who is listening */
@@ -1047,16 +1049,16 @@ fprintlog(f, flags, msg, fac, prilev)
f->f_prevcount = 0;
}
-#ifdef POSIX
+#ifdef _POSIX_VERSION
sigjmp_buf ttybuf;
#else
jmp_buf ttybuf;
#endif
-static sighandler_type
-endtty()
+static RETSIGTYPE endtty(sig)
+ int sig;
{
-#ifdef POSIX
+#ifdef _POSIX_VERSION
siglongjmp(ttybuf, 1);
#else
longjmp(ttybuf, 1);
@@ -1070,7 +1072,7 @@ endtty()
* world, or a list of approved users.
*/
-wallmsg(f, iov)
+static void wallmsg(f, iov)
register struct filed *f;
struct iovec *iov;
{
@@ -1081,7 +1083,7 @@ wallmsg(f, iov)
struct utmp ut;
static char p[6+sizeof(ut.ut_line)] = "/dev/";
char greetings[200];
-#ifdef POSIX
+#ifdef _POSIX_VERSION
struct sigaction action;
#endif
@@ -1100,7 +1102,7 @@ wallmsg(f, iov)
* and doing notty().
*/
if (fork() == 0) {
-#ifdef POSIX
+#ifdef _POSIX_VERSION
action.sa_flags = 0;
(void) sigemptyset(&action.sa_mask);
@@ -1136,7 +1138,7 @@ wallmsg(f, iov)
/* should we send the message to this user? */
if (f->f_type == F_USERS) {
for (i = 0; i < MAXUNAMES; i++) {
- if (!f->f_un.f_uname[i][0]) {
+ if (!f->f_un.f_uname[i]) {
i = MAXUNAMES;
break;
}
@@ -1156,7 +1158,7 @@ wallmsg(f, iov)
iov[0].iov_len = len;
iov[1].iov_len = 0;
}
-#ifdef POSIX
+#ifdef _POSIX_VERSION
if (sigsetjmp(ttybuf, 1) == 0)
#else
if (setjmp(ttybuf) == 0)
@@ -1184,23 +1186,22 @@ wallmsg(f, iov)
reenter = 0;
}
-static sighandler_type
-reapchild()
+static RETSIGTYPE reapchild(sig)
+ int sig;
{
-#ifdef POSIX
- int status;
- while (waitpid(-1, &status, WNOHANG) > 0) ;
+#ifdef HAVE_WAITPID
+ int status;
+ while (waitpid(-1, &status, WNOHANG) > 0) ;
#else
- union wait status;
- while (wait3(&status, WNOHANG, (struct rusage *) NULL) > 0) ;
+ union wait status;
+ while (wait3(&status, WNOHANG, (struct rusage *) NULL) > 0) ;
#endif
}
/*
* Return a printable representation of a host address.
*/
-char *
-cvthname(f)
+static const char *cvthname(f)
struct sockaddr_in *f;
{
struct hostent *hp;
@@ -1213,7 +1214,8 @@ cvthname(f)
dprintf("Malformed from address\n");
return ("???");
}
- hp = gethostbyaddr(&f->sin_addr, sizeof(struct in_addr), f->sin_family);
+ hp = gethostbyaddr((const char *) &f->sin_addr, sizeof(struct in_addr),
+ f->sin_family);
if (hp == 0) {
dprintf("Host name for your address (%s) unknown\n",
inet_ntoa(f->sin_addr));
@@ -1224,8 +1226,8 @@ cvthname(f)
return (hp->h_name);
}
-static sighandler_type
-domark()
+static RETSIGTYPE domark(sig)
+ int sig;
{
register struct filed *f;
@@ -1252,24 +1254,19 @@ domark()
/*
* Print syslogd errors some place.
*/
-logerror(type)
- char *type;
+static void logerror(type)
+ const char *type;
{
char buf[100];
- if (errno == 0)
- (void) sprintf(buf, "syslogd: %s", type);
- else if ((unsigned) errno > sys_nerr)
- (void) sprintf(buf, "syslogd: %s: error %d", type, errno);
- else
- (void) sprintf(buf, "syslogd: %s: %s", type, strerror(errno));
+ sprintf(buf, "syslogd: %s", strerror(errno));
errno = 0;
dprintf("%s\n", buf);
logmsg(LOG_SYSLOG|LOG_ERR, buf, LocalHostName, ADDDATE);
}
-static sighandler_type
-die(sig)
+static RETSIGTYPE die(sig)
+ int sig;
{
register struct filed *f;
char buf[100];
@@ -1287,7 +1284,7 @@ die(sig)
logerror(buf);
}
#ifndef STREAMS_LOG_DRIVER
- (void) unlink(LogName);
+ (void) unlink(LogName);
#endif
exit(0);
}
@@ -1296,8 +1293,8 @@ die(sig)
* INIT -- Initialize syslogd from configuration table
*/
-static sighandler_type
-init()
+static RETSIGTYPE init(sig)
+ int sig;
{
register int i;
register FILE *cf;
@@ -1316,7 +1313,6 @@ init()
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:
@@ -1326,6 +1322,13 @@ init()
#endif
(void) close(f->f_file);
break;
+
+ case F_USERS:
+ case F_ZEPHYR:
+
+ for (i = 0; i < MAXUNAMES && f->f_un.f_uname[i]; i++)
+ free(f->f_un.f_uname[i]);
+ break;
}
next = f->f_next;
free((char *) f);
@@ -1389,7 +1392,7 @@ init()
break;
case F_USERS:
- for (i = 0; i < MAXUNAMES && *f->f_un.f_uname[i]; i++)
+ for (i = 0; i < MAXUNAMES && f->f_un.f_uname[i]; i++)
printf("%s, ", f->f_un.f_uname[i]);
break;
}
@@ -1405,7 +1408,7 @@ init()
* Crack a configuration file line
*/
-cfline(line, f)
+static void cfline(line, f)
char *line;
register struct filed *f;
{
@@ -1541,15 +1544,18 @@ cfline(line, f)
for (i = 0; i < MAXUNAMES && *p; i++) {
for (q = p; *q && *q != ','; )
q++;
- (void) strncpy(f->f_un.f_uname[i], p, UTMPNAMESZ);
- if ((q - p) > UTMPNAMESZ)
- f->f_un.f_uname[i][UTMPNAMESZ] = '\0';
- else
- f->f_un.f_uname[i][q - p] = '\0';
+ f->f_un.f_uname[i] = malloc(q - p + 1);
+ if (f->f_un.f_uname[i]) {
+ strncpy(f->f_un.f_uname[i], p, q - p);
+ f->f_un.f_uname[i][q - p] = 0;
+ } else {
+ break;
+ }
while (*q == ',' || *q == ' ')
q++;
p = q;
}
+ f->f_un.f_uname[i] = NULL;
f->f_type = F_USERS;
break;
@@ -1557,15 +1563,18 @@ cfline(line, f)
for (i = 0; i < MAXUNAMES && *p; i++) {
for (q = p; *q && *q != ','; )
q++;
- (void) strncpy(f->f_un.f_uname[i], p, UNAMESZ);
- if ((q - p) > UNAMESZ)
- f->f_un.f_uname[i][UNAMESZ] = '\0';
- else
- f->f_un.f_uname[i][q - p] = '\0';
+ f->f_un.f_uname[i] = malloc(q - p + 1);
+ if (f->f_un.f_uname[i]) {
+ strncpy(f->f_un.f_uname[i], p, q - p);
+ f->f_un.f_uname[i][q - p] = 0;
+ } else {
+ break;
+ }
while (*q == ',' || *q == ' ')
q++;
p = q;
}
+ f->f_un.f_uname[i] = NULL;
f->f_type = F_ZEPHYR;
break;
}
@@ -1576,7 +1585,7 @@ cfline(line, f)
* Decode a symbolic name to a numeric value
*/
-decode(name, codetab)
+static int decode(name, codetab)
char *name;
struct code *codetab;
{
@@ -1598,11 +1607,10 @@ decode(name, codetab)
return (-1);
}
-#ifdef _AIX
+#ifdef HAVE_SRC
/* Routines for handling the SRC (System Resource Controller) system */
-void
-handle_src(packet)
+static void handle_src(packet)
struct srcreq packet;
{
void send_src_reply();
@@ -1638,7 +1646,7 @@ handle_src(packet)
break;
case REFRESH:
if (packet.subreq.object == SUBSYSTEM) {
- init();
+ init(0);
send_src_reply(packet, SRC_OK, "", sizeof(struct srcrep));
} else {
send_src_reply(packet, SRC_SUBMSG,
@@ -1649,8 +1657,7 @@ handle_src(packet)
}
}
-void
-send_src_reply(orig_packet, rtncode, packet,len)
+static void send_src_reply(orig_packet, rtncode, packet,len)
struct srcreq orig_packet;
int rtncode;
char *packet;
@@ -1668,4 +1675,4 @@ send_src_reply(orig_packet, rtncode, packet,len)
srcsrpy(srcrrqs(&orig_packet), (char *)&reply, len, cont);
}
-#endif /* _AIX */
+#endif /* HAVE_SRC */