]> granicus.if.org Git - sudo/commitdiff
Store the session ID in the tty ticket file too. A tty may only
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 25 Feb 2013 19:49:18 +0000 (14:49 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 25 Feb 2013 19:49:18 +0000 (14:49 -0500)
be in one session at a time so if the session ID doesn't match we
ignore the ticket.

--HG--
branch : 1.8

plugins/sudoers/check.c
plugins/sudoers/sudoers.c
plugins/sudoers/sudoers.h

index 21cb2b196f3e51e3bfef707dd9c7284a4830a105..e7134760e5bcf96f1bc3015ea44a58ef94fd74ef 100644 (file)
@@ -82,6 +82,7 @@ static struct tty_info {
     dev_t rdev;                        /* tty device ID */
     ino_t ino;                 /* tty inode number */
     struct timeval ctime;      /* tty inode change time */
+    pid_t sid;                 /* ID of session with controlling tty */
 } tty_info;
 
 static int   build_timestamp(char **, char **);
@@ -138,13 +139,14 @@ check_user(int validated, int mode)
     if (ISSET(mode, MODE_IGNORE_TICKET))
        SET(validated, FLAG_CHECK_USER);
 
-    /* Stash the tty's ctime for tty ticket comparison. */
+    /* Stash the tty's device, session ID and ctime for ticket comparison. */
     if (def_tty_tickets && user_ttypath && stat(user_ttypath, &sb) == 0) {
        tty_info.dev = sb.st_dev;
        tty_info.ino = sb.st_ino;
        tty_info.rdev = sb.st_rdev;
        if (tty_is_devpts(user_ttypath))
            ctim_get(&sb, &tty_info.ctime);
+       tty_info.sid = user_sid;
     }
 
     if (build_timestamp(&timestampdir, &timestampfile) == -1) {
index b4f9a3a45acf7a861342355c3062b25a53b9efee..0399acd072fdf5da40202c4bdb2647f4f31b9f5b 100644 (file)
@@ -1410,6 +1410,10 @@ deserialize_info(char * const args[], char * const settings[], char * const user
            sudo_user.cols = atoi(*cur + sizeof("cols=") - 1);
            continue;
        }
+       if (MATCHES(*cur, "sid=")) {
+           sudo_user.sid = atoi(*cur + sizeof("sid=") - 1);
+           continue;
+       }
     }
     if (user_cwd == NULL)
        user_cwd = "unknown";
index 0dd061fe10050edf02a0cb0dbd642520ee1b4008..e69a9779d014daf51f3bf2afe7ab3f8fead0de5e 100644 (file)
@@ -95,6 +95,7 @@ struct sudo_user {
     int   flags;
     uid_t uid;
     uid_t gid;
+    pid_t sid;
 };
 
 /*
@@ -171,8 +172,8 @@ struct sudo_user {
 #define user_name              (sudo_user.name)
 #define user_uid               (sudo_user.uid)
 #define user_gid               (sudo_user.gid)
+#define user_sid               (sudo_user.sid)
 #define user_passwd            (sudo_user.pw->pw_passwd)
-#define user_uuid              (sudo_user.uuid)
 #define user_dir               (sudo_user.pw->pw_dir)
 #define user_gids              (sudo_user.gids)
 #define user_ngids             (sudo_user.ngids)