]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1985] "logconfig =allall" rejected.
authorDave Hart <hart@ntp.org>
Tue, 9 Aug 2011 04:27:25 +0000 (04:27 +0000)
committerDave Hart <hart@ntp.org>
Tue, 9 Aug 2011 04:27:25 +0000 (04:27 +0000)
bk: 4e40b72ddYXzBZEiK1DOChgECQEdzQ

ChangeLog
include/ntp_syslog.h
include/ntpd.h
libntp/machines.c
libntp/msyslog.c
ntpd/complete.conf
ntpd/ntp_config.c

index 8aafff842917e63a8dac4d6f184e86a754501d19..bf046154f2351f9097faffb639d4f56b1b03c9e8 100644 (file)
--- 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).
index e8443ec7c15042e7b8cb25b096ce751b6d4cc4d7..12f78292b1eab2de5874f59590b8e29cdd73f604 100644 (file)
@@ -5,6 +5,8 @@
 #ifndef NTP_SYSLOG_H
 #define NTP_SYSLOG_H
 
+#include <ntp_types.h>         /* 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 */
index 16c559350179073110385dc8738244dc5045e08c..1ee0e52bdab17783e75287b817cf8e2aa963096a 100644 (file)
@@ -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"
index 450138047db63c0361d9d156ac53775b28c51f1a..7b3201d4203e478be44b29aee41c2d82ddc80ed9 100644 (file)
@@ -8,6 +8,7 @@
 #include "config.h"
 #endif
 
+#include "ntp.h"
 #include "ntp_machine.h"
 #include "ntp_syslog.h"
 #include "ntp_stdlib.h"
index ebfdd4b9f15e83ccb3d2ec8045adb54d917cb675..60f8a1309e86c352becabe32022bef7aa4039d1b 100644 (file)
@@ -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;
 
index e69140f597556ec767510fcbdb8367d10c1b3443..5a390c4d90f7da7d662f37023f24c3bc082049c4 100644 (file)
@@ -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
index 981728938e243118211645b73b356ae6e4b67ee0..4bd0e73a553bd478f666dba6933fd1e3c7bd08d4 100644 (file)
@@ -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)<<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 },
-       { "all",                NLOG_SYSMASK|NLOG_PEERMASK|NLOG_CLOCKMASK|NLOG_SYNCMASK },
-       { (char *)0,    0 }
+       { NULL,                 0 }
 };
 
 /* Limits */
@@ -303,9 +311,9 @@ do {                                        \
 } while (0)
 
 void ntpd_set_tod_using(const char *);
-static unsigned long get_pfxmatch(char **s,struct masks *m);
-static unsigned long get_match(char *s,struct masks *m);
-static unsigned long get_logmask(char *s);
+static u_int32 get_pfxmatch(const char **, struct masks *);
+static u_int32 get_match(const char *, struct masks *);
+static u_int32 get_logmask(const char *);
 static int getnetnum(const char *num,sockaddr_u *addr, int complain,
                     enum gnn_type a_type);
 static int get_multiple_netnums(const char *num, sockaddr_u *addr,
@@ -4025,15 +4033,15 @@ ntpd_set_tod_using(
  * get_pfxmatch - find value for prefixmatch
  * and update char * accordingly
  */
-static unsigned long
+static u_int32
 get_pfxmatch(
-       char ** s,
-       struct masks *m
+       const char **   pstr,
+       struct masks *  m
        )
 {
-       while (m->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;
 }