From: Dave Hart Date: Tue, 9 Aug 2011 04:27:25 +0000 (+0000) Subject: [Bug 1985] "logconfig =allall" rejected. X-Git-Tag: NTP_4_2_7P202~3^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a5f3e2926b2a1d0a7dd1a82b3985b990540f90a;p=thirdparty%2Fntp.git [Bug 1985] "logconfig =allall" rejected. bk: 4e40b72ddYXzBZEiK1DOChgECQEdzQ --- diff --git a/ChangeLog b/ChangeLog index 8aafff842..bf046154f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ --- * [Bug 1984] ntp/libisc fails to compile on OS X 10.7 (Lion). +* [Bug 1985] "logconfig =allall" rejected. * [Backward Incompatible] sntp: -l/--filelog -> -l/--logfile, to be consistent with ntpd. * libopts/file.c fix from Bruce Korb (arg-type=file). diff --git a/include/ntp_syslog.h b/include/ntp_syslog.h index e8443ec7c..12f78292b 100644 --- a/include/ntp_syslog.h +++ b/include/ntp_syslog.h @@ -5,6 +5,8 @@ #ifndef NTP_SYSLOG_H #define NTP_SYSLOG_H +#include /* u_int32 type */ + # ifdef VMS extern void msyslog(); # else @@ -39,34 +41,34 @@ extern FILE *syslog_file; /* if syslogit is FALSE, log to #define NLOG_STATIST 0x00000008 #define NLOG_OSYS 0 /* offset for system flags */ -#define NLOG_SYSMASK 0x0000000F /* system log events */ +#define NLOG_SYSMASK 0x0000000F /* system log events */ #define NLOG_SYSINFO 0x00000001 /* system info log events */ #define NLOG_SYSEVENT 0x00000002 /* system events */ #define NLOG_SYSSTATUS 0x00000004 /* system status (sync/unsync) */ #define NLOG_SYSSTATIST 0x00000008 /* system statistics output */ #define NLOG_OPEER 4 /* offset for peer flags */ -#define NLOG_PEERMASK 0x000000F0 /* peer log events */ +#define NLOG_PEERMASK 0x000000F0 /* peer log events */ #define NLOG_PEERINFO 0x00000010 /* peer info log events */ #define NLOG_PEEREVENT 0x00000020 /* peer events */ #define NLOG_PEERSTATUS 0x00000040 /* peer status (sync/unsync) */ #define NLOG_PEERSTATIST 0x00000080 /* peer statistics output */ #define NLOG_OCLOCK 8 /* offset for clock flags */ -#define NLOG_CLOCKMASK 0x00000F00 /* clock log events */ +#define NLOG_CLOCKMASK 0x00000F00 /* clock log events */ #define NLOG_CLOCKINFO 0x00000100 /* clock info log events */ #define NLOG_CLOCKEVENT 0x00000200 /* clock events */ #define NLOG_CLOCKSTATUS 0x00000400 /* clock status (sync/unsync) */ #define NLOG_CLOCKSTATIST 0x00000800 /* clock statistics output */ #define NLOG_OSYNC 12 /* offset for sync flags */ -#define NLOG_SYNCMASK 0x0000F000 /* sync log events */ +#define NLOG_SYNCMASK 0x0000F000 /* sync log events */ #define NLOG_SYNCINFO 0x00001000 /* sync info log events */ #define NLOG_SYNCEVENT 0x00002000 /* sync events */ #define NLOG_SYNCSTATUS 0x00004000 /* sync status (sync/unsync) */ #define NLOG_SYNCSTATIST 0x00008000 /* sync statistics output */ -extern unsigned long ntp_syslogmask; +extern u_int32 ntp_syslogmask; #define NLOG(_X_) if (ntp_syslogmask & (_X_)) #endif /* NTP_SYSLOG_H */ diff --git a/include/ntpd.h b/include/ntpd.h index 16c559350..1ee0e52bd 100644 --- a/include/ntpd.h +++ b/include/ntpd.h @@ -2,10 +2,9 @@ * ntpd.h - Prototypes for ntpd. */ -#include "ntp_syslog.h" -#include "ntp_fp.h" #include "ntp.h" #include "ntp_debug.h" +#include "ntp_syslog.h" #include "ntp_select.h" #include "ntp_malloc.h" #include "ntp_refclock.h" diff --git a/libntp/machines.c b/libntp/machines.c index 450138047..7b3201d42 100644 --- a/libntp/machines.c +++ b/libntp/machines.c @@ -8,6 +8,7 @@ #include "config.h" #endif +#include "ntp.h" #include "ntp_machine.h" #include "ntp_syslog.h" #include "ntp_stdlib.h" diff --git a/libntp/msyslog.c b/libntp/msyslog.c index ebfdd4b9f..60f8a1309 100644 --- a/libntp/msyslog.c +++ b/libntp/msyslog.c @@ -29,7 +29,7 @@ int syslogit = 1; int msyslog_term = FALSE; /* duplicate to stdout/err */ FILE * syslog_file; -u_long ntp_syslogmask = ~(u_long)0; /* libntp default is all lit */ +u_int32 ntp_syslogmask = ~(u_int32)0; /* libntp default is all lit */ extern char * progname; diff --git a/ntpd/complete.conf b/ntpd/complete.conf index e69140f59..5a390c4d9 100644 --- a/ntpd/complete.conf +++ b/ntpd/complete.conf @@ -1,7 +1,7 @@ saveconfigdir "/etc/ntp/conf" driftfile "/etc/ntp.drift" logfile "/var/log/ntp.log" -logconfig =all -allinfo -allevents -allstatistics -allstatus +allall -clockinfo -clockevents -clockstatistics -clockstatus +clockall -syncinfo -syncevents -syncstatistics -syncstatus +syncall -sysinfo -sysevents -sysstatistics -sysstatus +sysall +logconfig =allall -allinfo -allevents -allstatistics -allstatus +allall -clockinfo -clockevents -clockstatistics -clockstatus +clockall -syncinfo -syncevents -syncstatistics -syncstatus +syncall -sysinfo -sysevents -sysstatistics -sysstatus +sysall statsdir "/etc/ntp/stats" statistics loopstats peerstats filegen clockstats file clockstats type none enable diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index 981728938..4bd0e73a5 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -76,33 +76,41 @@ int resolver_pipe_fd[2]; /* used to let the resolver process alert the parent p * "logconfig" building blocks */ struct masks { - const char *name; - unsigned long mask; + const char * const name; + const u_int32 mask; }; static struct masks logcfg_class[] = { - { "clock", NLOG_OCLOCK }, - { "peer", NLOG_OPEER }, - { "sync", NLOG_OSYNC }, - { "sys", NLOG_OSYS }, - { (char *)0, 0 } + { "clock", NLOG_OCLOCK }, + { "peer", NLOG_OPEER }, + { "sync", NLOG_OSYNC }, + { "sys", NLOG_OSYS }, + { NULL, 0 } }; -static struct masks logcfg_item[] = { +/* logcfg_noclass_items[] masks are complete and must not be shifted */ +static struct masks logcfg_noclass_items[] = { + { "allall", NLOG_SYSMASK | NLOG_PEERMASK | NLOG_CLOCKMASK | NLOG_SYNCMASK }, + { "allinfo", NLOG_SYSINFO | NLOG_PEERINFO | NLOG_CLOCKINFO | NLOG_SYNCINFO }, + { "allevents", NLOG_SYSEVENT | NLOG_PEEREVENT | NLOG_CLOCKEVENT | NLOG_SYNCEVENT }, + { "allstatus", NLOG_SYSSTATUS | NLOG_PEERSTATUS | NLOG_CLOCKSTATUS | NLOG_SYNCSTATUS }, + { "allstatistics", NLOG_SYSSTATIST | NLOG_PEERSTATIST | NLOG_CLOCKSTATIST | NLOG_SYNCSTATIST }, + /* the remainder are misspellings of clockall, peerall, sysall, and syncall. */ + { "allclock", (NLOG_INFO | NLOG_STATIST | NLOG_EVENT | NLOG_STATUS) << NLOG_OCLOCK }, + { "allpeer", (NLOG_INFO | NLOG_STATIST | NLOG_EVENT | NLOG_STATUS) << NLOG_OPEER }, + { "allsys", (NLOG_INFO | NLOG_STATIST | NLOG_EVENT | NLOG_STATUS) << NLOG_OSYS }, + { "allsync", (NLOG_INFO | NLOG_STATIST | NLOG_EVENT | NLOG_STATUS) << NLOG_OSYNC }, + { NULL, 0 } +}; + +/* logcfg_class_items[] masks are shiftable by NLOG_O* counts */ +static struct masks logcfg_class_items[] = { + { "all", NLOG_INFO | NLOG_EVENT | NLOG_STATUS | NLOG_STATIST }, { "info", NLOG_INFO }, - { "allinfo", NLOG_SYSINFO|NLOG_PEERINFO|NLOG_CLOCKINFO|NLOG_SYNCINFO }, { "events", NLOG_EVENT }, - { "allevents", NLOG_SYSEVENT|NLOG_PEEREVENT|NLOG_CLOCKEVENT|NLOG_SYNCEVENT }, { "status", NLOG_STATUS }, - { "allstatus", NLOG_SYSSTATUS|NLOG_PEERSTATUS|NLOG_CLOCKSTATUS|NLOG_SYNCSTATUS }, { "statistics", NLOG_STATIST }, - { "allstatistics", NLOG_SYSSTATIST|NLOG_PEERSTATIST|NLOG_CLOCKSTATIST|NLOG_SYNCSTATIST }, - { "allclock", (NLOG_INFO|NLOG_STATIST|NLOG_EVENT|NLOG_STATUS)<name) { - if (strncmp(*s, m->name, strlen(m->name)) == 0) { - *s += strlen(m->name); + while (m->name != NULL) { + if (strncmp(*pstr, m->name, strlen(m->name)) == 0) { + *pstr += strlen(m->name); return m->mask; } else { m++; @@ -4045,14 +4053,14 @@ get_pfxmatch( /* * get_match - find logmask value */ -static unsigned long +static u_int32 get_match( - char *s, - struct masks *m + const char * str, + struct masks * m ) { - while (m->name) { - if (strcmp(s, m->name) == 0) + while (m->name != NULL) { + if (strcmp(str, m->name) == 0) return m->mask; else m++; @@ -4063,23 +4071,28 @@ get_match( /* * get_logmask - build bitmask for ntp_syslogmask */ -static unsigned long +static u_int32 get_logmask( - char *s + const char * str ) { - char *t; - unsigned long offset; - unsigned long mask; + const char * t; + u_int32 offset; + u_int32 mask; + + mask = get_match(str, logcfg_noclass_items); + if (mask != 0) + return mask; - t = s; + t = str; offset = get_pfxmatch(&t, logcfg_class); - mask = get_match(t, logcfg_item); + mask = get_match(t, logcfg_class_items); if (mask) return mask << offset; else - msyslog(LOG_ERR, "logconfig: illegal argument %s - ignored", s); + msyslog(LOG_ERR, "logconfig: '%s' not recognized - ignored", + str); return 0; }