Eliminate utmp_user global, just use the value in struct command details.
This commit is contained in:
@@ -59,7 +59,6 @@ static struct monitor_message_list monitor_messages =
|
||||
|
||||
/* Globals for the pty_cleanup() hook. */
|
||||
static char ptyname[PATH_MAX];
|
||||
static const char *utmp_user;
|
||||
|
||||
static void sync_ttysize(struct exec_closure *ec);
|
||||
static void schedule_signal(struct exec_closure *ec, int signo);
|
||||
@@ -89,11 +88,8 @@ pty_setup(struct command_details *details, const char *tty)
|
||||
details->tty = ptyname;
|
||||
|
||||
/* Add entry to utmp/utmpx? */
|
||||
if (ISSET(details->flags, CD_SET_UTMP)) {
|
||||
utmp_user =
|
||||
details->utmp_user ? details->utmp_user : user_details.username;
|
||||
utmp_login(tty, ptyname, io_fds[SFD_FOLLOWER], utmp_user);
|
||||
}
|
||||
if (ISSET(details->flags, CD_SET_UTMP))
|
||||
utmp_login(tty, ptyname, io_fds[SFD_FOLLOWER], details->utmp_user);
|
||||
|
||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||
"%s: %s fd %d, pty leader fd %d, pty follower fd %d",
|
||||
@@ -138,7 +134,7 @@ pty_cleanup_int(struct exec_closure *ec, int wstatus, bool init_only)
|
||||
}
|
||||
|
||||
/* Update utmp */
|
||||
if (utmp_user != NULL)
|
||||
if (ISSET(ec->details->flags, CD_SET_UTMP) && ptyname[0] != '\0')
|
||||
utmp_logout(ptyname, wstatus);
|
||||
|
||||
debug_return;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: ISC
|
||||
*
|
||||
* Copyright (c) 2009-2022 Todd C. Miller <Todd.Miller@sudo.ws>
|
||||
* Copyright (c) 2009-2023 Todd C. Miller <Todd.Miller@sudo.ws>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -869,6 +869,8 @@ command_info_to_details(char * const info[], struct command_details *details)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (details->utmp_user == NULL)
|
||||
details->utmp_user = user_details.username;
|
||||
|
||||
/* Only use ptrace(2) for intercept/log_subcmds if supported. */
|
||||
exec_ptrace_fix_flags(details);
|
||||
|
Reference in New Issue
Block a user