Logging to file stops before modules are detached

Enrik Berkhan enrik#freeradius at planb.de
Fri Aug 10 11:47:59 CEST 2007


Hi,

when logging to file, logging stops before modules get detached. AFAICS,
this happens because the log file name stored in mainconfig.log_file
gets free()d before modules get detached.

In effect, modules can't log anything to a log file while detaching.

A small test case using rlm_perl is:

radiusd.conf:
...
modules {
  perl test {
    module = ${raddbdir}/test.pl
  }
}
...
 authorize {
    test
 }
...


test.pl:
END {
  radiusd::radlog(3, 'ENDing...');
}


While running in debug mode, the perl END section will happily log its
ENDing... line to stdout. When running in daemon mode and logging to
file, these lines will never appear in the file.

I haven't found a clean solution for this problem but tested a very ugly
hack to confirm that logging to file will keep working when
mainconfig.log_file isn't free()d:

Index: src/main/conffile.c
===================================================================
RCS file: /source/radiusd/src/main/conffile.c,v
retrieving revision 1.176
diff -u -r1.176 conffile.c
--- src/main/conffile.c 4 Jul 2007 05:54:17 -0000       1.176
+++ src/main/conffile.c 10 Aug 2007 09:36:48 -0000
@@ -307,8 +307,10 @@
                        p = (char **) (((char *)base) +
variables[i].offset);
                }

-               free(*p);
-               *p = NULL;
+               if (*p != mainconfig.log_file) {
+                 free(*p);
+                 *p = NULL;
+               }
        }
 }

Has anybody any suggestions for a clean solution?

Enrik




More information about the Freeradius-Devel mailing list