2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 01:49:11 +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);
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"));
}