diff --git a/src/script.c b/src/script.c index 48e933f73..e007a07ac 100644 --- a/src/script.c +++ b/src/script.c @@ -138,8 +138,8 @@ static int safe_close(int fd); extern struct user_details user_details; /* XXX */ -void -script_setup(uid_t uid) +static void +pty_setup(uid_t uid) { script_fds[SFD_USERTTY] = open(_PATH_TTY, O_RDWR|O_NOCTTY, 0); if (script_fds[SFD_USERTTY] != -1) { @@ -500,6 +500,10 @@ script_execve(struct command_details *details, char *argv[], char *envp[], cstat->type = CMD_INVALID; log_io = !tq_empty(&io_plugins); + if (log_io) { + sudo_debug(8, "allocate pty for I/O logging"); + pty_setup(details->euid); + } #ifdef HAVE_SELINUX rbac_enabled = is_selinux_enabled() > 0 && details->selinux_role != NULL; diff --git a/src/sudo.c b/src/sudo.c index 577397b83..705a361d4 100644 --- a/src/sudo.c +++ b/src/sudo.c @@ -789,15 +789,9 @@ run_command(struct command_details *details, char *argv[], char *envp[]) cstat.val = 0; /* - * XXX - missing closefrom(), may not be possible in new scheme - * also no background support + * XXX - no background support */ - /* If there are I/O plugins, allocate a pty and exec */ - if (!tq_empty(&io_plugins)) { - sudo_debug(8, "setup I/O logging"); - script_setup(details->euid); - } script_execve(details, argv, envp, &cstat); switch (cstat.type) { diff --git a/src/sudo.h b/src/sudo.h index 8c558e3ae..86a2ebfde 100644 --- a/src/sudo.h +++ b/src/sudo.h @@ -160,7 +160,6 @@ void zero_bytes(volatile void *, size_t); /* script.c */ int script_execve(struct command_details *details, char *argv[], char *envp[], struct command_status *cstat); -void script_setup(uid_t); /* term.c */ int term_cbreak(int);