From: <ph...@us...> - 2003-01-08 16:02:55
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv16770/syslog/src Modified Files: syslogd.c syslogd.h Log Message: INTERNAL_NOPRI value was preventing logging based only on the "warning" priority from occuring. This is because INTERNAL_NOPRI (a macro indicating a given facility should NOT be logged to a particular file) had the same value (16) as the priority value of "warning" (4) when used as an exponent of 2 (2**4 = 16). See 'cfline' function in syslogd.c for details. The fix involves giving INTERNAL_NOPRI a different value (256), and making an appropriate type change (u_char to u_short) to a key variable that stores this value. Index: syslogd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.c,v retrieving revision 1.234 retrieving revision 1.235 diff -u -d -r1.234 -r1.235 --- syslogd.c 7 Jan 2003 21:56:05 -0000 1.234 +++ syslogd.c 8 Jan 2003 16:02:44 -0000 1.235 @@ -1480,39 +1480,34 @@ *bp = '\0'; if (*buf == '*') { + for (i = 0; i <= LOG_NFACILITIES; i++) { + if (pri == INTERNAL_NOPRI) { - if (ignorepri) - f->f_pmask[i] = - TABLE_ALLPRI; - else - f->f_pmask[i] = - TABLE_NOPRI; + + if (ignorepri) f->f_pmask[i] = TABLE_ALLPRI; + else f->f_pmask[i] = TABLE_NOPRI; + } else if (singlpri) { - if (ignorepri) - f->f_pmask[i] &= - ~(1<<pri); - else - f->f_pmask[i] |= - (1<<pri); + + if (ignorepri) f->f_pmask[i] &= ~(1<<pri); + else f->f_pmask[i] |= (1<<pri); + } else { + if (pri == TABLE_ALLPRI) { - if (ignorepri) - f->f_pmask[i] = - TABLE_NOPRI; - else - f->f_pmask[i] = - TABLE_ALLPRI; + + if (ignorepri) f->f_pmask[i] = TABLE_NOPRI; + else f->f_pmask[i] = TABLE_ALLPRI; + } else { - if (ignorepri) - for (j = 0; j <= pri; ++j) - f->f_pmask[i] &= ~(1<<j); - else - for (j= 0; j <= pri; ++j) - f->f_pmask[i] |= (1<<j); + + if (ignorepri) for (j = 0; j <= pri; ++j) f->f_pmask[i] &= ~(1<<j); + else for (j = 0; j <= pri; ++j) f->f_pmask[i] |= (1<<j); } } } + } else { i = decode(buf, facilitynames); @@ -1524,44 +1519,32 @@ } if (pri == INTERNAL_NOPRI) { - if (ignorepri) - f->f_pmask[i >> 3] = - TABLE_ALLPRI; - else - f->f_pmask[i >> 3] = - TABLE_NOPRI; + + if (ignorepri) f->f_pmask[i >> 3] = TABLE_ALLPRI; + else f->f_pmask[i >> 3] = TABLE_NOPRI; + } else if (singlpri) { - if (ignorepri) - f->f_pmask[i >> 3] &= - ~(1<<pri); - else - f->f_pmask[i >> 3] |= - (1<<pri); + + if (ignorepri) f->f_pmask[i >> 3] &= ~(1<<pri); + else f->f_pmask[i >> 3] |= (1<<pri); + } else { + if (pri == TABLE_ALLPRI) { - if (ignorepri) - f->f_pmask[i >> 3] = - TABLE_NOPRI; - else - f->f_pmask[i >> 3] = - TABLE_ALLPRI; + + if (ignorepri) f->f_pmask[i >> 3] = TABLE_NOPRI; + else f->f_pmask[i >> 3] = TABLE_ALLPRI; + } else { - if (ignorepri) - for (j = 0; j <= pri; - ++j) - f->f_pmask[i>>3] - &= ~(1<<j); - else - for (j= 0; j <= pri; - ++j) - f->f_pmask[i>>3] - |= (1<<j); + + if (ignorepri) for (j = 0; j <= pri; ++j) f->f_pmask[i>>3] &= ~(1<<j); + else for (j = 0; j <= pri; ++j) f->f_pmask[i>>3] |= (1<<j); + } } } - while (*p == ',' || *p == ' ') - p++; + while (*p == ',' || *p == ' ') ++p; } p = q; Index: syslogd.h =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.h,v retrieving revision 1.111 retrieving revision 1.112 diff -u -d -r1.111 -r1.112 --- syslogd.h 17 Sep 2002 05:20:26 -0000 1.111 +++ syslogd.h 8 Jan 2003 16:02:48 -0000 1.112 @@ -137,7 +137,7 @@ struct filed { struct filed *f_next; /* next in linked list */ time_t f_time; /* time this was last written */ - u_char f_pmask[LOG_NFACILITIES+1]; /* priority mask */ + u_short f_pmask[LOG_NFACILITIES+1]; /* priority mask */ char *f_program; /* program this applies to */ struct tm f_tm; /* date of message */ char f_prevline[MAXSVLINE]; /* last message logged */ @@ -212,6 +212,11 @@ * some systems lack those, so we define them here */ +#ifdef INTERNAL_NOPRI +#undef INTERNAL_NOPRI +#endif +#define INTERNAL_NOPRI 0x100 + #ifndef HAVE_CODE # ifdef SYSLOG_NAMES @@ -235,7 +240,6 @@ # define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) # endif -# define INTERNAL_NOPRI 0x10 # define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0) @@ -291,4 +295,4 @@ -#endif +#endif /* HAVE_CODE */ |