Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/libbb/change_identity.c
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/libbb/change_identity.c
r821 r1770 29 29 */ 30 30 31 #include <stdio.h>32 #include <errno.h>33 #include <unistd.h>34 #include <string.h>35 #include <stdlib.h>36 #include <syslog.h>37 #include <ctype.h>38 39 31 #include "libbb.h" 40 32 41 33 42 34 /* Become the user and group(s) specified by PW. */ 43 const char *change_identity_e2str ( const struct passwd *pw)35 const char *change_identity_e2str(const struct passwd *pw) 44 36 { 45 if ( initgroups ( pw-> pw_name, pw-> pw_gid ) == -1)37 if (initgroups(pw->pw_name, pw->pw_gid) == -1) 46 38 return "cannot set groups"; 47 endgrent ( ); 48 49 if ( setgid ( pw-> pw_gid )) 50 return "cannot set group id"; 51 if ( setuid ( pw->pw_uid )) 52 return "cannot set user id"; 39 endgrent(); /* ?? */ 40 xsetgid(pw->pw_gid); 41 xsetuid(pw->pw_uid); 53 42 return NULL; 54 43 } 55 44 56 void change_identity ( const struct passwd *pw)45 void change_identity(const struct passwd *pw) 57 46 { 58 47 const char *err_msg = change_identity_e2str(pw); 59 48 60 if (err_msg)61 bb_perror_msg_and_die ( "%s", err_msg);49 if (err_msg) 50 bb_perror_msg_and_die("%s", err_msg); 62 51 }
Note:
See TracChangeset
for help on using the changeset viewer.