OSSP CVS Repository

ossp - Check-in [2341]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 2341
Date: 2002-Jul-24 17:29:01 (local)
2002-Jul-24 15:29:01 (UTC)
User:thl
Branch:
Comment: added solaris and linux compatiblity; improved readability of traces
Tickets:
Inspections:
Files:
ossp-pkg/fsl/configure.ac      1.5 -> 1.6     2 inserted, 2 deleted
ossp-pkg/fsl/fsl.c      1.20 -> 1.21     43 inserted, 27 deleted
ossp-pkg/fsl/fsl_test.c      1.3 -> 1.4     1 inserted, 1 deleted

ossp-pkg/fsl/configure.ac 1.5 -> 1.6

--- configure.ac 2002/07/24 14:55:55     1.5
+++ configure.ac 2002/07/24 15:29:01     1.6
@@ -102,9 +102,9 @@
 
 AC_MSG_CHECKING(for debugging using a l2spec)
 AC_ARG_WITH(debug,dnl
-[  --with-debug=L2SPEC      set debugging using a l2spec (default="")],
+[  --with-debug=L2SPEC     set debugging using a l2spec (default="")],
 [ fsl_debug=$withval ],
-[ fsl_debug="" ]
+[ fsl_debug="null()" ]
 )dnl
 AC_DEFINE_UNQUOTED(FSL_DEBUG,  "$fsl_debug",  [Define debugging using a l2spec])
 AC_MSG_RESULT([$fsl_debug])


ossp-pkg/fsl/fsl.c 1.20 -> 1.21

--- fsl.c        2002/07/24 09:45:12     1.20
+++ fsl.c        2002/07/24 15:29:01     1.21
@@ -41,7 +41,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <dirent.h>
-#include <syslimits.h>
 
 /* standard include we re-implement */
 #include <syslog.h>
@@ -51,11 +50,6 @@
 #include "cfg.h"
 #include "pcre.h"
 
-/* default for the dedicated logfile */
-#ifndef LOGFILE
-#define LOGFILE "/tmp/syslog"
-#endif
-
 #ifndef LOG_PRIMASK
 #define LOG_PRIMASK (LOG_EMERG|LOG_ALERT|LOG_CRIT|LOG_ERR|LOG_WARNING|LOG_NOTICE|LOG_INFO|LOG_DEBUG)
 #endif
@@ -100,19 +94,18 @@
     char *string;
 } syslogfacility2string[] = {
     { LOG_AUTH,     "auth"     },
+#ifdef LOG_AUTHPRIV
     { LOG_AUTHPRIV, "authpriv" },
+#endif
+#ifdef LOG_CONSOLE
     { LOG_CONSOLE,  "console"  },
+#endif
     { LOG_CRON,     "cron"     },
     { LOG_DAEMON,   "daemon"   },
+#ifdef LOG_FTP
     { LOG_FTP,      "ftp"      },
+#endif
     { LOG_KERN,     "kern"     },
-    { LOG_LPR,      "lpr"      },
-    { LOG_MAIL,     "mail"     },
-    { LOG_NEWS,     "news"     },
-    { LOG_SECURITY, "security" },
-    { LOG_SYSLOG,   "syslog"   },
-    { LOG_USER,     "user"     },
-    { LOG_UUCP,     "uucp"     },
     { LOG_LOCAL0,   "local0"   },
     { LOG_LOCAL1,   "local1"   },
     { LOG_LOCAL2,   "local2"   },
@@ -121,7 +114,19 @@
     { LOG_LOCAL5,   "local5"   },
     { LOG_LOCAL6,   "local6"   },
     { LOG_LOCAL7,   "local7"   },
-    { 0,            NULL       }
+    { LOG_LPR,      "lpr"      },
+    { LOG_MAIL,     "mail"     },
+    { LOG_NEWS,     "news"     },
+#ifdef LOG_NTP
+    { LOG_NTP,      "ntp"      },
+#endif
+#ifdef LOG_SECURITY
+    { LOG_SECURITY, "security" },
+#endif
+    { LOG_SYSLOG,   "syslog"   },
+    { LOG_USER,     "user"     },
+    { LOG_UUCP,     "uucp"     },
+    { -1,            NULL      }
 };
 
 static struct {
@@ -137,7 +142,7 @@
     { "notice",  LOG_NOTICE,  L2_LEVEL_NOTICE   },
     { "info",    LOG_INFO,    L2_LEVEL_INFO     },
     { "debug",   LOG_DEBUG,   L2_LEVEL_DEBUG    },
-    { NULL,      0,           0                 }
+    { NULL,      -1,          -1                }
 };
 
 static struct {
@@ -153,7 +158,7 @@
     { "info",     L2_LEVEL_INFO,      },
     { "trace",    L2_LEVEL_TRACE,     },
     { "debug",    L2_LEVEL_DEBUG,     },
-    { NULL,       0                   }
+    { NULL,       -1                  }
 };
 typedef struct {
     int        syslog;
@@ -184,6 +189,8 @@
     va_start(args, message);
     if (ctx.l2_fslnch != NULL)
         l2_channel_vlog(ctx.l2_fslnch, level, message, args);
+    else
+        vfprintf(stderr, message, args);
     va_end(args);
     return;
 }
@@ -337,7 +344,7 @@
             cp = l2_env_strerror(ctx.l2_fslenv, l2rv); fsldebug(L2_LEVEL_ERROR, "logging failed to link child channel %s(%d) for fsl\n", cp, l2rv); CU(1); }
         if ((l2rv = l2_channel_open(ctx.l2_fslnch)) != L2_OK) {
             cp = l2_env_strerror(ctx.l2_fslenv, l2rv); fsldebug(L2_LEVEL_ERROR, "logging failed to open channel stream %s(%d) for fsl\n", cp, l2rv); CU(1); }
-        fsldebug(L2_LEVEL_TRACE, "captured openlog(%s, 0x%.8lx, 0x%.8lx)", ident, logopt, facility);
+        fsldebug(L2_LEVEL_TRACE, "captured openlog(ident=\"%s\", logopt=0x%.8lx, facility=0x%.8lx)", ident, logopt, facility);
     }
 
     /*FIXME currently we completely ignore logopt LOG_CONS, LOG_NDELAY, LOG_PERROR, LOG_PID
@@ -388,7 +395,7 @@
     strcat(cpISF, cpFacility);
 
     if ((rv = readfileorallfiles(&buf, ident)) != FSL_OK) {
-        fsldebug(L2_LEVEL_ERROR, "readfileorallfiles(buf, %s) returned %d, system %s(%d)\n", ident, rv, strerror(errno), errno); CU(1); }
+        fsldebug(L2_LEVEL_ERROR, "readfileorallfiles(buf, \"%s\") returned %d, system error: %s(%d)\n", ident, rv, strerror(errno), errno); CU(1); }
 
     if ((cfgrv = cfg_create(&cfg)) != CFG_OK) {
         (void)cfg_error(cfg, cfgrv, &cp); fsldebug(L2_LEVEL_ERROR, "cfg_create() failed with error %s (%d)\n", cp, cfgrv); CU(1); }
@@ -488,7 +495,7 @@
                     fsldebug(L2_LEVEL_ERROR, "pcre_study() failed with error %s\n", cpError); CU(1); }
 
                 nMatch = pcre_exec(pcreRegex, pcreExtra, cpISF, strlen(cpISF), 0, 0, ovec, OVECSIZE);
-                fsldebug(L2_LEVEL_TRACE, "nMatch=%d when \"%s\" is used against \"%s\"\n", nMatch, argmatch, cpISF);
+                fsldebug(L2_LEVEL_TRACE, "found %2d matches when \"%s\" is used against \"%s\"\n", nMatch, argmatch, cpISF);
                 if (nMatch >= 1) {
                     pcre_get_substring_list(cpISF, ovec, nMatch, &acpMatch);
                     if (acpMatch != NULL)
@@ -594,7 +601,7 @@
     int oldmask;
 
     if (ctx.l2_fslnch != NULL)
-        l2_channel_log(ctx.l2_fslnch, L2_LEVEL_TRACE, "captured setlogmask(0x%.8lx)", maskpri);
+        l2_channel_log(ctx.l2_fslnch, L2_LEVEL_TRACE, "captured setlogmask(maskpri=0x%.8lx)", maskpri);
 
     oldmask = ctx.maskpri;
 
@@ -659,6 +666,10 @@
 {
     fsl_rc_t rv;
 
+    if (ident == NULL)
+        return FSL_ERR_ARG;
+    fsldebug(L2_LEVEL_TRACE, "readfileorallfiles(buffer, ident=\"%s\")\n", ident);
+
     if ((rv = readfile(buffer, ident)) == FSL_OK)
         return FSL_OK;
 
@@ -678,6 +689,7 @@
 
     if (ident == NULL || buffer == NULL)
         CU(FSL_ERR_ARG);
+    fsldebug(L2_LEVEL_TRACE, "readfile(buffer, ident=\"%s\")\n", ident);
 
     if ((filename = (char *)malloc(strlen(FSL_CFGDIR) + 1 + strlen(FSL_PREFIX) + strlen(ident) + 1)) == NULL)
         CU(FSL_ERR_MEM);
@@ -700,31 +712,35 @@
     DIR *dp;
     struct dirent *de;
     char *filename = NULL;
+    int n;
 
     if (buffer == NULL)
         CU(FSL_ERR_ARG);
+    fsldebug(L2_LEVEL_TRACE, "readallfiles(buffer) globbing \"%s/%s*\"\n", FSL_CFGDIR, FSL_PREFIX);
 
     if ((dp = opendir(FSL_CFGDIR)) == NULL)
         CU(FSL_ERR_SYS);
 
+    rc = FSL_ERR_ARG;
     while ((de = readdir(dp)) != NULL) {
-        if (   (de->d_type == DT_REG)
-            && (de->d_namlen >= strlen(FSL_PREFIX))
+        n = strlen(de->d_name);
+        if (   (n >= strlen(FSL_PREFIX))
             && (strncmp(de->d_name, FSL_PREFIX, strlen(FSL_PREFIX)) == 0)
               ) {
-            if ((filename = (char *)malloc(strlen(FSL_CFGDIR) + 1 + de->d_namlen + 1)) == NULL)
+            if ((filename = (char *)malloc(strlen(FSL_CFGDIR) + 1 + n + 1)) == NULL)
                 CU(FSL_ERR_MEM);
             filename[0] = '\0';
             strcat(filename, FSL_CFGDIR);
             strcat(filename, "/");
-            strncat(filename, de->d_name, de->d_namlen);
-            (void /*FIXME*/)appendfiletobuffer(buffer, filename);
+            strcat(filename, de->d_name);
+            if (appendfiletobuffer(buffer, filename) == FSL_OK)
+                rc = FSL_OK;
             free(filename);
             filename = NULL;
         }
     }
     (void)closedir(dp);
-    CU(FSL_OK);
+    CU(rc);
 CUS:
     if (filename != NULL)
         free(filename);
@@ -741,7 +757,7 @@
 
     if (filename == NULL || buffer == NULL)
         CU(FSL_ERR_ARG);
-    fsldebug(L2_LEVEL_TRACE, "appendfiletobuffer(), filename=%s)\n", filename);
+    fsldebug(L2_LEVEL_TRACE, "appendfiletobuffer(buffer, filename=\"%s\")\n", filename);
 
     if ((fd = open(filename, O_RDONLY)) == -1)
         CU(FSL_ERR_SYS);


ossp-pkg/fsl/fsl_test.c 1.3 -> 1.4

--- fsl_test.c   2002/07/23 14:37:50     1.3
+++ fsl_test.c   2002/07/24 15:29:01     1.4
@@ -5,7 +5,7 @@
 int main(int argc, char *argv[])
 {
     syslog(LOG_INFO, "Connection from host %s", "foo.bar.dom");
-    openlog("mail", LOG_PID|LOG_NDELAY, LOG_FTP);
+    openlog("mail", LOG_PID|LOG_NDELAY, LOG_LOCAL0);
     syslog(LOG_ALERT, "who: internal error 23\n");
     setlogmask(LOG_UPTO(LOG_ERR));
     syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m");

CVSTrac 2.0.1