Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
$*USER and $*GROUP don't update when uid/gid change #4728
I recently committed the starts of a POSIX module to the p6 ecosystem and noticed that when using the POSIX::setuid and POSIX::setgid function calls, the $*USER and $*GROUP variables to not update as expected when program privileges change.
I have attached a sample program demonstrating this below. Note that the program must be run as root.
Here is the output on my machine:
~$ sudo perl6 ./uid-gid.p6
POSIX::getuid reports UID as: 0
Dropping privileges to 'nobody' user...
$*USER reports UID as: 0
POSIX::getuid reports UID as: 65534
The default implementation of $*USER and $*GROUP call an external program and parses the result at the moment. This is something you do not want to do for every access to $*USER.
I recommend that the POSIX module installs its own version of $*USER / $*GROUP handling in PROCESS::<$USER> and PROCESS::<$GROUP>, which can then correctly reflect changes in privileges. Something akin to:
PROCESS::<$USER> := POSIX::getuid;
My advise: ENOTABUG, can be closed.