]> granicus.if.org Git - sudo/commitdiff
PAM wants the full tty path so add user_ttypath which holds the
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 13 Sep 2007 23:05:34 +0000 (23:05 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 13 Sep 2007 23:05:34 +0000 (23:05 +0000)
full path to the tty or is NULL if no tty was present.

TODO
auth/pam.c
sudo.c
sudo.h

diff --git a/TODO b/TODO
index 130efdfb818812d9604a2db8b891d105431947b5..e1f749296242bb44eb5e944973ffac09811da3a1 100644 (file)
--- 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.
index dec53ac25b39402525c0d530f3e95e2ee0268c29..92a9f212a383a2308d3ce1247b67353ad043eac2 100644 (file)
@@ -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 2f3c39370b62453ea4c25da8a980f188551718db..e7bcd9c2d8b3d7dd7bd9fe491605ff2e7a8f8f11 100644 (file)
--- 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 44bc45bbed8491d8195318c9e7d7b883b2507b82..d79160785b29de87e74226eefa8650f9ba5b2346 100644 (file)
--- 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)