freeradius 1.1.6 / syslog problems
Hi I installed freeRadius 1.1.6 on a FreeBSD 6.2-RELEASE system from the ports collection, and am trying to get it to log via syslog. I followed the instructions from the wiki for configuring radiusd to use syslog, but when radiusd starts, I get the following: # radiusd -f -l syslog Sun Jul 1 10:40:09 2007 : Info: Starting - reading configuration files ... radiusd: Couldn't open syslog/radius.log for logging: Permission denied (rlm_eap_tls: Loading the certificate file as a chain) radiusd: Couldn't open syslog/radius.log for logging: Permission denied (rlm_passwd: nfields: 2 keyfield 0(User-Name) listable: no) Output after that appears correctly via syslog. Have I missed something? Bug or feature? Kind regard -- Keep it icy man. I don't want to end up a corpse before my time because you were daydreaming.
# radiusd -f -l syslog Sun Jul 1 10:40:09 2007 : Info: Starting - reading configuration files ... radiusd: Couldn't open syslog/radius.log for logging: Permission denied (rlm_eap_tls: Loading the certificate file as a chain) radiusd: Couldn't open syslog/radius.log for logging: Permission denied (rlm_passwd: nfields: 2 keyfield 0(User-Name) listable: no)
Output after that appears correctly via syslog. Have I missed something? Bug or feature?
With FreeBSD, that almost has to be some type of permission problem. What type of account are you running freeradius under? If you are testing freeradius using, for example, "radiusd -X", while not running as root, that is most likely your problem. Not likely, but if you are trying to run freeradius from daemontools, there are instructions in the wiki for that. Basically, you have to make the process running a member of the group that has logging privileges. But again, the first suggestion is the first place to start. Jay
Jay Banks wrote:
# radiusd -f -l syslog Sun Jul 1 10:40:09 2007 : Info: Starting - reading configuration files ... radiusd: Couldn't open syslog/radius.log for logging: Permission denied (rlm_eap_tls: Loading the certificate file as a chain) radiusd: Couldn't open syslog/radius.log for logging: Permission denied (rlm_passwd: nfields: 2 keyfield 0(User-Name) listable: no)
Output after that appears correctly via syslog. Have I missed something? Bug or feature?
With FreeBSD, that almost has to be some type of permission problem. What type of account are you running freeradius under? If you are testing freeradius using, for example, "radiusd -X", while not running as root, that is most likely your problem.
Not likely, but if you are trying to run freeradius from daemontools, there are instructions in the wiki for that. Basically, you have to make the process running a member of the group that has logging privileges. But again, the first suggestion is the first place to start.
freeradius is started as the root user and should then switch to an unprivileged user-id according to the config file: user = radius group = radius But that cannot be the problem here. A relative file name of "syslog/radius.log" is obviously wrong. Presumably the file cannot be opened due to missing write permissions. Anyway, when doing syslog, no log file should be opened at all, right? Both error messages seem to originate from modules during their initialization (rlm_eap_tls / rlm_passwd). After a quick look at the source, I would say, this is due to calling radlog()/vradlog() from the module initialization or elsewhere, *before* the 'radlog_dest' variable is correctly set to RADLOG_SYSLOG in src/main/radiusd.c. After radlog_dest has been set up there, no more such error messages appear, and log goes correctly to syslog as it should. Andreas -- Keep it icy man. I don't want to end up a corpse before my time because you were daydreaming.
Both error messages seem to originate from modules during their initialization (rlm_eap_tls / rlm_passwd). After a quick look at the source, I would say, this is due to calling radlog()/vradlog() from the module initialization or elsewhere, *before* the 'radlog_dest' variable is correctly set to RADLOG_SYSLOG in src/main/radiusd.c. After radlog_dest has been set up there, no more such error messages appear, and log goes correctly to syslog as it should.
Andreas
Yes, I think you are right. I did some research and see other people have had the same problem. Here is the same problem, found in the archives for this list, which was posted back in January of 2004: BUG?? Couldn't open syslog/radius.log for logging: Not a directory Problem Summary: radiusd: radiusd: Couldn't open syslog/radius.log for logging: Not a directory Problem Detials: It appears that freeradius is attempting to log to a file when asked to to log to the syslog. Listed below is the config settings and init script to confirm correct settings. In looking at the source, it appears that RADLOG_SYSLOG is never defined and as such has a null value when being evaluated in the following code snippets: *************radiusd.c********************** #if HAVE_SYSLOG_H /* * If they asked for syslog, then give it to them. * Also, initialize the logging facility with the * configuration that they asked for. */ if (strcmp(radlog_dir, "syslog") == 0) { openlog(progname, LOG_PID, syslog_facility); radlog_dest = RADLOG_SYSLOG; } /* Do you want a warning if -g is used without a -l to activate it? */ #endif if (strcmp(radlog_dir, "stdout") == 0) { radlog_dest = RADLOG_STDOUT; } else if (strcmp(radlog_dir, "stderr") == 0) { radlog_dest = RADLOG_STDERR; } *************log.c********************** if (radlog_dest == RADLOG_NULL) { return 0; } if (debug_flag || (radlog_dest == RADLOG_STDOUT) || (radlog_dir == NULL)) { msgfd = stdout; } else if (radlog_dest == RADLOG_STDERR) { msgfd = stderr; } else if (radlog_dest != RADLOG_SYSLOG) { /* * No log file set. It must go to stdout. */ if (!mainconfig.log_file) { msgfd = stdout; /* * Else try to open the file. */ } else if ((msgfd = fopen(mainconfig.log_file, "a")) == NULL) { fprintf(stderr, "%s: Couldn't open %s for logging: %s\n", progname, mainconfig.log_file, strerror(errno)); fprintf(stderr, " ("); vfprintf(stderr, fmt, ap); /* the message that caused the log */ fprintf(stderr, ")\n"); return -1; } } #if HAVE_SYSLOG_H if (radlog_dest == RADLOG_SYSLOG) { *buffer = '\0'; len = 0; } else #endif *********CONFIGURATION FILE SETTINGS************************* prefix = /usr/local exec_prefix = ${prefix} sysconfdir = ${prefix}/etc localstatedir = ${prefix}/var sbindir = ${exec_prefix}/sbin #logdir = ${localstatedir}/log/radius logdir = syslog raddbdir = ${sysconfdir}/raddb #radacctdir = ${logdir}/radacct confdir = ${raddbdir} run_dir = ${localstatedir}/run/radiusd libdir = ${exec_prefix}/lib pidfile = ${run_dir}/radiusd.pid #user = nobody #group = nobody max_request_time = 30 delete_blocked_requests = no cleanup_delay = 5 max_requests = 1024 bind_address = XX.XX.XX.XX port = 0 hostname_lookups = no allow_core_dumps = no regular_expressions = yes extended_expressions = yes log_stripped_names = yes log_auth = yes log_auth_badpass = yes log_auth_goodpass = no *********INIT SCRIPT************************* # Source function library. . /etc/rc.d/init.d/functions RADIUSD=/usr/local/sbin/radiusd LOCKF=/var/lock/subsys/radiusd CONFIG=/usr/local/etc/raddb/radiusd.conf [ -f $RADIUSD ] || exit 0 [ -f $CONFIG ] || exit 0 RETVAL=0 case "$1" in start) echo -n $"Starting RADIUS server: " daemon $RADIUSD RETVAL=$? echo [ $RETVAL -eq 0 ] && touch $LOCKF && ln -s /var/run/radiusd/radiusd.pid /var/run/radiusd.pid 2>/dev/null ;; stop)
Jay Banks wrote:
Here is the same problem, found in the archives for this list, which was posted back in January of 2004:
BUG?? Couldn't open syslog/radius.log for logging: Not a directory
Problem Summary: radiusd: radiusd: Couldn't open syslog/radius.log for logging: Not a directory
Problem Detials: It appears that freeradius is attempting to log to a file when asked to to log to the syslog. Listed below is the config settings and init script to confirm correct settings. In looking at the source, it appears that RADLOG_SYSLOG is never defined and as such has a null value when being evaluated in the following code snippets:
*************radiusd.c**********************
#if HAVE_SYSLOG_H /* * If they asked for syslog, then give it to them. * Also, initialize the logging facility with the * configuration that they asked for. */ if (strcmp(radlog_dir, "syslog") == 0) { openlog(progname, LOG_PID, syslog_facility); radlog_dest = RADLOG_SYSLOG; } /* Do you want a warning if -g is used without a -l to activate it? */ #endif if (strcmp(radlog_dir, "stdout") == 0) { radlog_dest = RADLOG_STDOUT; } else if (strcmp(radlog_dir, "stderr") == 0) { radlog_dest = RADLOG_STDERR; }
RADLOG_SYSLOG is defined, at least in 1.1.6. The problem is that 'radlog_dest' has a default setting of: radlog_dest_t radlog_dest = RADLOG_FILES; And the above processing of the special 'syslog/stdout/stderr' keywords in 'radlog_dir' which changes 'radlog_deest' to RADLOG_SYSLOG, does not take place until after the config file(s) have been read and modules have been setup by setup_modules(). This means if anything calls radlog()/vradlog() before, then radlog_dest will contain RADLOG_FILES, and the value from 'radlog_dir' will be suffixed with the default log file name, which gives 'syslog/radius.log'. A simple solution to this problem would be to change the default setting of 'radlog_dest' to RADLOG_SYSLOG and recompile. But then you wont be able to ever log to a file again, which might be ok if you intent on using syslog only anyway. The better way is probably moving the code block, that calls setup_modules() after the block that sets up 'radlog_dest' according to the special values from radlog_dir. So the radlog_dest variable would already been set correctly when setup_modules() runs. Anyway, the best solution would be to have a separate commandline switch, whose sole purpose is to set the log destination, and which is made effective immediately when commandline option processing occurs. i.e. radiusd -g files (*default*) radiusd -g syslog@daemon radiusd -g stdout radiusd -g stderr The current '-g' commandline option, which only sets the syslog facility is BTW not documented in the program usage output. best regard, Andreas -- Keep it icy man. I don't want to end up a corpse before my time because you were daydreaming.
Perhaps this might help -- Jay-=-=-=-=-=Didn't know freeradius did syslog, cool. Anyway, just tried it out on freebsd 5.4. In man radiusd, it shows that when using -l syslog, there is also -g to specify the facility, where it also shows the default is daemon. You will need to edit /etc/syslog.conf and add daemon.* /var/log/whateverfileyouwant Touch /var/log/whateverfileyouwant and then restart syslogd and then restart freeradius with at least -l syslog. You could also use -g and specify a different facility such as local[0-7]. Make sure to touch the file first before restarting syslogd.
Andreas Wetzel wrote:
I installed freeRadius 1.1.6 on a FreeBSD 6.2-RELEASE system from the ports collection, and am trying to get it to log via syslog. I followed the instructions from the wiki for configuring radiusd to use syslog, but when radiusd starts, I get the following:
1.1.6 doesn't really do syslog well... changing that is a fair amount of work, I think. 2.0 will do it better. Alan DeKok.
participants (3)
-
Alan DeKok -
Andreas Wetzel -
Jay Banks