Skip to content

Commit

Permalink
tsdump: update to use a uid-based path by default
Browse files Browse the repository at this point in the history
This matches the changes in sudo 1.9.15 to the sudoers policy module.
  • Loading branch information
millert committed Nov 26, 2023
1 parent ce74f50 commit 5ff6f49
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions plugins/sudoers/tsdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}

Expand Down

0 comments on commit 5ff6f49

Please sign in to comment.