OSSP CVS Repository

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

Check-in Number: 3360
Date: 2003-May-22 14:30:35 (local)
2003-May-22 12:30:35 (UTC)
User:thl
Branch:
Comment: for details see attached ChangeLog
Tickets:
Inspections:
Files:
ossp-pkg/fsl/ChangeLog      1.16 -> 1.17     33 inserted, 0 deleted
ossp-pkg/fsl/Makefile.in      1.14 -> 1.15     15 inserted, 10 deleted
ossp-pkg/fsl/README      1.29 -> 1.30     1 inserted, 1 deleted
ossp-pkg/fsl/devtool.conf      1.17 -> 1.18     1 inserted, 0 deleted
ossp-pkg/fsl/fsl.ac      1.5 -> 1.6     45 inserted, 11 deleted
ossp-pkg/fsl/fsl.c      1.57 -> 1.58     121 inserted, 143 deleted
ossp-pkg/fsl/fsl.pod      1.27 -> 1.28     53 inserted, 18 deleted
ossp-pkg/fsl/fsl_version.c      1.15 -> 1.16     9 inserted, 9 deleted

ossp-pkg/fsl/ChangeLog 1.16 -> 1.17

--- ChangeLog    2003/02/13 15:38:38     1.16
+++ ChangeLog    2003/05/22 12:30:35     1.17
@@ -8,6 +8,39 @@
 
   CHANGELOG
 
+  Changes between 1.0.8 and 1.1.0 (22-May-2003)
+
+    *) for compatiblity reasons, when debugging is enabled and
+       openlog(2) is called without LOG_NDELAY no filedescriptor is
+       consumed.  Prevously debugging unconditionally took one or more
+       filedescriptors which violates POSIX.
+   
+    *) for compatiblity reasons, the library will no longer print any
+       messages to stderr under any circumstances. If debugging is not
+       possible or disabled, messages will be silently discarded.
+    
+    *) for security reasons the process environment is completely
+       ignored.  The drawback is that FSL_CFGDIR, FSL_PREFIX and most
+       debugging options are now configure options only.
+   
+    *) for safety reasons, when debugging is not used the whole
+       debugging code is replaced with a simple no-operation stub function.
+   
+    *) for convenience reasons, what(1) or a "strings binarywithfsl |
+       grep '@(#)'" will provide information about debugging code being
+       omitted or included and, in the latter case, which logfile and
+       logmask are being used.
+   
+    *) for convenience reasons and to keep simple things simple,
+       debugging now logs to a file only and support to use l2spec for
+       debugging is entirely removed at this time. The logfile, the logstop
+       maximum file size and the logmask are configure options.
+   
+    *) for flexibility reasons but still to stay away from the process
+       environment the logmask is configured by reading the content of a
+       symlink.
+       [Thomas Lotterer <thomas@lotterer.net]
+
   Changes between 1.0.7 and 1.0.8 (13-Feb-2003)
 
     *) Remove NULL checks for va_list based variables because it was


ossp-pkg/fsl/Makefile.in 1.14 -> 1.15

--- Makefile.in  2003/05/20 15:47:23     1.14
+++ Makefile.in  2003/05/22 12:30:35     1.15
@@ -59,8 +59,12 @@
 TST_NAME    = fsl_test
 TST_OBJS    = fsl_test.o
 
-FSL_CFGDIR  = @FSL_CFGDIR@
-FSL_PREFIX  = @FSL_PREFIX@
+FSL_CFGDIR       = @FSL_CFGDIR@
+FSL_PREFIX       = @FSL_PREFIX@
+FSL_DEBUGLOGCODE = @FSL_DEBUGLOGCODE@
+FSL_DEBUGLOGFILE = @FSL_DEBUGLOGFILE@
+FSL_DEBUGLOGMASK = @FSL_DEBUGLOGMASK@
+FSL_DEBUGLOGSTOP = @FSL_DEBUGLOGSTOP@
 
 SUBDIRS     = @SUBDIR_L2@ @SUBDIR_CFG@ @SUBDIR_PCRE@
 
@@ -111,19 +115,20 @@
                    --release="$$D" --date="OSSP fsl $$VS" fsl.pod | \
         sed -e "s;FSL_VERSION_STR;$$VL;" \
             -e "s;\@FSL_CFGDIR\@;$(FSL_CFGDIR);g" \
-            -e "s;\@FSL_PREFIX\@;$(FSL_PREFIX);g" >fsl.3
+            -e "s;\@FSL_PREFIX\@;$(FSL_PREFIX);g" \
+            -e "s;\@FSL_DEBUGLOGCODE\@;$(FSL_DEBUGLOGCODE);g" \
+            -e "s;\@FSL_DEBUGLOGFILE\@;$(FSL_DEBUGLOGFILE);g" \
+            -e "s;\@FSL_DEBUGLOGMASK\@;$(FSL_DEBUGLOGMASK);g" \
+            -e "s;\@FSL_DEBUGLOGSTOP\@;$(FSL_DEBUGLOGSTOP);g" \
+                >fsl.3
 
 test: check
 check: $(TST_NAME)
-        @[ -f fsl_test.debug  ] && $(RM) fsl_test.debug  || true
         @[ -f fsl_test.syslog ] && $(RM) fsl_test.syslog || true
-        @true && \
-        FSL_CFGDIR=.; export FSL_CFGDIR; \
-        FSL_PREFIX=fsl_test.cfg; export FSL_PREFIX; \
-        FSL_DEBUG="trace: file(path=fsl_test.debug)"; export FSL_DEBUG; \
-        $(LIBTOOL) --mode=execute ./$(TST_NAME)
+        @$(LIBTOOL) --mode=execute ./$(TST_NAME)
         @echo "fsl_test.syslog:"; if [ -s fsl_test.syslog ]; then cat fsl_test.syslog; else echo " ***EMPTY***"; fi
-        #echo "fsl_test.debug:";  if [ -s fsl_test.debug  ]; then cat fsl_test.debug;  else echo " ***EMPTY***"; fi
+        @echo "this test requires manual configuration, use fsl_test.cfg as template and see pathes below"
+        @strings <$(TST_NAME) | grep '@(#)'
 
 install: all
         $(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(prefix)


ossp-pkg/fsl/README 1.29 -> 1.30

--- README       2003/02/13 15:40:30     1.29
+++ README       2003/05/22 12:30:35     1.30
@@ -5,7 +5,7 @@
   |_|_|_|  \___/|____/____/|_|     |_| |___/_|
  
   OSSP fsl - Faking/Flexible Syslog Library
-  Version 1.0.8 (13-Feb-2003)
+  Version 1.1b0 (22-May-2003)
 
   ABSTRACT
 


ossp-pkg/fsl/devtool.conf 1.17 -> 1.18

--- devtool.conf 2003/05/22 12:28:25     1.17
+++ devtool.conf 2003/05/22 12:30:35     1.18
@@ -37,6 +37,7 @@
         --disable-shared \
         --enable-maintainer \
         --enable-debug \
+       #--with-fsl-debuglogcode=yes \
         "$@"
 
 %release


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

--- fsl.ac       2003/01/06 16:41:21     1.5
+++ fsl.ac       2003/05/22 12:30:35     1.6
@@ -77,17 +77,51 @@
 AC_SUBST(FSL_PREFIX)
 AC_MSG_RESULT([$fsl_prefix])
 
-dnl #   built-time configuration parameter --with-fsl-debug
-AC_MSG_CHECKING(for debugging using a l2spec)
-AC_ARG_WITH(fsl-debug,dnl
-[  --with-fsl-debug=L2SPEC set internal debugging (default="null")],
-[ fsl_debug=$withval ],
-[ fsl_debug="null" ]
+])
+
+dnl #   built-time configuration parameter --with-fsl-debuglogcode
+AC_MSG_CHECKING(for debug log code)
+AC_ARG_WITH(fsl-debuglogcode,dnl
+[  --with-fsl-debuglogcode=BOOL  set debug log code (default=0) 0=omit; 1=include],
+[ AC_DEFINE(FSL_DEBUGLOGCODE, 1, [Define for OSSP fsl debug log code; 0=omit, 1=include]) ]
 )dnl
-AC_DEFINE_UNQUOTED(FSL_DEBUG, "$fsl_debug", [Define for OSSP fsl debugging])
-FSL_DEBUG="$fsl_debug"
-AC_SUBST(FSL_DEBUG)
-AC_MSG_RESULT([$fsl_debug])
+FSL_DEBUGLOGCODE="$fsl_debuglogcode"
+AC_SUBST(FSL_DEBUGLOGCODE)
+AC_MSG_RESULT([$fsl_debuglogcode])
 
-])
+dnl #   built-time configuration parameter --with-fsl-debuglogfile
+AC_MSG_CHECKING(for debug log file)
+AC_ARG_WITH(fsl-debuglogfile,dnl
+[  --with-fsl-debuglogfile=FILE  set debug log file (default="PREFIX/var/fsl/debuglogfile")],
+[ fsl_debuglogfile=$withval ],
+[ fsl_debuglogfile="${prefix}/var/fsl/debuglogfile" ]
+)dnl
+AC_DEFINE_UNQUOTED(FSL_DEBUGLOGFILE, "$fsl_debuglogfile", [Define for OSSP fsl debug log file; name])
+FSL_DEBUGLOGFILE="$fsl_debuglogfile"
+AC_SUBST(FSL_DEBUGLOGFILE)
+AC_MSG_RESULT([$fsl_debuglogfile])
+
+dnl #   built-time configuration parameter --with-fsl-debuglogmask
+AC_MSG_CHECKING(for debug log mask)
+AC_ARG_WITH(fsl-debuglogmask,dnl
+[  --with-fsl-debuglogmask=FILE  set debug log mask (default="PREFIX/var/fsl/debuglogmask")],
+[ fsl_debuglogmask=$withval ],
+[ fsl_debuglogmask="${prefix}/var/fsl/debuglogmask" ]
+)dnl
+AC_DEFINE_UNQUOTED(FSL_DEBUGLOGMASK, "$fsl_debuglogmask", [Define for OSSP fsl debug log mask; symlink])
+FSL_DEBUGLOGMASK="$fsl_debuglogmask"
+AC_SUBST(FSL_DEBUGLOGMASK)
+AC_MSG_RESULT([$fsl_debuglogmask])
+
+dnl #   built-time configuration parameter --with-fsl-debuglogstop
+AC_MSG_CHECKING(for debug log stop)
+AC_ARG_WITH(fsl-debuglogstop,dnl
+[  --with-fsl-debuglogstop=SIZE  set debug log stop (default=16777216)],
+[ fsl_debuglogstop=$withval ],
+[ fsl_debuglogstop=16777216 ]
+)dnl
+AC_DEFINE_UNQUOTED(FSL_DEBUGLOGSTOP, $fsl_debuglogstop, [Define for OSSP fsl debug log stop; maxsize])
+FSL_DEBUGLOGSTOP="$fsl_debuglogstop"
+AC_SUBST(FSL_DEBUGLOGSTOP)
+AC_MSG_RESULT([$fsl_debuglogstop])
 


ossp-pkg/fsl/fsl.c 1.57 -> 1.58

--- fsl.c        2003/05/20 15:47:23     1.57
+++ fsl.c        2003/05/22 12:30:35     1.58
@@ -53,6 +53,11 @@
 /* autoconfiguration */
 #include "config.h"
 
+/* use l2_ut_[v]sprintf() as a portable [v]snprintf() replacement for debugging */
+#ifdef FSL_DEBUGLOGCODE
+#include "l2_ut_format.h"
+#endif
+
 /* version */
 #define _FSL_VERSION_C_AS_HEADER_
 #include "fsl_version.c"
@@ -61,6 +66,9 @@
 /* pcre static vector size */
 #define OVECSIZE 30
 
+/* maximum atomic write size, maximum log message size */
+#define MAXWRITESIZE 512
+
 /* backward compatibility */
 #ifndef LOG_PRIMASK
 #define LOG_PRIMASK (LOG_EMERG|LOG_ALERT|LOG_CRIT|LOG_ERR|\
@@ -179,88 +187,123 @@
 static struct {
     l2_env_t     *l2_env;
     l2_channel_t *l2_nch;
+    char         *cpISF;
     levelmap_t   *levelmap;
     int           maskpri;
     int           logopt;
     int           delayopen;
     int           triedopenlog;
-    /* fsl debugging */
+#ifdef FSL_DEBUGLOGCODE
     l2_env_t     *fsldebug_l2_env;
     l2_channel_t *fsldebug_l2_nch;
     int           fsldebug_transientproblem;
     int           fsldebug_permanentproblem;
+#endif /* ifdef FSL_DEBUGLOGCODE */
+    char         *fsl_config;
 } ctx = { 
     NULL,
     NULL,
     NULL,
+    NULL,
     LOG_UPTO(LOG_DEBUG),
     0,
     TRUE,
     FALSE,
-    /* fsl debugging */
+#ifdef FSL_DEBUGLOGCODE
     NULL,
     NULL,
     FALSE,
-    FALSE
+    FALSE,
+#endif /* ifdef FSL_DEBUGLOGCODE */
+    "@(#)OSSP fsl config "
+    "cfgdir=\"" FSL_CFGDIR "\"" " "
+    "prefix=\"" FSL_PREFIX "\""
+    "\n"
+    "@(#)OSSP fsl debug "
+#ifdef FSL_DEBUGLOGCODE
+    "logfile=\"" FSL_DEBUGLOGFILE "\"" " "
+    "logmask=\"" FSL_DEBUGLOGMASK "\""
+#else /* ifdef FSL_DEBUGLOGCODE */
+    "code omitted;"
+#endif /* ifdef FSL_DEBUGLOGCODE */
+    "\n"
 };
 
-/* internal debugging prototypes */
-static void fsldebugcreate (void);
-static void fsldebug       (l2_level_t, const char *, ...);
-static int  fsldebugl2     (l2_level_t, const char *, va_list);
-static int  fsldebugf2     (l2_level_t, const char *, va_list);
-static void fsldebugdestroy(void);
-
-/* internal debugging functions */
-static void fsldebugcreate()
+#ifdef FSL_DEBUGLOGCODE
+static void vfsldebug(l2_level_t level, const char *message, va_list ap)
 {
-    int rc = FSL_OK;
-    char *argl2spec;
-    l2_result_t l2rv;
-    char *cp; /* scratch variable */
-    l2_channel_t *ch; /* scratch variable */
-
-    /* identify previous fault and avoid repetition */
-    if (ctx.fsldebug_permanentproblem || ctx.fsldebug_transientproblem)
-        return;
-
-    /* create OSSP l2 environment for fsl itself (internal logging) */
-    if ((argl2spec = getenv("FSL_DEBUG")) == NULL)
-        argl2spec = FSL_DEBUG;
-    if (strlen(argl2spec) > 0) {
-        if ((l2rv = l2_env_create(&ctx.fsldebug_l2_env)) != L2_OK) {
-            cp = l2_env_strerror(ctx.fsldebug_l2_env, l2rv); fsldebug(L2_LEVEL_ERROR, "openlog: failed to create L2 environment (%d) for fsl", l2rv); CU(FSL_ERR_INT); }
-        if ((l2rv = l2_env_levels(ctx.fsldebug_l2_env, L2_LEVEL_ALL, L2_LEVEL_NONE)) != L2_OK) {
-            cp = l2_env_strerror(ctx.fsldebug_l2_env, l2rv); fsldebug(L2_LEVEL_ERROR, "openlog: logging failed to set global logging level defaults %s(%d) for fsl", cp, l2rv); CU(FSL_ERR_INT); }
-        if ((l2rv = l2_env_formatter(ctx.fsldebug_l2_env, 'D', l2_util_fmt_dump, NULL)) != L2_OK) {
-            cp = l2_env_strerror(ctx.fsldebug_l2_env, l2rv); fsldebug(L2_LEVEL_ERROR, "openlog: logging failed to register dump formatter %s(%d) for fsl", cp, l2rv); CU(FSL_ERR_INT); }
-        if ((l2rv = l2_env_formatter(ctx.fsldebug_l2_env, 'S', l2_util_fmt_string, NULL)) != L2_OK) {
-            cp = l2_env_strerror(ctx.fsldebug_l2_env, l2rv); fsldebug(L2_LEVEL_ERROR, "openlog: logging failed to register string formatter %s(%d) for fsl", cp, l2rv); CU(FSL_ERR_INT); }
-        if ((l2rv = l2_env_formatter(ctx.fsldebug_l2_env, 'm', l2_util_fmt_errno, NULL)) != L2_OK) {
-            cp = l2_env_strerror(ctx.fsldebug_l2_env, l2rv); fsldebug(L2_LEVEL_ERROR, "openlog: logging failed to register errno formatter %s(%d) for fsl", cp, l2rv); CU(FSL_ERR_INT); }
-        if ((l2rv = l2_channel_create(&ctx.fsldebug_l2_nch, ctx.fsldebug_l2_env, "noop")) != L2_OK) {
-            cp = l2_env_strerror(ctx.fsldebug_l2_env, l2rv); fsldebug(L2_LEVEL_ERROR, "openlog: logging failed to create noop channel; %s(%d) for fsl", cp, l2rv); CU(FSL_ERR_INT); }
-        if ((l2rv = l2_spec(&ch, ctx.fsldebug_l2_env, "%s", argl2spec)) != L2_OK) {
-            cp = l2_env_strerror(ctx.fsldebug_l2_env, l2rv); fsldebug(L2_LEVEL_ERROR, "openlog: logging failed to create stream from spec %s(%d) for fsl", cp, l2rv);
-            if (l2rv == L2_ERR_ARG)
-                CU(FSL_ERR_ARG);
-            else
-                CU(FSL_ERR_INT);
-        }
-        if ((l2rv = l2_channel_link(ctx.fsldebug_l2_nch, L2_LINK_CHILD, ch, NULL)) != L2_OK) {
-            cp = l2_env_strerror(ctx.fsldebug_l2_env, l2rv); fsldebug(L2_LEVEL_ERROR, "openlog: logging failed to link child channel %s(%d) for fsl", cp, l2rv); CU(FSL_ERR_INT); }
-        if ((~ctx.logopt & LOG_NDELAY) && (ctx.delayopen == TRUE)) {
-            fsldebug(L2_LEVEL_ERROR, "openlog: LOG_NDELAY unused forces debugging to use stealth mode until first syslog"); }
-        else {
-            if ((l2rv = l2_channel_open(ctx.fsldebug_l2_nch)) != L2_OK) {
-                cp = l2_env_strerror(ctx.fsldebug_l2_env, l2rv); fsldebug(L2_LEVEL_ERROR, "openlog: logging failed to open channel stream %s(%d) for fsl", cp, l2rv); CU(FSL_ERR_INT); }
+    /* sizing cp temporary buffer is max out of
+       strlen "(panic,critical,error,warning,notice,info,trace,debug)" + terminating NUL and
+       strlen "bbb dd HH:MM:SS " + terminating NUL
+       = 56
+     */
+    static char cp[56]; /* FIXME */
+    static char cpo[MAXWRITESIZE];
+    int cpn;
+    int n;
+    struct stat sb;
+    unsigned int levelmask;
+    time_t t;
+    struct tm *tm;
+    int fd = 0;
+
+    /* determine level mask */
+    if ((n = readlink(FSL_DEBUGLOGMASK, cp, sizeof(cp))) == -1)
+        VCU;
+    if (cp[0] == '(' && cp[n-1] == ')') { /* level mask in round brackets like l2spec */
+        if(l2_util_s2l(&cp[1], n-2, ',', &levelmask) != L2_OK)
+            VCU;
+    }
+    else if (strchr(cp, ',') != NULL) { /* level mask automatic because comma detected */
+        if(l2_util_s2l(&cp[0], n  , ',', &levelmask) != L2_OK)
+            VCU;
+    }
+    else { /* upto level like l2spec */
+        if(l2_util_s2l(&cp[0], n  , 0  , &levelmask) != L2_OK)
+            VCU;
+        levelmask = L2_LEVEL_UPTO(levelmask);
+    }
+
+    if (level & levelmask) {
+
+        cpn = 0;
+
+        /* date and time */
+        t = time(NULL);
+        tm = localtime(&t);
+        if ((n = strftime(cp, sizeof(cp), "%b %d %H:%M:%S ", tm)) == 0)
+            VCU;
+        l2_util_sprintf( &cpo[cpn], MAXWRITESIZE-cpn, "%s", cp);
+        cpn = strlen(cpo);
+
+        /* level */
+        l2_util_sprintf( &cpo[cpn], MAXWRITESIZE-cpn, "<%s> ", l2_util_l2s(cp, sizeof(cp), '\0', level) == L2_OK ? cp : "unknown");
+        cpn = strlen(cpo);
+        
+        /* program "name" and pid */
+        l2_util_sprintf( &cpo[cpn], MAXWRITESIZE-cpn, "%s[%lu^%lu] ", ctx.cpISF != NULL ? ctx.cpISF : "unknown", (unsigned long)getpid(), (unsigned long)getppid());
+        cpn = strlen(cpo);
+
+        /* message */
+        l2_util_vsprintf(&cpo[cpn], MAXWRITESIZE-cpn, message, ap);
+        cpn = strlen(cpo);
+        l2_util_sprintf( &cpo[cpn], MAXWRITESIZE-cpn, "\n");
+        cpn = strlen(cpo);
+
+        /* write the log */
+        if (cpn >= 1) {
+            if ((fd = open(FSL_DEBUGLOGFILE, O_WRONLY|O_CREAT|O_APPEND|O_NONBLOCK, 0644)) == -1)
+                VCU;
+            if (fstat(fd, &sb) == -1)
+                VCU;
+            if (sb.st_size >= FSL_DEBUGLOGSTOP)
+                VCU;
+            write(fd, cpo, cpn);
         }
     }
 CUS:
-    if (rc == FSL_ERR_ARG)
-        ctx.fsldebug_permanentproblem = TRUE;
-    if (rc != FSL_OK)
-        fsldebugdestroy();
+    if (fd)
+        (void)close(fd);
 }
 
 static void fsldebug(l2_level_t level, const char *message, ...)
@@ -268,82 +311,16 @@
     va_list ap;
 
     va_start(ap, message);
-    fsldebugl2(level, message, ap) || fsldebugf2(level, message, ap);
+    vfsldebug(level, message, ap);
     va_end(ap);
     return;
 }
-
-static int fsldebugl2(l2_level_t level, const char *message, va_list ap)
-{
-    int rc = FALSE; /* the pessimist */
-    l2_result_t l2rv;
-    char *cp;
-
-    /* identify previous fault and avoid repetition */
-    if (ctx.fsldebug_permanentproblem || ctx.fsldebug_transientproblem)
-        return rc;
-        
-    /* nothing has been prepared, so do it now */
-    if (ctx.fsldebug_l2_nch == NULL)
-        fsldebugcreate();
-
-    /* identify previous fault and avoid repetition */
-    if (ctx.fsldebug_permanentproblem || ctx.fsldebug_transientproblem)
-        return rc;
-
-    /* preparation failed */
-    if (ctx.fsldebug_l2_nch == NULL)
-        return rc;
-
-    /* try logging, L2_ERR_USE only occurs if channel is not yet open */
-    if ((l2rv = l2_channel_vlog(ctx.fsldebug_l2_nch, level, message, ap)) == L2_ERR_USE) {
-        if ((l2rv = l2_channel_open(ctx.fsldebug_l2_nch)) != L2_OK) {
-            ctx.fsldebug_transientproblem = TRUE; /* avoid loop from fsldebug() in next line */
-            cp = l2_env_strerror(ctx.fsldebug_l2_env, l2rv); fsldebug(L2_LEVEL_ERROR, "openlog: logging failed to open channel stream %s(%d) for fsl", cp, l2rv);
-            ctx.fsldebug_transientproblem = FALSE; /* opening the channel might work at next attempt */
-            return rc;
-        }
-        l2rv = l2_channel_vlog(ctx.fsldebug_l2_nch, level, message, ap);
-    }
-
-    if (l2rv == L2_OK)
-        rc = TRUE;
-
-    /* if openlog(3) "did not request LOG_NDELAY" aka "did request delay" (~ctx.logopt & LOG_NDELAY),
-     * until a syslog(3) was tried (ctx.delayopen == TRUE), operate in stealth mode by closing channel
-     */
-    if ((~ctx.logopt & LOG_NDELAY) && (ctx.delayopen == TRUE))
-        (void)l2_channel_close(ctx.fsldebug_l2_nch);
-
-    return rc;
-}
-
-static int fsldebugf2(l2_level_t level, const char *message, va_list ap)
-{
-    int rc = TRUE; /* the optimist */
-    char cp[8];
-
-    if (level & L2_LEVEL_UPTO(L2_LEVEL_ERROR)) {
-        fprintf( stderr, "%s: ", l2_util_l2s(cp, sizeof(cp), '\0', level) == L2_OK ? cp[0]&=0xDF, cp : "Log");
-        vfprintf(stderr, message, ap);
-        fprintf( stderr, "\n");
-    }
-    return rc;
-}
-
-static void fsldebugdestroy()
+#else /* ifdef FSL_DEBUGLOGCODE */
+static void fsldebug(l2_level_t level, const char *message, ...)
 {
-    if (ctx.fsldebug_l2_nch != NULL) {
-        l2_channel_destroy(ctx.fsldebug_l2_nch);
-        ctx.fsldebug_l2_nch = NULL;
-    }
-    if (ctx.fsldebug_l2_env != NULL) {
-        l2_env_destroy(ctx.fsldebug_l2_env);
-        ctx.fsldebug_l2_env = NULL;
-    }
-    ctx.fsldebug_transientproblem = FALSE;
-    /*  fsldebug_permanentproblem kept */
+    return;
 }
+#endif /* ifdef FSL_DEBUGLOGCODE */
 
 /* append contents of a file to buffer */
 static fsl_rc_t appendfiletobuffer(buf_t *buffer, const char *filename)
@@ -408,10 +385,8 @@
     if (buffer == NULL)
         CU(FSL_ERR_ARG);
 
-    if ((cfgdir = getenv("FSL_CFGDIR")) == NULL)
-        cfgdir = FSL_CFGDIR;
-    if ((prefix = getenv("FSL_PREFIX")) == NULL)
-        prefix = FSL_PREFIX;
+    cfgdir = FSL_CFGDIR;
+    prefix = FSL_PREFIX;
 
     fsldebug(L2_LEVEL_TRACE, "readallfiles() globbing \"%s/%s*\"", cfgdir, prefix);
 
@@ -750,7 +725,6 @@
     int   i;  /* scratch variable */
     char *cpIdent;
     char *cpFacility;
-    char *cpISF;
     l2_result_t   l2rv;
 
     /* initialization */
@@ -759,7 +733,6 @@
     buf.used = 0;
     buf.size = 0;
     cpIdent = NULL;
-    cpISF = NULL;
 
     /* properly prepare for repeated execution */
     closelog();
@@ -822,12 +795,12 @@
             break;
         }
     }
-    if ((cpISF = (char *)malloc(strlen(cpIdent) + 1 + strlen(cpFacility) + 1)) == NULL) {
+    if ((ctx.cpISF = (char *)malloc(strlen(cpIdent) + 1 + strlen(cpFacility) + 1)) == NULL) {
         fsldebug(L2_LEVEL_ERROR, "openlog: malloc() failed"); CU(1); }
-    cpISF[0] = '\0';
-    strcat(cpISF, cpIdent);
-    strcat(cpISF, "/");
-    strcat(cpISF, cpFacility);
+    ctx.cpISF[0] = '\0';
+    strcat(ctx.cpISF, cpIdent);
+    strcat(ctx.cpISF, "/");
+    strcat(ctx.cpISF, cpFacility);
 
     /* read configuration file(s) into buffer */
     if ((rv = readallfiles(&buf)) != FSL_OK) {
@@ -840,11 +813,11 @@
         (void)cfg_error(cfg, cfgrv, &cp); fsldebug(L2_LEVEL_ERROR, "openlog: cfg_import() failed with error %s (%d)", cp, cfgrv); CU(1); }
 
     /*  process OSSP cfg node tree "map" and "ident" directives */
-    if ((rv = processcfg(cfg, cpISF, 0)) != FSL_OK && (rv != FSL_NOIDENT)) {
+    if ((rv = processcfg(cfg, ctx.cpISF, 0)) != FSL_OK && (rv != FSL_NOIDENT)) {
         fsldebug(L2_LEVEL_ERROR, "openlog: processcfg() failed with an unrecoverable error (%d)", rv); CU(1); }
 
     /*  optionally process OSSP cfg node tree "default" directives */
-    if ((rv == FSL_NOIDENT) && ((rv = processcfg(cfg, cpISF, 1)) != FSL_OK)) {
+    if ((rv == FSL_NOIDENT) && ((rv = processcfg(cfg, ctx.cpISF, 1)) != FSL_OK)) {
         fsldebug(L2_LEVEL_ERROR, "openlog: processcfg() failed with an unrecoverable error (%d)", rv); CU(1); }
 
     /*  open logging now or prepare for delayed open */
@@ -859,8 +832,10 @@
 
     CU(0);
 CUS:
-    if (cpISF != NULL)
-        free(cpISF);
+    if (ctx.cpISF != NULL) {
+        free(ctx.cpISF);
+        ctx.cpISF = NULL;
+    }
     if (cpIdent != NULL)
         free(cpIdent);
     if (cfg != NULL)
@@ -879,7 +854,6 @@
     /* tracing */
     fsldebug(L2_LEVEL_TRACE, "fsl in closelog(3)");
 
-    fsldebugdestroy();
     if (ctx.l2_nch != NULL) {
         l2_channel_destroy(ctx.l2_nch);
         ctx.l2_nch = NULL;
@@ -892,6 +866,10 @@
         free(ctx.levelmap);
         ctx.levelmap = NULL;
     }
+    if (ctx.cpISF != NULL) {
+        free(ctx.cpISF);
+        ctx.cpISF = NULL;
+    }
     ctx.maskpri = LOG_UPTO(LOG_DEBUG);
     ctx.logopt = 0;
     ctx.delayopen = TRUE;


ossp-pkg/fsl/fsl.pod 1.27 -> 1.28

--- fsl.pod      2003/01/06 16:41:21     1.27
+++ fsl.pod      2003/05/22 12:30:35     1.28
@@ -479,39 +479,74 @@
      )
  };
 
-=head1 ENVIRONMENT
+=head1 CONFIGURE
 
-The following environment variables affect the execution of B<OSSP fsl>:
+Operation.
 
 =over 4
 
-=item C<FSL_CFGDIR>
+=item C<--with-fsl-cfgdir>
 
-This variable overrides the default value (hard-coded in B<OSSP fsl>
-under built-time via C<--with-fsl-cfgdir=>I<path>) under run-time. The
-value has to point to an existing directory where configuration files
-named "I<prefix>C<*>" (see below) exist. The default value is
+The value has to point to an existing directory where configuration
+files named "I<prefix>C<*>" (see below) exist. The default value is
 "C<@FSL_CFGDIR@>".
 
-=item C<FSL_PREFIX>
+=item C<--with-fsl-prefix>
 
-This variable overrides the default value (hard-coded in B<OSSP fsl>
-under built-time via C<--with-fsl-prefix=>I<prefix>) under run-time.
 The value has to be a valid partial Unix filename. The default value is
 "C<@FSL_PREFIX@>".
 
-=item C<FSL_DEBUG>
+=back
+
+Deployment.
+
+=over 4
+
+=item C<--with-fsl-debuglogcode>
 
-This variable overrides the default value (hard-coded in B<OSSP fsl>
-under built-time via C<--with-fsl-debug=>I<l2-spec>) under run-time.
-The value has to be a valid B<OSSP l2> channel tree specification. An
-empty value (either hard-coded or overridden) disables B<OSSP fsl>
-debugging via B<OSSP l2> (but still logs errors to F<stderr>). A value
-of "C<null>" instead disables debugging at all by discarding all
-messages.
+The value must be empty or something where empty omits and anything else
+includes debugging code.  When debugging is not used the whole debugging
+code is replaced with a simple no-operation stub function.  The default
+value is "C<@FSL_DEBUGLOGCODE@>".
+
+=item C<--with-fsl-debuglogfile>
+
+The value has to point to a file where logging information is being
+dumped into. The directory has to exist, the file must be
+creatable/writable.  The file is opened, written in append mode and
+closed for every debug log message. In case of problems the debug log
+messages will be silently discarded.  The default value is
+"C<@FSL_DEBUGLOGFILE@>".
+
+=item C<--with-fsl-debuglogmask>
+
+The value has to point to a symlink. The content of this symlink is the
+name of a loglevel or a logmask. Possible values are panic, critical,
+error, warning, notice, info, trace, debug; A single word is interpreted
+as a log level and all messages with that or a more important level will
+be logged. If a comma is found in the symlink content a logmask is build
+by or'ing together the values behind all words. The same is true when
+the entire value is inside round brackets, which makes this part of the
+format compatible to l2spec and allows a single word to be a mask rather
+than a level. If for any reasons the symlink does not exist, is not
+readable, has a syntactically wrong value or any other problems the
+debug log messages will be silently discarded.  The default value is
+"C<@FSL_DEBUGLOGMASK@>".
+
+=item C<--with-fsl-debuglogstop>
+
+The value is the maximum size of the logfile in bytes.  If this size is
+reached or exceeded before the message is written logging stops and
+debug log messages will be silently discarded.  The default value is
+"C<@FSL_DEBUGLOGSTOP@>".
 
 =back
 
+For convenience reasons, what(1) or a "strings binarywithfsl | grep
+'@(#)'" will provide information about debugging code being omitted or
+included and, in the latter case, which logfile and logmask are being
+used.
+
 =head1 FILES
 
 =over 4


ossp-pkg/fsl/fsl_version.c 1.15 -> 1.16

--- fsl_version.c        2003/02/13 15:40:30     1.15
+++ fsl_version.c        2003/05/22 12:30:35     1.16
@@ -8,7 +8,7 @@
 #ifndef _FSL_VERSION_C_
 #define _FSL_VERSION_C_
 
-#define FSL_VERSION 0x100208
+#define FSL_VERSION 0x101100
 
 typedef struct {
     const int   v_hex;
@@ -32,14 +32,14 @@
 #undef  _FSL_VERSION_C_AS_HEADER_
 
 fsl_version_t fsl_version = {
-    0x100208,
-    "1.0.8",
-    "1.0.8 (13-Feb-2003)",
-    "This is OSSP fsl, Version 1.0.8 (13-Feb-2003)",
-    "OSSP fsl 1.0.8 (13-Feb-2003)",
-    "OSSP fsl/1.0.8",
-    "@(#)OSSP fsl 1.0.8 (13-Feb-2003)",
-    "$Id: fsl_version.c,v 1.15 2003/02/13 15:40:30 rse Exp $"
+    0x101100,
+    "1.1b0",
+    "1.1b0 (22-May-2003)",
+    "This is OSSP fsl, Version 1.1b0 (22-May-2003)",
+    "OSSP fsl 1.1b0 (22-May-2003)",
+    "OSSP fsl/1.1b0",
+    "@(#)OSSP fsl 1.1b0 (22-May-2003)",
+    "$Id: fsl_version.c,v 1.16 2003/05/22 12:30:35 thl Exp $"
 };
 
 #endif /* _FSL_VERSION_C_AS_HEADER_ */

CVSTrac 2.0.1