Blame SOURCES/sudo-1.8.23-who-am-i.patch

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