|
|
@ -102,12 +102,14 @@ int main(int argc, char *argv[]) |
|
|
|
fprintf(stderr, "getpwid: %s\n", strerror(errno)); |
|
|
|
fprintf(stderr, "getpwid: %s\n", strerror(errno)); |
|
|
|
return errno; |
|
|
|
return errno; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
char *my_name = strdup(my_pw->pw_name); |
|
|
|
|
|
|
|
if (!my_name) |
|
|
|
|
|
|
|
die("strdup:"); |
|
|
|
|
|
|
|
|
|
|
|
/* Authenticate, we will be root from now on */ |
|
|
|
/* Authenticate, we will be root from now on */ |
|
|
|
if (authenticate(my_pw->pw_uid, 0)) |
|
|
|
if (authenticate(my_pw->pw_uid, 0)) |
|
|
|
exit(EXIT_FAILURE); |
|
|
|
exit(EXIT_FAILURE); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Get target user and group info */ |
|
|
|
/* Get target user and group info */ |
|
|
|
t_pw = user_to_passwd(t_usr); |
|
|
|
t_pw = user_to_passwd(t_usr); |
|
|
|
if (!t_pw) |
|
|
|
if (!t_pw) |
|
|
@ -169,8 +171,11 @@ int main(int argc, char *argv[]) |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if (envflag) { /* clear env */ |
|
|
|
if (envflag) { /* clear env */ |
|
|
|
for (int i = 0; env_keep[i].name; i++) |
|
|
|
for (int i = 0; env_keep[i].name; i++) { |
|
|
|
env_keep[i].value = strdup(getenv(env_keep[i].name)); |
|
|
|
env_keep[i].value = strdup(getenv(env_keep[i].name)); |
|
|
|
|
|
|
|
if (!env_keep[i].value) |
|
|
|
|
|
|
|
die("strdup:"); |
|
|
|
|
|
|
|
} |
|
|
|
environ = NULL; // in place of clearenv
|
|
|
|
environ = NULL; // in place of clearenv
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -194,7 +199,8 @@ int main(int argc, char *argv[]) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// do not override, we might be under more levels of 'us'
|
|
|
|
// do not override, we might be under more levels of 'us'
|
|
|
|
err = setenv("US_USER", my_pw->pw_name, 0); |
|
|
|
err = setenv("US_USER", my_name, 0); |
|
|
|
|
|
|
|
free(my_name); |
|
|
|
|
|
|
|
|
|
|
|
errno = 0; |
|
|
|
errno = 0; |
|
|
|
/* Set permissions */ |
|
|
|
/* Set permissions */ |
|
|
|