[msyslog 1.01 ] [sysv patch ] This patch was submitted to the msyslog-dev mailing list. It should be integrated into the distributed source tree as of the next release, possibly after some editing. ari edelkind (10/28/2000) last modified 11/02/2000 diff -ruN msyslog-v1.01.orig/CHANGES.ari msyslog-v1.01/CHANGES.ari --- msyslog-v1.01.orig/CHANGES.ari Thu Jan 1 05:00:00 1970 +++ msyslog-v1.01/CHANGES.ari Thu Nov 2 03:28:52 2000 @@ -0,0 +1,139 @@ +NOTES: + +For solaris and irix compilation, i removed BSD and LINUX from the module +list. I did not feel it worthwhile to get those modules to compile on these +platforms, since the required devices are not accessible in the same manner. +im_unix does now compile on these platforms, but should be useless, as they +use streams devices, not unix domain sockets. So don't try using the UNIX +module unless you remember the major and minor numbers of /dev/log. If you +need the BSD or LINUX modules, add them; if you don't need the UNIX module, +remove it. + +GNU make should be used. The make which comes with solaris will try making +the programs before the objects. + +Solaris requires libdl, libnsl, libresolv, and libsocket. To link with +these, use the argument 'LIBS="-ldl -lnsl -lresolv -lsocket"' on the make +command line (i.e. gmake LIBS="-ldl -lnsl -lresolv -lsocket"). + +Solaris sh and GNU test don't seem to work together. Using bash on solaris +with GNU test yields no problem, and using solaris sh with solaris test also +yields no problem. Using solaris sh with GNU test gives the message "test: +argument expected" for something like: + + if test -e "bleh"; then echo hi; fi + +... however, using test -f works fine. I have changed any instances of -e +which are to check a regular file to -f. + + + +CHANGES: + +* aclocal.m4: removed quotes for calling MSYSLOG_GREP (quotes there +result in double-quotes being used in configure) + +* aclocal.m4: changed 'test -e' to 'test -f' for all instances (all +instances were meant to check for a regular file) + +* for all modules which listed "../modules.h" before "../syslogd.h" for +inclusion, moved "../syslogd.h" include before "../modules.h" include. +modules.h uses MAXHOSTNAMELEN, which is defined by netdb.h, which is +included by syslogd.h. + +* added UT_NAMESIZE define in syslogd.h if it's not already defined + +* syslogd.c: changed wording 'Using _PATH_CONSOLE as "/dev/console"' to +'Using "/dev/console" for _PATH_CONSOLE' (was confusing) + +* ttymsg.c: use "/dev/" for _PATH_DEV if _PATH_DEV is not defined + +* conditionally (if solaris or irix) added typedefs for u_int32_t and +u_int64_t to conditional.h and included ../conditional.h from peo/md5.h and +peo/sha1.h + +* modules/om_peo.c: don't include err.h for irix or solaris + +* peo/peochk.c: don't include err.h for irix or solaris + +* added definition of __P to conditional.h if it isn't already defined + +* changed syslogd.c to only include sys/sysctl.h if we aren't using solaris + +* syslogd.c: changed sys_errlist[errno] to strerror(errno) to make more +portable + +* conditional.h: added SYSLOG_NAMES section for solaris, with added +LOG_MAKEPRI, LOG_PRI, and LOG_FAC definitions + +* syslogd.c: added conditional.h to includes (just after system-wide syslogd.h) + +* syslogd.c: commented out the current inclusion of limits.h, and added the +inclusion of limits.h unconditionally + +* syslogd.c: if NAME_MAX is not defined, define it as MAXNAMLEN. If +MAXNAMLEN isn't defined either, use 255. A better solution would be to use +the POSIX-compliant pathconf() function (long pathconf("/path" +_PC_NAME_MAX)). + +* conditional.h: added define of _PATH_UTMP if it isn't already defined + +* peo/rmd160.h: added include for ../conditional.h + +* peo/peochk.c: changed all instances of err() calls to perror()+exit() +calls, and all instances of errx() calls to fprintf()+exit() calls. the +err() family (from err.h) is very unportable. + +* added -Wall to CFLAGS in Makefile.in + +* syslogd.c: added and to includes (for +recvfrom) + +* ttymsg.c: added to includes (for bcopy and bzero) + +* man/GNUmakefile.in: altered to not remove makefiles on a simple make clean + +* conditional.h: added typedef for socklen_t for irix + +* syslogd.c: replaced (void)daemon(0, 0) with a portable method, which +should mimic its behavior verbatim. + +* syslogd.c: replaced sigsetmask with the more portable sigprocmask + +* added executable bit to install-sh + +* static_modules.c: properly spaced lines in function module_load (why was +it like that?) + +* syslogd.c: added new alarm catcher in domark() -- after a signal is +caught, it's not handled anymore on SYSV machines... and it won't hurt to do +this on BSD-style systems as well. If the signal is no longer handled, the +next alarm() will kill the process. Note that a better (and portable) +solution here would be to use sigaction(). + +* syslogd.h: added sys/param.h include + +* added ../conditional.h include to all modules that use socklen_t + + + +COMMENTS/GRIPES: + +* --with-msyslog-lib-dir should default to ${prefix}/lib/alat, not +/usr/local/lib/alat + +* most preprocessor checks should be done with configure instead, aside from +the preprocessor checks used to check defines in config.h. During compile, +one should not need to see #warning messages. + +* proper libraries for linking should be decided in configure. + +* syslogd.c: systems with getutent() and related functions should use them +instead of reading utmp directly. This includes linux, solaris, and irix, +at least. + +* the CFLAGS environment variable should have its proper effect during +configure. at the moment, it is ignored. If other related environment +variables are also ignored, configure should be modified for them as well, +so they may have their designated effects. + diff -ruN msyslog-v1.01.orig/aclocal.m4 msyslog-v1.01/aclocal.m4 --- msyslog-v1.01.orig/aclocal.m4 Tue Sep 12 02:15:30 2000 +++ msyslog-v1.01/aclocal.m4 Fri Oct 20 23:56:29 2000 @@ -6,7 +6,7 @@ dnl Searches for a pattern on a file and executes command if match dnl AC_DEFUN(MSYSLOG_GREP, [ -if test -e "$2" +if test -f "$2" then if test "`grep $1 $2`" then @@ -67,7 +67,7 @@ for i in /usr/local/include/mysql /usr/local/mysql/include \ /usr/local/include /usr/include/mysql /usr/include no do - if test -e "$i/mysql.h" + if test -f "$i/mysql.h" then break fi @@ -122,7 +122,7 @@ for i in /usr/local/pgsql/include /usr/local/include/pgsql \ /usr/local/include /usr/include/pgsql /usr/include no do - if test -e "$i/libpq-fe.h" + if test -f "$i/libpq-fe.h" then break fi @@ -202,14 +202,14 @@ olast->om_init=om_$1_init; \ olast->om_doLog=om_$1_doLog;" -MSYSLOG_GREP(om_$1_flush, "$MODULES_DIR/$2", [ +MSYSLOG_GREP(om_$1_flush, $MODULES_DIR/$2, [ SMODULES_HEADER="$SMODULES_HEADER \ int om_$1_flush (struct filed*, struct om_hdr_ctx*);" SMODULES_LOAD="$SMODULES_LOAD \ olast->om_flush=om_$1_flush;" ]) -MSYSLOG_GREP(om_$1_close, "$MODULES_DIR/$2", [ +MSYSLOG_GREP(om_$1_close, $MODULES_DIR/$2, [ SMODULES_HEADER="$SMODULES_HEADER \ int om_$1_close (struct filed*, struct om_hdr_ctx*);" SMODULES_LOAD="$SMODULES_LOAD \ @@ -246,13 +246,13 @@ ilast->im_init=im_$1_init; \ ilast->im_getLog=im_$1_getLog;" -MSYSLOG_GREP(im_$1_close, "$MODULES_DIR/$2", [ +MSYSLOG_GREP(im_$1_close, $MODULES_DIR/$2, [ SMODULES_HEADER="$SMODULES_HEADER \ int im_$1_close (struct i_module*);" SMODULES_LOAD="$SMODULES_LOAD \ ilast->im_close=im_$1_close;" ]) -MSYSLOG_GREP(im_$1_timer, "$MODULES_DIR/$2", [ +MSYSLOG_GREP(im_$1_timer, $MODULES_DIR/$2, [ SMODULES_HEADER="$SMODULES_HEADER \ int im_$1_timer (struct i_module*, struct im_msg*);" SMODULES_LOAD="$SMODULES_LOAD \ diff -ruN msyslog-v1.01.orig/configure msyslog-v1.01/configure --- msyslog-v1.01.orig/configure Tue Sep 12 02:15:30 2000 +++ msyslog-v1.01/configure Fri Oct 20 23:59:49 2000 @@ -1263,9 +1263,9 @@ ilast->im_getLog=im_unix_getLog;" -if test -e ""$MODULES_DIR/im_unix.c"" +if test -f "$MODULES_DIR/im_unix.c" then - if test "`grep im_unix_close "$MODULES_DIR/im_unix.c"`" + if test "`grep im_unix_close $MODULES_DIR/im_unix.c`" then SMODULES_HEADER="$SMODULES_HEADER \ @@ -1277,9 +1277,9 @@ -if test -e ""$MODULES_DIR/im_unix.c"" +if test -f "$MODULES_DIR/im_unix.c" then - if test "`grep im_unix_timer "$MODULES_DIR/im_unix.c"`" + if test "`grep im_unix_timer $MODULES_DIR/im_unix.c`" then SMODULES_HEADER="$SMODULES_HEADER \ @@ -1336,9 +1336,9 @@ ilast->im_getLog=im_udp_getLog;" -if test -e ""$MODULES_DIR/im_udp.c"" +if test -f "$MODULES_DIR/im_udp.c" then - if test "`grep im_udp_close "$MODULES_DIR/im_udp.c"`" + if test "`grep im_udp_close $MODULES_DIR/im_udp.c`" then SMODULES_HEADER="$SMODULES_HEADER \ @@ -1350,9 +1350,9 @@ -if test -e ""$MODULES_DIR/im_udp.c"" +if test -f "$MODULES_DIR/im_udp.c" then - if test "`grep im_udp_timer "$MODULES_DIR/im_udp.c"`" + if test "`grep im_udp_timer $MODULES_DIR/im_udp.c`" then SMODULES_HEADER="$SMODULES_HEADER \ @@ -1409,9 +1409,9 @@ ilast->im_getLog=im_bsd_getLog;" -if test -e ""$MODULES_DIR/im_bsd.c"" +if test -f "$MODULES_DIR/im_bsd.c" then - if test "`grep im_bsd_close "$MODULES_DIR/im_bsd.c"`" + if test "`grep im_bsd_close $MODULES_DIR/im_bsd.c`" then SMODULES_HEADER="$SMODULES_HEADER \ @@ -1423,9 +1423,9 @@ -if test -e ""$MODULES_DIR/im_bsd.c"" +if test -f "$MODULES_DIR/im_bsd.c" then - if test "`grep im_bsd_timer "$MODULES_DIR/im_bsd.c"`" + if test "`grep im_bsd_timer $MODULES_DIR/im_bsd.c`" then SMODULES_HEADER="$SMODULES_HEADER \ @@ -1482,9 +1482,9 @@ ilast->im_getLog=im_linux_getLog;" -if test -e ""$MODULES_DIR/im_linux.c"" +if test -f "$MODULES_DIR/im_linux.c" then - if test "`grep im_linux_close "$MODULES_DIR/im_linux.c"`" + if test "`grep im_linux_close $MODULES_DIR/im_linux.c`" then SMODULES_HEADER="$SMODULES_HEADER \ @@ -1496,9 +1496,9 @@ -if test -e ""$MODULES_DIR/im_linux.c"" +if test -f "$MODULES_DIR/im_linux.c" then - if test "`grep im_linux_timer "$MODULES_DIR/im_linux.c"`" + if test "`grep im_linux_timer $MODULES_DIR/im_linux.c`" then SMODULES_HEADER="$SMODULES_HEADER \ @@ -1555,9 +1555,9 @@ olast->om_doLog=om_classic_doLog;" -if test -e ""$MODULES_DIR/om_classic.c"" +if test -f "$MODULES_DIR/om_classic.c" then - if test "`grep om_classic_flush "$MODULES_DIR/om_classic.c"`" + if test "`grep om_classic_flush $MODULES_DIR/om_classic.c`" then SMODULES_HEADER="$SMODULES_HEADER \ @@ -1570,9 +1570,9 @@ -if test -e ""$MODULES_DIR/om_classic.c"" +if test -f "$MODULES_DIR/om_classic.c" then - if test "`grep om_classic_close "$MODULES_DIR/om_classic.c"`" + if test "`grep om_classic_close $MODULES_DIR/om_classic.c`" then SMODULES_HEADER="$SMODULES_HEADER \ @@ -1629,9 +1629,9 @@ olast->om_doLog=om_peo_doLog;" -if test -e ""$MODULES_DIR/om_peo.c"" +if test -f "$MODULES_DIR/om_peo.c" then - if test "`grep om_peo_flush "$MODULES_DIR/om_peo.c"`" + if test "`grep om_peo_flush $MODULES_DIR/om_peo.c`" then SMODULES_HEADER="$SMODULES_HEADER \ @@ -1644,9 +1644,9 @@ -if test -e ""$MODULES_DIR/om_peo.c"" +if test -f "$MODULES_DIR/om_peo.c" then - if test "`grep om_peo_close "$MODULES_DIR/om_peo.c"`" + if test "`grep om_peo_close $MODULES_DIR/om_peo.c`" then SMODULES_HEADER="$SMODULES_HEADER \ @@ -1772,7 +1772,7 @@ for i in /usr/local/include/mysql /usr/local/mysql/include \ /usr/local/include /usr/include/mysql /usr/include no do - if test -e "$i/mysql.h" + if test -f "$i/mysql.h" then break fi @@ -1821,9 +1821,9 @@ olast->om_doLog=om_mysql_doLog;" -if test -e ""$MODULES_DIR/om_mysql.c"" +if test -f "$MODULES_DIR/om_mysql.c" then - if test "`grep om_mysql_flush "$MODULES_DIR/om_mysql.c"`" + if test "`grep om_mysql_flush $MODULES_DIR/om_mysql.c`" then SMODULES_HEADER="$SMODULES_HEADER \ @@ -1836,9 +1836,9 @@ -if test -e ""$MODULES_DIR/om_mysql.c"" +if test -f "$MODULES_DIR/om_mysql.c" then - if test "`grep om_mysql_close "$MODULES_DIR/om_mysql.c"`" + if test "`grep om_mysql_close $MODULES_DIR/om_mysql.c`" then SMODULES_HEADER="$SMODULES_HEADER \ @@ -1956,7 +1956,7 @@ for i in /usr/local/pgsql/include /usr/local/include/pgsql \ /usr/local/include /usr/include/pgsql /usr/include no do - if test -e "$i/libpq-fe.h" + if test -f "$i/libpq-fe.h" then break fi @@ -2012,9 +2012,9 @@ olast->om_doLog=om_pgsql_doLog;" -if test -e ""$MODULES_DIR/om_pgsql.c"" +if test -f "$MODULES_DIR/om_pgsql.c" then - if test "`grep om_pgsql_flush "$MODULES_DIR/om_pgsql.c"`" + if test "`grep om_pgsql_flush $MODULES_DIR/om_pgsql.c`" then SMODULES_HEADER="$SMODULES_HEADER \ @@ -2027,9 +2027,9 @@ -if test -e ""$MODULES_DIR/om_pgsql.c"" +if test -f "$MODULES_DIR/om_pgsql.c" then - if test "`grep om_pgsql_close "$MODULES_DIR/om_pgsql.c"`" + if test "`grep om_pgsql_close $MODULES_DIR/om_pgsql.c`" then SMODULES_HEADER="$SMODULES_HEADER \ @@ -2086,9 +2086,9 @@ olast->om_doLog=om_regex_doLog;" -if test -e ""$MODULES_DIR/om_regex.c"" +if test -f "$MODULES_DIR/om_regex.c" then - if test "`grep om_regex_flush "$MODULES_DIR/om_regex.c"`" + if test "`grep om_regex_flush $MODULES_DIR/om_regex.c`" then SMODULES_HEADER="$SMODULES_HEADER \ @@ -2101,9 +2101,9 @@ -if test -e ""$MODULES_DIR/om_regex.c"" +if test -f "$MODULES_DIR/om_regex.c" then - if test "`grep om_regex_close "$MODULES_DIR/om_regex.c"`" + if test "`grep om_regex_close $MODULES_DIR/om_regex.c`" then SMODULES_HEADER="$SMODULES_HEADER \ diff -ruN msyslog-v1.01.orig/modules.conf msyslog-v1.01/modules.conf --- msyslog-v1.01.orig/modules.conf Fri Sep 22 01:16:00 2000 +++ msyslog-v1.01/modules.conf Fri Oct 27 02:03:19 2000 @@ -1,6 +1,6 @@ UNIX=static BSD= -LINUX=static +LINUX= UDP=static CLASSIC=static PEO=static diff -ruN msyslog-v1.01.orig/src/Makefile.in msyslog-v1.01/src/Makefile.in --- msyslog-v1.01.orig/src/Makefile.in Tue Sep 5 02:02:58 2000 +++ msyslog-v1.01/src/Makefile.in Sat Oct 21 00:43:59 2000 @@ -29,7 +29,7 @@ # CC= @CC@ -CFLAGS= @CFLAGS@ +CFLAGS= @CFLAGS@ -Wall LDFLAGS= @LDFLAGS@ LDDFLAGS= @LDDFLAGS@ CPPFLAGS= @CPPFLAGS@ diff -ruN msyslog-v1.01.orig/src/conditional.h msyslog-v1.01/src/conditional.h --- msyslog-v1.01.orig/src/conditional.h Thu Jan 1 05:00:00 1970 +++ msyslog-v1.01/src/conditional.h Thu Oct 12 22:18:46 2000 @@ -0,0 +1,104 @@ + +#ifndef HAVE_CONDITIONAL_H +#define HAVE_CONDITIONAL_H + +#if (__svr4__ && __sun__) +/* solaris doesn't have u_int_32 or u_int_64 */ +typedef uint32_t u_int32_t; +typedef uint64_t u_int64_t; +#elif sgi +/* irix has u_int32_t, but not u_int64_t or socklen_t */ +typedef __uint64_t u_int64_t; +typedef __uint32_t socklen_t; +#endif + +/* if __P isn't already defined... */ +#ifdef __STDC__ +#ifndef __P +#define __P(p) p +#endif +#else +#ifndef __P +#define __P(p) () +#endif +#endif /* __STDC__ */ + + +/* syslog code taken mostly from linux */ +#if (__svr4__ && __sun__) +# ifdef SYSLOG_NAMES + +# ifndef LOG_MAKEPRI +# define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri)) +# endif + +# ifndef LOG_PRI +# define LOG_PRI(p) ((p) & LOG_PRIMASK) +# endif + +# ifndef LOG_FAC +# define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) +# endif + +# define INTERNAL_NOPRI 0x10 +# define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0) + +typedef struct _code { + char *c_name; + int c_val; +} CODE; + +CODE prioritynames[] = + { + { "alert", LOG_ALERT }, + { "crit", LOG_CRIT }, + { "debug", LOG_DEBUG }, + { "emerg", LOG_EMERG }, + { "err", LOG_ERR }, + { "error", LOG_ERR }, /* DEPRECATED */ + { "info", LOG_INFO }, + { "none", INTERNAL_NOPRI }, /* INTERNAL */ + { "notice", LOG_NOTICE }, + { "panic", LOG_EMERG }, /* DEPRECATED */ + { "warn", LOG_WARNING }, /* DEPRECATED */ + { "warning", LOG_WARNING }, + { NULL, -1 } + }; + +CODE facilitynames[] = + { + { "auth", LOG_AUTH }, + { "cron", LOG_CRON }, + { "daemon", LOG_DAEMON }, + { "kern", LOG_KERN }, + { "lpr", LOG_LPR }, + { "mail", LOG_MAIL }, + { "mark", INTERNAL_MARK }, /* INTERNAL */ + { "news", LOG_NEWS }, + { "security", LOG_AUTH }, /* DEPRECATED */ + { "syslog", LOG_SYSLOG }, + { "user", LOG_USER }, + { "uucp", LOG_UUCP }, + { "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 } + }; + +# endif /* SYSLOG_NAMES */ +#endif /* solaris */ + + +/* if _PATH_UTMP isn't defined, define it here... */ +#ifndef _PATH_UTMP +# define _PATH_UTMP "/var/adm/utmp" +# warning Using "/var/adm/utmp" for _PATH_UTMP +#endif + + +#endif /* !HAVE_CONDITIONAL_H */ diff -ruN msyslog-v1.01.orig/src/man/GNUmakefile.in msyslog-v1.01/src/man/GNUmakefile.in --- msyslog-v1.01.orig/src/man/GNUmakefile.in Thu Sep 7 03:33:40 2000 +++ msyslog-v1.01/src/man/GNUmakefile.in Wed Oct 11 23:38:00 2000 @@ -41,7 +41,9 @@ $(OMAN): -gzip -cf $(@:%.gz=%) > $(MANDIR)/man$(subst .,,$(suffix $(@:%.gz=%)))/$@ -distclean cleandir clean: +clean: + +distclean cleandir: clean -rm -f GNUmakefile -rm -f BSDmakefile diff -ruN msyslog-v1.01.orig/src/modules/Makefile.in msyslog-v1.01/src/modules/Makefile.in --- msyslog-v1.01.orig/src/modules/Makefile.in Tue Sep 12 02:15:31 2000 +++ msyslog-v1.01/src/modules/Makefile.in Wed Oct 11 22:34:13 2000 @@ -30,7 +30,7 @@ CC= @CC@ LD= ld -CFLAGS= @CFLAGS@ +CFLAGS= @CFLAGS@ -Wall LDFLAGS= @LDFLAGS@ LDDFLAGS= @LDDFLAGS@ DCCFLAGS= @DCCFLAGS@ diff -ruN msyslog-v1.01.orig/src/modules/im_udp.c msyslog-v1.01/src/modules/im_udp.c --- msyslog-v1.01.orig/src/modules/im_udp.c Fri Sep 15 00:36:58 2000 +++ msyslog-v1.01/src/modules/im_udp.c Thu Nov 2 03:24:59 2000 @@ -45,15 +45,16 @@ #include #include -#include #include +#include #include #include #include #include -#include "../modules.h" +#include "../conditional.h" #include "../syslogd.h" +#include "../modules.h" /* standard input module header variables in context */ struct im_udp_ctx { diff -ruN msyslog-v1.01.orig/src/modules/im_unix.c msyslog-v1.01/src/modules/im_unix.c --- msyslog-v1.01.orig/src/modules/im_unix.c Wed Sep 6 04:42:39 2000 +++ msyslog-v1.01/src/modules/im_unix.c Thu Nov 2 03:26:48 2000 @@ -51,8 +51,10 @@ #include #include #include -#include "../modules.h" + +#include "../conditional.h" #include "../syslogd.h" +#include "../modules.h" /* * get message diff -ruN msyslog-v1.01.orig/src/modules/om_mysql.c msyslog-v1.01/src/modules/om_mysql.c --- msyslog-v1.01.orig/src/modules/om_mysql.c Thu Sep 14 06:07:29 2000 +++ msyslog-v1.01/src/modules/om_mysql.c Sat Oct 21 00:25:18 2000 @@ -49,8 +49,8 @@ #include #include #include "../config.h" -#include "../modules.h" #include "../syslogd.h" +#include "../modules.h" #include "sql_misc.h" #define MAX_QUERY 8192 diff -ruN msyslog-v1.01.orig/src/modules/om_peo.c msyslog-v1.01/src/modules/om_peo.c --- msyslog-v1.01.orig/src/modules/om_peo.c Wed Sep 6 04:42:39 2000 +++ msyslog-v1.01/src/modules/om_peo.c Wed Oct 11 23:41:49 2000 @@ -44,7 +44,9 @@ #include #include -#include +#if !((__svr4__ && __sun__) || sgi) +# include +#endif #include #include #include @@ -52,6 +54,7 @@ #include #include #include +#include #include "../syslogd.h" #include "../modules.h" diff -ruN msyslog-v1.01.orig/src/modules/om_pgsql.c msyslog-v1.01/src/modules/om_pgsql.c --- msyslog-v1.01.orig/src/modules/om_pgsql.c Thu Sep 14 06:09:32 2000 +++ msyslog-v1.01/src/modules/om_pgsql.c Sat Oct 21 00:29:01 2000 @@ -56,8 +56,8 @@ #include #include #include "../config.h" -#include "../modules.h" #include "../syslogd.h" +#include "../modules.h" #include "sql_misc.h" #include diff -ruN msyslog-v1.01.orig/src/peo/Makefile.in msyslog-v1.01/src/peo/Makefile.in --- msyslog-v1.01.orig/src/peo/Makefile.in Fri Aug 25 05:16:59 2000 +++ msyslog-v1.01/src/peo/Makefile.in Sat Oct 21 00:44:20 2000 @@ -29,7 +29,7 @@ # CC= @CC@ -CFLAGS= @CFLAGS@ +CFLAGS= @CFLAGS@ -Wall LDFLAGS= @LDFLAGS@ LDDFLAGS= @LDDFLAGS@ CPPFLAGS= @CPPFLAGS@ diff -ruN msyslog-v1.01.orig/src/peo/md5.h msyslog-v1.01/src/peo/md5.h --- msyslog-v1.01.orig/src/peo/md5.h Sat Apr 29 02:50:54 2000 +++ msyslog-v1.01/src/peo/md5.h Wed Oct 11 19:52:14 2000 @@ -27,6 +27,8 @@ #ifndef _MD5_H_ #define _MD5_H_ +#include "../conditional.h" + /* MD5 context. */ typedef struct MD5Context { u_int32_t state[4]; /* state (ABCD) */ diff -ruN msyslog-v1.01.orig/src/peo/peochk.c msyslog-v1.01/src/peo/peochk.c --- msyslog-v1.01.orig/src/peo/peochk.c Wed Sep 6 04:42:39 2000 +++ msyslog-v1.01/src/peo/peochk.c Wed Oct 11 22:27:58 2000 @@ -68,7 +68,9 @@ #include #include -#include +#if !((__svr4__ && __sun__) || sgi) +# include +#endif #include #include #include @@ -197,21 +199,29 @@ /* open logfile */ if (actionf & ST_IN) input = STDIN_FILENO; - else if ( (input = open(logfile, O_RDONLY, 0)) == -1) - err(-1, logfile); + else if ( (input = open(logfile, O_RDONLY, 0)) == -1) { + perror (logfile); + exit (-1); + } mfd = 0; /* shutup gcc */ /* open macfile */ if (macfile) - if ( (mfd = open(macfile, O_RDONLY, 0)) == -1) - err(-1, macfile); + if ( (mfd = open(macfile, O_RDONLY, 0)) == -1) { + perror (macfile); + exit (-1); + } /* read initial key (as ascii string) and tranlate it to binary */ - if ( (i = open(key0file, O_RDONLY, 0)) == -1) - err(-1, key0file); - if ( (keylen = read(i, key, 40)) == -1) - err(-1, key0file); + if ( (i = open(key0file, O_RDONLY, 0)) == -1) { + perror (key0file); + exit (-1); + } + if ( (keylen = read(i, key, 40)) == -1) { + perror (key0file); + exit (-1); + } if (!keylen) { if (actionf & QUIET) eexit(1, "1\n"); @@ -224,10 +234,14 @@ close(i); /* read last key */ - if ( (i = open(keyfile, O_RDONLY, 0)) == -1) - err(-1, keyfile); - if ( (lastkeylen = read(i, lastkey, 20)) == -1) - err(-1, keyfile); + if ( (i = open(keyfile, O_RDONLY, 0)) == -1) { + perror (keyfile); + exit (-1); + } + if ( (lastkeylen = read(i, lastkey, 20)) == -1) { + perror (keyfile); + exit (-1); + } if (!lastkeylen) { if (actionf & QUIET) eexit(1, "1\n"); @@ -248,10 +262,14 @@ line = 1; while( (msglen = readline(input, msg, MAXLINE)) > 0) { if (macfile) { - if ( (mkey1len = mac2(key, keylen, msg, msglen, mkey1)) < 0) - err(-1, macfile); - if ( (mkey2len = read(mfd, mkey2, mkey1len)) < 0) - err(-1, macfile); + if ( (mkey1len = mac2(key, keylen, msg, msglen, mkey1)) < 0) { + perror (macfile); + exit (-1); + } + if ( (mkey2len = read(mfd, mkey2, mkey1len)) < 0) { + perror (macfile); + exit (-1); + } if ((mkey2len != mkey1len) || memcmp(mkey2, mkey1, mkey1len)) { if (actionf & QUIET) eexit(1, "%i\n", line); @@ -260,15 +278,19 @@ } line++; } - if ( (keylen = mac(method, key, keylen, msg, msglen, key)) == -1) - err(-1, "fatal"); + if ( (keylen = mac(method, key, keylen, msg, msglen, key)) == -1) { + perror ("fatal"); + exit (-1); + } } if (macfile) close(mfd); - if (i < 0) - errx(-1, "error reading logs form %s", (actionf & ST_IN) ? "standard input" : logfile); + if (i < 0) { + fprintf (stderr, "error reading logs form %s: %s\n", (actionf & ST_IN) ? "standard input" : logfile, strerror (errno)); + exit (-1); + } if (memcmp(lastkey, key, keylen)) { if (actionf & QUIET) @@ -300,21 +322,25 @@ if (getrandom(randvalue, 20) < 0) { release(); - err(-1, "getrandom"); + perror ("getrandom"); + exit (-1); } if ( (keylen = mac(method, NULL, 0, randvalue, 20, key)) == -1) { release(); - err(-1, "fatal"); + perror ("fatal"); + exit (-1); } if ( (kfd = open(keyfile, O_WRONLY|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR)) == -1) { release(); - err(-1, keyfile); + perror (keyfile); + exit (-1); } if ( (k0fd = open(key0file, O_WRONLY|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR)) == -1) { unlink(keyfile); close(kfd); release(); - err(-1, key0file); + perror (key0file); + exit (-1); } /* write key 0 */ @@ -354,7 +380,8 @@ free(logfile); if ( (logfile = strrealpath(optarg)) == NULL) { release(); - err(-1, optarg); + perror (optarg); + exit (-1); } actionf &= ~ST_IN; break; @@ -368,7 +395,8 @@ free(key0file); if ( (key0file = strdup(optarg)) == NULL) { release(); - err(-1, optarg); + perror (optarg); + exit (-1); } break; case 'k': @@ -377,7 +405,8 @@ free(keyfile); if ( (keyfile = strdup(optarg)) == NULL) { release(); - err(-1, optarg); + perror (optarg); + exit (-1); } break; case 'l': @@ -408,7 +437,8 @@ if (argc && (actionf & ST_IN)) if ( (logfile = strrealpath(argv[argc-1])) == NULL) { release(); - err(-1, argv[argc-1]); + perror (argv[argc-1]); + exit (-1); } /* if keyfile was not specified converted logfile is used instead */ @@ -417,13 +447,15 @@ if ( (tmp = strallocat("/var/ssyslog/", logfile)) == NULL) { release(); - err(-1, "buffer for keyfile"); + perror ("buffer for keyfile"); + exit (-1); } strdot(tmp+13); if ( (keyfile = strallocat(tmp, ".key")) == NULL) { free(tmp); release(); - err(-1, "buffer for keyfile"); + perror ("buffer for keyfile"); + exit (-1); } free(tmp); } @@ -432,14 +464,16 @@ if (key0file == NULL) if ( (key0file = strkey0(keyfile)) == NULL) { release(); - err(-1, "creating key0 file"); + perror ("creating key0 file"); + exit (-1); } /* create macfile */ if (mac) if ( (macfile = strmac(keyfile)) == NULL) { release(); - err(-1, "creating mac file"); + perror ("creating mac file"); + exit (-1); } /* execute action */ diff -ruN msyslog-v1.01.orig/src/peo/rmd160.h msyslog-v1.01/src/peo/rmd160.h --- msyslog-v1.01.orig/src/peo/rmd160.h Sat Apr 29 02:50:55 2000 +++ msyslog-v1.01/src/peo/rmd160.h Wed Oct 11 21:48:18 2000 @@ -20,6 +20,8 @@ #ifndef _RMD160_H /* make sure this file is read only once */ #define _RMD160_H +#include "../conditional.h" + /********************************************************************/ /* structure definitions */ diff -ruN msyslog-v1.01.orig/src/peo/sha1.h msyslog-v1.01/src/peo/sha1.h --- msyslog-v1.01.orig/src/peo/sha1.h Sat Apr 29 02:50:56 2000 +++ msyslog-v1.01/src/peo/sha1.h Wed Oct 11 19:52:29 2000 @@ -9,6 +9,8 @@ #ifndef _SHA1_H #define _SHA1_H +#include "../conditional.h" + typedef struct { u_int32_t state[5]; u_int32_t count[2]; diff -ruN msyslog-v1.01.orig/src/syslogd.c msyslog-v1.01/src/syslogd.c --- msyslog-v1.01.orig/src/syslogd.c Thu Sep 21 03:14:32 2000 +++ msyslog-v1.01/src/syslogd.c Fri Oct 27 02:33:00 2000 @@ -86,16 +86,21 @@ #include #include #include -#include +#include +#include +#if !(__svr4__ && __sun__) +# include +#endif +#include #define SYSLOG_NAMES #include +#include "conditional.h" #include "syslogd.h" #ifdef PATH_MAX #define PID_PATH_MAX PATH_MAX #else -#include #ifdef _POSIX_PATH_MAX #define PID_PATH_MAX _POSIX_PATH_MAX #warning Using _POSIX_PATH_MAX as maximum pidfile name length @@ -106,9 +111,19 @@ #ifndef _PATH_CONSOLE #define _PATH_CONSOLE "/dev/console" -#warning Using _PATH_CONSOLE as "/dev/console" +#warning Using "/dev/console" for _PATH_CONSOLE #endif /* _PATH_CONSOLE */ +#ifndef NAME_MAX +# ifdef MAXNAMLEN +# define NAME_MAX MAXNAMLEN +# warning using MAXNAMLEN for NAME_MAX +# else +# define NAME_MAX 255 +# warning using 255 for NAME_MAX +# endif /* MAXNAMLEN */ +#endif /* NAME_MAX */ + /* * Intervals at which we flush out "message repeated" messages, * in seconds after previous message is logged. After each flush, @@ -221,8 +236,28 @@ if (((argc -= optind) != 0) || Inputs.im_fd < 0) usage(); - if (!Debug) - (void)daemon(0, 0); + if (!Debug) { + /* mimic daemon(0,0) behavior */ + pid_t pid; + pid = fork(); + if (pid < 0) { + perror ("fork"); + exit (-1); + } else if (pid > 0) { + /* parent can exit now */ + exit (0); + } + + /* child */ + chdir("/"); + /* these would be disconcerting, but nonfatal, errors */ + if (close (STDIN_FILENO) != 0) + perror ("could not close stdin"); + if (close (STDOUT_FILENO) != 0) + perror ("could not close stdout"); + if (close (STDERR_FILENO) != 0) + perror ("could not close stderr"); + } else setlinebuf(stdout); @@ -274,7 +309,7 @@ } else { snprintf(buf, sizeof(buf), "fcntl lock error " "status %d on %s %d %s", status, - pidfile, lfd, sys_errlist[errno]); + pidfile, lfd, strerror(errno)); logerror(buf); die(0); } @@ -286,7 +321,7 @@ if (errno != 0) { snprintf(buf, sizeof(buf), "Cannot lock %s fd %d " "in %d tries %s", pidfile, lfd, - tries+1, sys_errlist[errno]); + tries+1, strerror(errno)); logerror(buf); /* who is hogging this lock */ @@ -663,6 +698,7 @@ BACKOFF(f); } } + (void)signal(SIGALRM, domark); (void)alarm(TIMERINTVL); } diff -ruN msyslog-v1.01.orig/src/syslogd.h msyslog-v1.01/src/syslogd.h --- msyslog-v1.01.orig/src/syslogd.h Thu Sep 21 03:14:32 2000 +++ msyslog-v1.01/src/syslogd.h Thu Nov 2 03:24:17 2000 @@ -52,6 +52,7 @@ #endif /* HAVE_PATHS_H */ #include #include +#include #include #include @@ -85,6 +86,12 @@ * maximum number of unix sockets */ #define MAXFUNIX 21 + +/* if UT_NAMESIZE doesn't exist, define it as 32 */ +#ifndef UT_NAMESIZE +# define UT_NAMESIZE 32 +# warning Using 32 for UT_NAMESIZE +#endif /* * This structure represents the files that will have log diff -ruN msyslog-v1.01.orig/src/ttymsg.c msyslog-v1.01/src/ttymsg.c --- msyslog-v1.01.orig/src/ttymsg.c Fri Aug 25 04:59:17 2000 +++ msyslog-v1.01/src/ttymsg.c Fri Oct 27 01:42:27 2000 @@ -55,6 +55,12 @@ #include #include #include +#include + +#ifndef _PATH_DEV +# define _PATH_DEV "/dev/" +# warning Using "/dev/" for _PATH_DEV +#endif /* * Display the contents of a uio structure on a terminal. Used by wall(1), @@ -133,6 +139,7 @@ } if (errno == EWOULDBLOCK) { int cpid, off = 0; + sigset_t sig_set; if (forked) { (void) close(fd); @@ -153,7 +160,21 @@ /* wait at most tmout seconds */ (void) signal(SIGALRM, SIG_DFL); (void) signal(SIGTERM, SIG_DFL); /* XXX */ - (void) sigsetmask(0); + + /* replace sigsetmask with sigprocmask */ + sigemptyset(&sig_set); + if (sigprocmask(SIG_SETMASK, &sig_set, NULL) != 0) { + (void) snprintf(errbuf, sizeof(errbuf), + "sigprocmask: %s", strerror(errno)); + (void) close(fd); + return (errbuf); + } else { + (void) snprintf(errbuf, sizeof(errbuf), + "sigprocmask success: %s", strerror(errno)); + (void) close(fd); + return (errbuf); + } + (void) alarm((u_int)tmout); (void) fcntl(fd, O_NONBLOCK, &off); continue;