mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-31 06:15:37 +00:00
moved tty stuff into sudo.c
This commit is contained in:
15
sudo.c
15
sudo.c
@@ -132,6 +132,7 @@ char **Argv;
|
||||
char *cmnd = NULL;
|
||||
char *cmnd_args = NULL;
|
||||
char *user = NULL;
|
||||
char *tty = NULL;
|
||||
char *epasswd = NULL;
|
||||
char *prompt = PASSPROMPT;
|
||||
char *shell = NULL;
|
||||
@@ -367,6 +368,20 @@ static void load_globals(sudo_mode)
|
||||
(void) tzset(); /* set the timezone if applicable */
|
||||
#endif /* HAVE_TZSET */
|
||||
|
||||
/*
|
||||
* Need to get tty early since it's used for logging
|
||||
*/
|
||||
if ((tty = (char *) ttyname(0)) || (tty = (char *) ttyname(0))) {
|
||||
if ((p = strrchr(tty, '/')))
|
||||
tty = p + 1;
|
||||
if ((tty = strdup(tty)) == NULL) {
|
||||
perror("malloc");
|
||||
(void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
} else
|
||||
tty = "none";
|
||||
|
||||
/*
|
||||
* loading the user & epasswd global variable from the passwd file
|
||||
* (must be done as root to get real passwd on some systems)
|
||||
|
Reference in New Issue
Block a user