Skip to content

Commit

Permalink
fake_id0: Make sudo work under PRoot.
Browse files Browse the repository at this point in the history
The program sudo changes its effective uid before checking that the
owner of /etc/sudoers is root.  As a consequence, the faked owner of
this file -- and of all other files owned by the real user -- is the
new effective uid.  Sadly, this makes sudo aborts because the owner of
/etc/sudoers is not root.  A workaround is to use the save uid as the
faked owner of all files owned by the real user.

This was tested with "makepkg -i" on a Archi Linux guest rootfs.

Ref.: fsquillace/junest#59
  • Loading branch information
cedric-vincent committed Feb 23, 2015
1 parent 28910e9 commit c3378a6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/extension/fake_id0/fake_id0.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,10 +654,10 @@ static int handle_sysexit_end(Tracee *tracee, Config *config)
/* Override only if the file is owned by the current user.
* Errors are not fatal here. */
if (uid == getuid())
poke_uint32(tracee, address + offsetof_stat_uid(tracee), config->ruid);
poke_uint32(tracee, address + offsetof_stat_uid(tracee), config->suid);

if (gid == getgid())
poke_uint32(tracee, address + offsetof_stat_gid(tracee), config->rgid);
poke_uint32(tracee, address + offsetof_stat_gid(tracee), config->sgid);

return 0;
}
Expand Down

0 comments on commit c3378a6

Please sign in to comment.