On Tue, Jan 29, 2002 at 11:26:05PM +0000, Miquel van Smoorenburg wrote: > In article <[EMAIL PROTECTED]>, > <[EMAIL PROTECTED]> wrote: > >"Carlos Velasco" <[EMAIL PROTECTED]> wrote: > >> I have commented these lines and compiled: > >> > >> /* if we're running as a daemon, close other file descriptors. */ > >> if (debug_flag =3D=3D FALSE) { > >> close(STDIN_FILENO); > >> close(STDOUT_FILENO); > >> close(STDERR_FILENO); > >> } > >> > >> It works, although I don't know why this fail. > > > > Hmm... It looks like something is closing stdout (or whatever), > >opening it as the acct_fd, and then this code closes it. That's bad. > > It can get worse. If you close(STDOUT_FILENO) and/or STDERR_FILENO, > then the next open will get fd#1 or fd#2. That could be your SQL > socket, or whatever. Now anything that calls printf() or perror() > or something (some libc routines do! yuck!) will write to a random > filedescriptor.
The well behaved daemon closes existing open file descriptors. If your daemon calls code that would do perror(), etc. it is buggy. Given that freeradius has exec-program-wait, it probably should close these and reopen them /dev/null (unless -X). /fc - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
