From: Todd C. Miller Date: Wed, 10 May 2000 04:56:28 +0000 (+0000) Subject: If the targetpw flag is set, use target username as part of the timestamp path. X-Git-Tag: SUDO_1_6_4~274 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=192b2ae6c35db5999af3c0a2230797baed89a0c5;p=sudo If the targetpw flag is set, use target username as part of the timestamp path. If tty tickets are in effect cat the tty and the target username with a ':' as the separator. --- diff --git a/check.c b/check.c index b6e005fb4..ada8f002c 100644 --- 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; - } } /*