From 4f5e88532ff5ae2389f782e795b9e5dfd1e07682 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 13 Sep 2007 23:05:34 +0000 Subject: [PATCH] PAM wants the full tty path so add user_ttypath which holds the full path to the tty or is NULL if no tty was present. --- TODO | 3 +-- auth/pam.c | 4 ++-- sudo.c | 6 +++--- sudo.h | 2 ++ 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index 130efdfb8..e1f749296 100644 --- a/TODO +++ b/TODO @@ -160,5 +160,4 @@ TODO list (most will be addressed in sudo 2.0) Note that configure substitution runs on the .man.in file not the .pod file. -59) Consider making a distinction between ID and WORD in what token - gets passed in to the grammar. +59) Consolidate line wrap code. diff --git a/auth/pam.c b/auth/pam.c index dec53ac25..92a9f212a 100644 --- a/auth/pam.c +++ b/auth/pam.c @@ -99,10 +99,10 @@ pam_init(pw, promptp, auth) * will cause a crash if PAM_TTY is not set so if * there is no tty, set PAM_TTY to the empty string. */ - if (strcmp(user_tty, "unknown") == 0) + if (user_ttypath == NULL) (void) pam_set_item(pamh, PAM_TTY, ""); else - (void) pam_set_item(pamh, PAM_TTY, user_tty); + (void) pam_set_item(pamh, PAM_TTY, user_ttypath); return(AUTH_SUCCESS); } diff --git a/sudo.c b/sudo.c index 2f3c39370..e7bcd9c2d 100644 --- a/sudo.c +++ b/sudo.c @@ -553,9 +553,9 @@ init_vars(sudo_mode, envp) } if ((p = ttyname(STDIN_FILENO)) || (p = ttyname(STDOUT_FILENO))) { - if (strncmp(p, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) - p += sizeof(_PATH_DEV) - 1; - user_tty = estrdup(p); + user_tty = user_ttypath = estrdup(p); + if (strncmp(user_tty, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) + user_tty += sizeof(_PATH_DEV) - 1; } else user_tty = "unknown"; diff --git a/sudo.h b/sudo.h index 44bc45bbe..d79160785 100644 --- a/sudo.h +++ b/sudo.h @@ -41,6 +41,7 @@ struct sudo_user { char *path; char *shell; char *tty; + char *ttypath; char *host; char *shost; char **runas; @@ -129,6 +130,7 @@ struct sudo_user { #define user_ngroups (sudo_user.ngroups) #define user_groups (sudo_user.groups) #define user_tty (sudo_user.tty) +#define user_ttypath (sudo_user.ttypath) #define user_cwd (sudo_user.cwd) #define user_runas (sudo_user.runas) #define user_cmnd (sudo_user.cmnd) -- 2.40.0