aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
Diffstat (limited to 'libbb')
-rw-r--r--libbb/change_identity.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/libbb/change_identity.c b/libbb/change_identity.c
index b2274e0ae..f19aa8aaa 100644
--- a/libbb/change_identity.c
+++ b/libbb/change_identity.c
@@ -30,22 +30,12 @@
30 30
31#include "libbb.h" 31#include "libbb.h"
32 32
33
34/* Become the user and group(s) specified by PW. */ 33/* Become the user and group(s) specified by PW. */
35const char *change_identity_e2str(const struct passwd *pw) 34void change_identity(const struct passwd *pw)
36{ 35{
37 if (initgroups(pw->pw_name, pw->pw_gid) == -1) 36 if (initgroups(pw->pw_name, pw->pw_gid) == -1)
38 return "cannot set groups"; 37 bb_perror_msg_and_die("can't set groups");
39 endgrent(); /* ?? */ 38 endgrent(); /* ?? */
40 xsetgid(pw->pw_gid); 39 xsetgid(pw->pw_gid);
41 xsetuid(pw->pw_uid); 40 xsetuid(pw->pw_uid);
42 return NULL;
43}
44
45void change_identity(const struct passwd *pw)
46{
47 const char *err_msg = change_identity_e2str(pw);
48
49 if (err_msg)
50 bb_simple_perror_msg_and_die(err_msg);
51} 41}