--- syslogd.c.orig Fri Oct 26 17:58:02 2001 +++ syslogd.c Fri Oct 26 17:59:56 2001 @@ -487,7 +487,6 @@ #include #include -#include #include #include #include @@ -574,10 +573,17 @@ #define MAXUNAMES 20 /* maximum number of user names */ #define MAXFNAME 200 /* max file pathname length */ -#define INTERNAL_NOPRI 0x10 /* the "no priority" priority */ #define TABLE_NOPRI 0 /* Value to indicate no priority in f_pmask */ #define TABLE_ALLPRI 0xFF /* Value to indicate all priorities in f_pmask */ -#define LOG_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0) /* mark "facility" */ +#ifndef LOG_MAKEPRI +#define LOG_MAKEPRI(f,p) (((f) << 3) + (p)) +#endif +#ifndef LOG_FAC +#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) +#endif +#ifndef LOG_PRI +#define LOG_PRI(p) ((p) & LOG_PRIMASK) +#endif /* * Flags to logmsg(). @@ -670,12 +676,21 @@ struct filed *Files = (struct filed *) 0; struct filed consfile; -struct code { +/* Some syslog.h's define this stuff for us (BSD, glibc), some + don't. Try to cope with 'em all. +*/ + +#ifndef INTERNAL_MARK + +#define INTERNAL_NOPRI 0x10 /* the "no priority" priority */ +#define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0) /* mark "facility" */ + +typedef struct code { char *c_name; int c_val; -}; +} CODE; -struct code PriNames[] = { +CODE prioritynames[] = { {"alert", LOG_ALERT}, {"crit", LOG_CRIT}, {"debug", LOG_DEBUG}, @@ -692,15 +707,17 @@ {NULL, -1} }; -struct code FacNames[] = { +CODE facilitynames[] = { {"auth", LOG_AUTH}, +#ifdef LOG_AUTHPRIV {"authpriv", LOG_AUTHPRIV}, +#endif {"cron", LOG_CRON}, {"daemon", LOG_DAEMON}, {"kern", LOG_KERN}, {"lpr", LOG_LPR}, {"mail", LOG_MAIL}, - {"mark", LOG_MARK}, /* INTERNAL */ + {"mark", INTERNAL_MARK}, /* INTERNAL */ {"news", LOG_NEWS}, {"security", LOG_AUTH}, /* DEPRECATED */ {"syslog", LOG_SYSLOG}, @@ -720,6 +737,8 @@ {NULL, -1}, }; +#endif + int Debug; /* debug flag */ char LocalHostName[MAXHOSTNAMELEN+1]; /* our hostname */ char *LocalDomain; /* our local domain name */ @@ -761,7 +780,7 @@ #endif void init(); void cfline(char *line, register struct filed *f); -int decode(char *name, struct code *codetab); +int decode(char *name, CODE *codetab); #if defined(__GLIBC__) #define dprintf mydprintf #endif /* __GLIBC__ */ @@ -1235,12 +1254,14 @@ /* We need to enable BSD compatibility. Otherwise an attacker * could flood our log files by sending us tons of ICMP errors. */ +#ifdef SO_BSDCOMPAT if (setsockopt(fd, SOL_SOCKET, SO_BSDCOMPAT, \ (char *) &on, sizeof(on)) < 0) { logerror("setsockopt(BSDCOMPAT), suspending inet"); close(fd); return -1; } +#endif if (bind(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0) { logerror("bind, suspending inet"); close(fd); @@ -2496,11 +2517,11 @@ if ( *buf == '=' ) { singlpri = 1; - pri = decode(&buf[1], PriNames); + pri = decode(&buf[1], prioritynames); } else { singlpri = 0; - pri = decode(buf, PriNames); + pri = decode(buf, prioritynames); } if (pri < 0) { @@ -2548,7 +2569,7 @@ } } } else { - i = decode(buf, FacNames); + i = decode(buf, facilitynames); if (i < 0) { (void) snprintf(xbuf, sizeof(xbuf), "unknown facility name \"%s\"", buf); @@ -2691,9 +2712,9 @@ int decode(name, codetab) char *name; - struct code *codetab; + CODE *codetab; { - register struct code *c; + register CODE *c; register char *p; char buf[80];