Set SUDO_*

This commit is contained in:
Fierelier 2023-12-11 14:31:08 +01:00
parent ec3b4ffc33
commit c46a926a04
1 changed files with 14 additions and 0 deletions

View File

@ -50,6 +50,20 @@ int main(int argc, char **argv) {
setenv("HOME",pw -> pw_dir,1);
setenv("SHELL",pw -> pw_shell,1);
// SUDO ENV
sprintf(passwStore,"%d",uid);
setenv("SUDO_UID",passwStore,1);
sprintf(passwStore,"%d",gid);
setenv("SUDO_GID",passwStore,1);
pw = getpwuid(uid);
if (pw == NULL) {
fprintf(stderr,"["APP_NAME"] Error 253: Failed to get user information (errno: %d: %s)\n",errno,strerror(errno));
return 253;
}
setenv("SUDO_USER",pw -> pw_name,1);
setenv("SUDO_HOME",pw -> pw_dir,1);
setenv("SUDO_COMMAND",pw -> pw_shell,1);
// Strip first argument, and move them by 1
char **cmd;
if (argc > 1) {