|
|
46eb58 |
commit b2f7983c84fd01e0b29895d7df776b4b162fd8a5
|
|
|
46eb58 |
Author: Todd C. Miller <Todd.Miller@sudo.ws>
|
|
|
46eb58 |
Date: Wed Jan 2 07:39:33 2019 -0700
|
|
|
46eb58 |
|
|
|
46eb58 |
Fix setting of utmp entry when running command in a pty.
|
|
|
46eb58 |
Regression introduced in sudo 1.8.22.
|
|
|
46eb58 |
|
|
|
46eb58 |
diff --git a/src/exec_pty.c b/src/exec_pty.c
|
|
|
46eb58 |
index cbcccca3..68312a98 100644
|
|
|
46eb58 |
--- a/src/exec_pty.c
|
|
|
46eb58 |
+++ b/src/exec_pty.c
|
|
|
46eb58 |
@@ -140,7 +140,7 @@ pty_cleanup(void)
|
|
|
46eb58 |
* and slavename globals.
|
|
|
46eb58 |
*/
|
|
|
46eb58 |
static bool
|
|
|
46eb58 |
-pty_setup(uid_t uid, const char *tty)
|
|
|
46eb58 |
+pty_setup(struct command_details *details, const char *tty)
|
|
|
46eb58 |
{
|
|
|
46eb58 |
debug_decl(pty_setup, SUDO_DEBUG_EXEC);
|
|
|
46eb58 |
|
|
|
46eb58 |
@@ -152,12 +152,15 @@ pty_setup(uid_t uid, const char *tty)
|
|
|
46eb58 |
}
|
|
|
46eb58 |
|
|
|
46eb58 |
if (!get_pty(&io_fds[SFD_MASTER], &io_fds[SFD_SLAVE],
|
|
|
46eb58 |
- slavename, sizeof(slavename), uid))
|
|
|
46eb58 |
+ slavename, sizeof(slavename), details->euid))
|
|
|
46eb58 |
sudo_fatal(U_("unable to allocate pty"));
|
|
|
46eb58 |
|
|
|
46eb58 |
/* Add entry to utmp/utmpx? */
|
|
|
46eb58 |
- if (utmp_user != NULL)
|
|
|
46eb58 |
+ if (ISSET(details->flags, CD_SET_UTMP)) {
|
|
|
46eb58 |
+ utmp_user =
|
|
|
46eb58 |
+ details->utmp_user ? details->utmp_user : user_details.username;
|
|
|
46eb58 |
utmp_login(tty, slavename, io_fds[SFD_SLAVE], utmp_user);
|
|
|
46eb58 |
+ }
|
|
|
46eb58 |
|
|
|
46eb58 |
sudo_debug_printf(SUDO_DEBUG_INFO,
|
|
|
46eb58 |
"%s: %s fd %d, pty master fd %d, pty slave fd %d",
|
|
|
46eb58 |
@@ -1302,12 +1305,11 @@ exec_pty(struct command_details *details, struct command_status *cstat)
|
|
|
46eb58 |
/*
|
|
|
46eb58 |
* Allocate a pty.
|
|
|
46eb58 |
*/
|
|
|
46eb58 |
- if (pty_setup(details->euid, user_details.tty)) {
|
|
|
46eb58 |
- if (ISSET(details->flags, CD_SET_UTMP))
|
|
|
46eb58 |
- utmp_user = details->utmp_user ? details->utmp_user : user_details.username;
|
|
|
46eb58 |
- } else if (TAILQ_EMPTY(&io_plugins)) {
|
|
|
46eb58 |
- /* Not logging I/O and didn't allocate a pty. */
|
|
|
46eb58 |
- debug_return_bool(false);
|
|
|
46eb58 |
+ if (!pty_setup(details, user_details.tty)) {
|
|
|
46eb58 |
+ if (TAILQ_EMPTY(&io_plugins)) {
|
|
|
46eb58 |
+ /* Not logging I/O and didn't allocate a pty. */
|
|
|
46eb58 |
+ debug_return_bool(false);
|
|
|
46eb58 |
+ }
|
|
|
46eb58 |
}
|
|
|
46eb58 |
|
|
|
46eb58 |
/*
|