From 5ff6f4965315f25f3e9153e37eb2a1021c1be775 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sun, 26 Nov 2023 08:21:05 -0700 Subject: [PATCH] tsdump: update to use a uid-based path by default This matches the changes in sudo 1.9.15 to the sudoers policy module. --- plugins/sudoers/tsdump.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/plugins/sudoers/tsdump.c b/plugins/sudoers/tsdump.c index 0002a4815..44baa944b 100644 --- a/plugins/sudoers/tsdump.c +++ b/plugins/sudoers/tsdump.c @@ -112,14 +112,19 @@ main(int argc, char *argv[]) sudo_timespecsub(&now, &timediff, &timediff); if (fname == NULL) { - struct passwd *pw; + uid_t uid; + int len; if (user == NULL) { - if ((pw = getpwuid(geteuid())) == NULL) - sudo_fatalx(U_("unknown uid %u"), (unsigned int)geteuid()); - user = pw->pw_name; + uid = geteuid(); + } else { + struct passwd *pw = getpwnam(user); + if (pw == NULL) + sudo_fatalx(U_("unknown user %s"), user); + uid = pw->pw_uid; } - if (asprintf(&fname, "%s/%s", _PATH_SUDO_TIMEDIR, user) == -1) + len = asprintf(&fname, "%s/%u", _PATH_SUDO_TIMEDIR, (unsigned int)uid); + if (len == -1) sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory")); }