]> granicus.if.org Git - sudo/commitdiff
If the targetpw flag is set, use target username as part of the timestamp path.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 10 May 2000 04:56:28 +0000 (04:56 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 10 May 2000 04:56:28 +0000 (04:56 +0000)
If tty tickets are in effect cat the tty and the target username with a
':' as the separator.

check.c

diff --git a/check.c b/check.c
index b6e005fb48fbb9f817ac6332961c04d1f12563ff..ada8f002c343fbe102e5124a59d5e12a03fb05da 100644 (file)
--- a/check.c
+++ b/check.c
@@ -251,8 +251,18 @@ build_timestamp(timestampdir, timestampfile)
     char **timestampdir;
     char **timestampfile;
 {
-    char *dirparent = def_str(I_TIMESTAMPDIR);
+    char *dirparent;
+    int len;
+
+    dirparent = def_str(I_TIMESTAMPDIR);
+    len = easprintf(timestampdir, "%s/%s", dirparent, user_name);
+    if (len >= MAXPATHLEN)
+       log_error(0, "timestamp path too long: %s", timestampdir);
 
+    /*
+     * Timestamp file may be a file in the directory or NUL to use
+     * the directory as the timestamp.
+     */
     if (def_flag(I_TTY_TICKETS)) {
        char *p;
 
@@ -260,17 +270,20 @@ build_timestamp(timestampdir, timestampfile)
            p++;
        else
            p = user_tty;
-       if (strlen(dirparent) + strlen(user_name) + strlen(p) + 3 > MAXPATHLEN)
-           log_error(0, "timestamp path too long: %s/%s/%s", dirparent,
-               user_name, p);
-       easprintf(timestampdir, "%s/%s", dirparent, user_name);
-       easprintf(timestampfile, "%s/%s/%s", dirparent, user_name, p);
-    } else {
-       if (strlen(dirparent) + strlen(user_name) + 2 > MAXPATHLEN)
-           log_error(0, "timestamp path too long: %s/%s", dirparent, user_name);
-       easprintf(timestampdir, "%s/%s", dirparent, user_name);
+       if (def_flag(I_TARGETPW))
+           len = easprintf(timestampfile, "%s/%s/%s:%s", dirparent, user_name,
+               p, *user_runas);
+       else
+           len = easprintf(timestampfile, "%s/%s/%s", dirparent, user_name, p);
+       if (len >= MAXPATHLEN)
+           log_error(0, "timestamp path too long: %s", timestampfile);
+    } else if (def_flag(I_TARGETPW)) {
+       len = easprintf(timestampfile, "%s/%s/%s", dirparent, user_name,
+           *user_runas);
+       if (len >= MAXPATHLEN)
+           log_error(0, "timestamp path too long: %s", timestampfile);
+    } else
        *timestampfile = NULL;
-    }
 }
 
 /*