2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 09:57:41 +00:00

tsdump: update to use a uid-based path by default

This matches the changes in sudo 1.9.15 to the sudoers policy module.
This commit is contained in:
Todd C. Miller 2023-11-26 08:21:05 -07:00
parent ce74f50b44
commit 5ff6f49653

View File

@ -112,14 +112,19 @@ main(int argc, char *argv[])
sudo_timespecsub(&now, &timediff, &timediff); sudo_timespecsub(&now, &timediff, &timediff);
if (fname == NULL) { if (fname == NULL) {
struct passwd *pw; uid_t uid;
int len;
if (user == NULL) { if (user == NULL) {
if ((pw = getpwuid(geteuid())) == NULL) uid = geteuid();
sudo_fatalx(U_("unknown uid %u"), (unsigned int)geteuid()); } else {
user = pw->pw_name; 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")); sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
} }