bug-gnu-radius
[Top][All Lists]
Advanced

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

[Bug-gnu-radius] exec.c: opening a logfile should append or truncate


From: Maurice Makaay
Subject: [Bug-gnu-radius] exec.c: opening a logfile should append or truncate
Date: Tue, 4 Nov 2003 18:06:30 +0100

Hi,

If you use an error-log for a filter and the filter / radiusserver is
restarted, the logging will be written to the start of the logfile,
without truncating it first. Therefore you'll end up with a mixture
of old and new logging output in one file where there might be old data
after the new data the logfile starts out with. Very confusing...

The problem is in the function radius_run_filter() of exec.c. There the
logfile is opened like this:

    /* Error output */
    i = open(errfile, O_CREAT|O_WRONLY, 0644);
    if (i > 0 && i != 2) {
        dup2(i, 2);
        close(i);
    }

My proposal is to change this to:

    /* Error output */
    i = open(errfile, O_CREAT|O_APPEND|O_WRONLY, 0644);
    if (i > 0 && i != 2) {
        dup2(i, 2);
        close(i);
    }

Another possibility would be to use O_TRUNC instead of O_APPEND, so the 
logfile will be truncated prior to writing to it. However, I prefer 
appending new loglines to it, because else important error messages 
might be lost in the process. This is especially important in case of
dramatically dying spawned programs.


Regards,

-- Maurice Makaay




reply via email to

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