Glynn Clements wrote:
> There is a similar problem for descriptors 1 and 2, particularly in
> setuid programs.
True. It isn't really a problem for daemons (deamons are usually not
suid, and started in a controlled environment), but for suid programs
yes.
What about this code:
int fd;
if(fork())
exit(0);
setsid();
close(0);
open("/dev/null, O_RDONLY);
if (!close(dup(1))) {
close(1);
open("/dev/null, O_WRONLY);
}
if (!close(dup(2))) {
dup2(1,2);
}
Keep stdout/stderr if open, else use /dev/null.
---
Henrik Nordstrom