Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/libbb/change_identity.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/libbb/change_identity.c
r2725 r3621 34 34 void FAST_FUNC change_identity(const struct passwd *pw) 35 35 { 36 if (initgroups(pw->pw_name, pw->pw_gid) == -1) 36 int res; 37 38 res = initgroups(pw->pw_name, pw->pw_gid); 39 endgrent(); /* helps to close a fd used internally by libc */ 40 41 if (res != 0) { 42 /* 43 * If initgroups() fails because a system call is unimplemented 44 * then we are running on a Linux kernel compiled without multiuser 45 * support (CONFIG_MULTIUSER is not defined). 46 * 47 * If we are running without multiuser support *and* the target uid 48 * already matches the current uid then we can skip the change of 49 * identity. 50 */ 51 if (errno == ENOSYS && pw->pw_uid == getuid()) { 52 return; 53 } 54 37 55 bb_perror_msg_and_die("can't set groups"); 38 endgrent(); /* helps to close a fd used internally by libc */ 56 } 57 39 58 xsetgid(pw->pw_gid); 40 59 xsetuid(pw->pw_uid);
Note:
See TracChangeset
for help on using the changeset viewer.