mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-23 02:17:35 +00:00
Redirect std{in,out,err} to /dev/null even when given the -n option.
This commit is contained in:
parent
955fa11b53
commit
74a0e686ac
@ -960,25 +960,25 @@ logsrvd_cleanup(void)
|
|||||||
* Fork and detatch from the terminal.
|
* Fork and detatch from the terminal.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
daemonize(void)
|
daemonize(bool nofork)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
debug_decl(daemonize, SUDO_DEBUG_UTIL)
|
debug_decl(daemonize, SUDO_DEBUG_UTIL)
|
||||||
|
|
||||||
|
if (!nofork) {
|
||||||
switch (fork()) {
|
switch (fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
sudo_fatal("fork");
|
sudo_fatal("fork");
|
||||||
case 0:
|
case 0:
|
||||||
/* child */
|
/* child, detach from terminal */
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* parent */
|
|
||||||
_exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* detach from terminal */
|
|
||||||
if (setsid() == -1)
|
if (setsid() == -1)
|
||||||
sudo_fatal("setsid");
|
sudo_fatal("setsid");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* parent, exit */
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (chdir("/") == -1)
|
if (chdir("/") == -1)
|
||||||
sudo_warn("chdir(\"/\")");
|
sudo_warn("chdir(\"/\")");
|
||||||
@ -1095,8 +1095,7 @@ main(int argc, char *argv[])
|
|||||||
logsrvd_conf_read(conf_file);
|
logsrvd_conf_read(conf_file);
|
||||||
|
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
if (!nofork)
|
daemonize(nofork);
|
||||||
daemonize();
|
|
||||||
|
|
||||||
if ((evbase = sudo_ev_base_alloc()) == NULL)
|
if ((evbase = sudo_ev_base_alloc()) == NULL)
|
||||||
sudo_fatal(NULL);
|
sudo_fatal(NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user