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

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