bug-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-inetutils] bug with patch:syslogd doesn't process messages properl


From: Peter Rehley
Subject: [bug-inetutils] bug with patch:syslogd doesn't process messages properly as specified in syslog.conf
Date: Mon, 10 Feb 2003 12:53:23 -0800

Hello,

I was trying syslogd in inetutils version 1.4.1 and 1.4.2 and I noticed that
certain entiries in the syslog.conf file are handled incorrectly.
Specifically, the none option, only option and range options don't work. For
example if I had the following entries in syslog.conf:

*.*;local0.none /var/log/system.log

Should put all messages except local0 messages into the system.log file, but
the current program is putting all messages into that file.

Also:
local0.=debug   /var/log/debugonly

Should put local0 debug messages into the debug only file, but the warning
message also appears for these cases.

And finally:
local0.info;local0.!warning     /var/log/info2notice

Should put only messages types starting at info and ending at notice in the
file, but they start at debug and end at  notice.

I've traced the problem and I'm listing changes against the latest version of
syslogd.c

diff -durpN 1.4.2/syslogd.c new/syslogd.c
--- 1.4.2/syslogd.c     Wed Dec 11 04:38:00 2002
+++ new/syslogd.c       Mon Jan 27 16:12:56 2003
@@ -1120,7 +1120,7 @@ logmsg (int pri, const char *msg, const
     {
       /* Skip messages that are incorrect priority. */
       if (!(f->f_pmask[fac] & LOG_MASK (prilev)) ||
-         f->f_pmask[fac] == INTERNAL_NOPRI)
+         f->f_pmask[fac] & LOG_MASK(INTERNAL_NOPRI))
        continue;

       if (f->f_type == F_CONSOLE && (flags & IGN_CONS))
@@ -1762,7 +1762,7 @@ init (int signo)
        {
          int i;
          for (i = 0; i <= LOG_NFACILITIES; i++)
-           if (f->f_pmask[i] == INTERNAL_NOPRI)
+           if (f->f_pmask[i] == 0)
              dbg_printf(" X ");
            else
              dbg_printf("%2x ", f->f_pmask[i]);
@@ -1820,7 +1820,7 @@ cfline (const char *line, struct filed *
   memset (f, 0, sizeof (*f));
   for (i = 0; i <= LOG_NFACILITIES; i++)
     {
-      f->f_pmask[i] = INTERNAL_NOPRI;
+      f->f_pmask[i] = LOG_MASK(INTERNAL_NOPRI);
       f->f_flags = 0;
     }

@@ -1858,7 +1858,7 @@ cfline (const char *line, struct filed *
       /* Decode priority name and set up bit masks.  */
       if (*bp == '*')
        {
-         pri_clear = INTERNAL_NOPRI;
+         pri_clear = LOG_MASK(INTERNAL_NOPRI);
          pri_set = LOG_UPTO (LOG_PRIMASK);
        }
       else
@@ -1871,8 +1871,16 @@ cfline (const char *line, struct filed *
              logerror (ebuf);
              return;
            }
-         pri_clear = 0;
-         pri_set = excl_pri ? LOG_MASK (pri) : LOG_UPTO (pri);
+         if (pri == INTERNAL_NOPRI)
+           {
+             pri_clear = 255;
+             pri_set = 0;
+           }
+         else
+           {
+             pri_clear = 0;
+             pri_set = excl_pri ? LOG_MASK (pri) : LOG_UPTO (pri);
+           }
        }
       if (negate_pri)
        {


Here is also the test syslog.conf file that I was using:

##############################
# Log everything to system log except some local messages
*.*;local0,local1.none  /var/log/system.log

# Log only debug messages
local0,local1.debug;local0,local1.!info /var/log/log.debug2debug

# Log debug to notice messages
local0,local1.debug;local0,local1.!warning      /var/log/log.debug2notice

# Log info to notice messages
local0,local1.info;local0,local1.!warning       /var/log/log.info2notice

# Log error to critical messages
local0,local1.error;local0,local1.!alert        /var/log/log.error2critical

# Log debug and higher
local0,local1.debug     /var/log/log.debug

# Log info and higher to prwn.log
local0,local1.info      /var/log/log.log

# Log warning and higher
local0,local1.warning   /var/log/log.warning

# Log error and higher
local0,local1.error     /var/log/log.error

# Log only the listed messages
local0,local1.=debug    /var/log/log.debugonly
local0,local1.=info     /var/log/log.infoonly
local0,local1.=notice   /var/log/log.noticeonly
local0,local1.=warning  /var/log/log.warningonly
local0,local1.=error    /var/log/log.erroronly
local0,local1.=crit     /var/log/log.criticalonly
local0,local1.=alert    /var/log/log.alertonly
#####################################

Here is a perl script that I used to send messages to syslogd. This requires the Sys::Syslog.pm module. This should already be installed for most perl
distributions.

#####
use Sys::Syslog;
use Sys::Syslog qw(:DEFAULT setlogsock);

setlogsock('unix');
#setlogsock('inet');
openlog("SysSys","cons,pid,ndelay","local0");
syslog("debug","Debug Message");
syslog("info","Info Message");
syslog("notice","Notice Message");
syslog("warning","Warning Message");
syslog("err","Error Message");
syslog("crit","Critical Message");
syslog("alert","Alert Message");
closelog();

exit(0);
#####

Thanks,
Peter Rehley


=====

Infinity Softworks. Making scientific, financial and realtor calculators for Palm Pilots and other PDAs since 1997

Visit them today at http://www.infinitysw.com





reply via email to

[Prev in Thread] Current Thread [Next in Thread]