diff options
-rw-r--r-- | Makefile | 28 | ||||
-rw-r--r-- | chmod_chown_chgrp.c | 2 | ||||
-rw-r--r-- | cmdedit.c | 10 | ||||
-rw-r--r-- | coreutils/id.c | 2 | ||||
-rw-r--r-- | coreutils/uudecode.c | 1 | ||||
-rw-r--r-- | coreutils/uuencode.c | 1 | ||||
-rw-r--r-- | coreutils/whoami.c | 1 | ||||
-rw-r--r-- | id.c | 2 | ||||
-rw-r--r-- | include/grp.h | 47 | ||||
-rw-r--r-- | include/pwd.h | 51 | ||||
-rw-r--r-- | shell/cmdedit.c | 10 | ||||
-rw-r--r-- | utility.c | 129 | ||||
-rw-r--r-- | uudecode.c | 1 | ||||
-rw-r--r-- | uuencode.c | 1 | ||||
-rw-r--r-- | whoami.c | 1 |
15 files changed, 174 insertions, 113 deletions
@@ -42,6 +42,17 @@ DOSTATIC = false | |||
42 | # Do not enable this for production builds... | 42 | # Do not enable this for production builds... |
43 | DODEBUG = false | 43 | DODEBUG = false |
44 | 44 | ||
45 | # Setting this to `true' will cause busybox to directly use the system's | ||
46 | # password and group functions. Assuming you use GNU libc, when this is | ||
47 | # `true', you will need to install the /etc/nsswitch.conf configuration file | ||
48 | # and the required libnss_* libraries. This generally makes your embedded | ||
49 | # system quite a bit larger... If you leave this off, busybox will directly | ||
50 | # use the /etc/password, /etc/group files (and your system will be smaller, and | ||
51 | # I will get fewer emails asking about how glibc NSS works). Enabling this adds | ||
52 | # just 1.4k to the binary size (which is a _lot_ less then glibc NSS costs), | ||
53 | # Most people will want to leave this set to false. | ||
54 | USE_SYSTEM_PWD_GRP = false | ||
55 | |||
45 | # This enables compiling with dmalloc ( http://dmalloc.com/ ) | 56 | # This enables compiling with dmalloc ( http://dmalloc.com/ ) |
46 | # which is an excellent public domain mem leak and malloc problem | 57 | # which is an excellent public domain mem leak and malloc problem |
47 | # detector. To enable dmalloc, before running busybox you will | 58 | # detector. To enable dmalloc, before running busybox you will |
@@ -158,10 +169,20 @@ ifdef BB_INIT_SCRIPT | |||
158 | CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"' | 169 | CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"' |
159 | endif | 170 | endif |
160 | 171 | ||
172 | ifneq ($(USE_SYSTEM_PWD_GRP),true) | ||
173 | PWD_LIB = pwd_grp/libpwd.a | ||
174 | LIBRARIES += $(PWD_LIB) | ||
175 | else | ||
176 | CFLAGS += -DUSE_SYSTEM_PWD_GRP | ||
177 | endif | ||
178 | |||
179 | |||
161 | # Put user-supplied flags at the end, where they | 180 | # Put user-supplied flags at the end, where they |
162 | # have a chance of winning. | 181 | # have a chance of winning. |
163 | CFLAGS += $(CFLAGS_EXTRA) | 182 | CFLAGS += $(CFLAGS_EXTRA) |
164 | 183 | ||
184 | .EXPORT_ALL_VARIABLES: | ||
185 | |||
165 | all: busybox busybox.links doc | 186 | all: busybox busybox.links doc |
166 | 187 | ||
167 | doc: olddoc | 188 | doc: olddoc |
@@ -220,15 +241,19 @@ docs/busybox/busyboxdocumentation.html: docs/busybox.sgml | |||
220 | 241 | ||
221 | 242 | ||
222 | 243 | ||
223 | busybox: $(OBJECTS) | 244 | busybox: $(PWD_LIB) $(OBJECTS) |
224 | $(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES) | 245 | $(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES) |
225 | $(STRIP) | 246 | $(STRIP) |
226 | 247 | ||
248 | $(PWD_LIB): | ||
249 | $(MAKE) -eC pwd_grp | ||
250 | |||
227 | busybox.links: Config.h applets.h | 251 | busybox.links: Config.h applets.h |
228 | - $(BB_SRC_DIR)/busybox.mkll $(CONFIG_H) $(BB_SRC_DIR)/applets.h >$@ | 252 | - $(BB_SRC_DIR)/busybox.mkll $(CONFIG_H) $(BB_SRC_DIR)/applets.h >$@ |
229 | 253 | ||
230 | nfsmount.o cmdedit.o: %.o: %.h | 254 | nfsmount.o cmdedit.o: %.o: %.h |
231 | $(OBJECTS): %.o: %.c Config.h busybox.h applets.h Makefile | 255 | $(OBJECTS): %.o: %.c Config.h busybox.h applets.h Makefile |
256 | $(CC) $(CFLAGS) -c $*.c -o $*.o | ||
232 | 257 | ||
233 | utility.o: loop.h | 258 | utility.o: loop.h |
234 | 259 | ||
@@ -240,6 +265,7 @@ test tests: | |||
240 | 265 | ||
241 | clean: | 266 | clean: |
242 | - cd tests && $(MAKE) clean | 267 | - cd tests && $(MAKE) clean |
268 | - cd pwd_grp && $(MAKE) clean | ||
243 | - rm -f docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \ | 269 | - rm -f docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \ |
244 | docs/busybox.lineo.com/BusyBox.html | 270 | docs/busybox.lineo.com/BusyBox.html |
245 | - rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \ | 271 | - rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \ |
diff --git a/chmod_chown_chgrp.c b/chmod_chown_chgrp.c index 530c45658..f6ecfd6f8 100644 --- a/chmod_chown_chgrp.c +++ b/chmod_chown_chgrp.c | |||
@@ -29,8 +29,6 @@ | |||
29 | #include "messages.c" | 29 | #include "messages.c" |
30 | 30 | ||
31 | #include <stdio.h> | 31 | #include <stdio.h> |
32 | #include <grp.h> | ||
33 | #include <pwd.h> | ||
34 | 32 | ||
35 | 33 | ||
36 | static long uid = -1; | 34 | static long uid = -1; |
@@ -54,10 +54,6 @@ | |||
54 | #include <sys/stat.h> | 54 | #include <sys/stat.h> |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | #ifdef BB_FEATURE_USERNAME_COMPLETION | ||
58 | #include <pwd.h> | ||
59 | #endif | ||
60 | |||
61 | static const int MAX_HISTORY = 15; /* Maximum length of the linked list for the command line history */ | 57 | static const int MAX_HISTORY = 15; /* Maximum length of the linked list for the command line history */ |
62 | 58 | ||
63 | enum { | 59 | enum { |
@@ -354,10 +350,10 @@ static char** username_tab_completion(char *ud, int *num_matches) | |||
354 | char *temp; | 350 | char *temp; |
355 | int nm = 0; | 351 | int nm = 0; |
356 | 352 | ||
357 | setpwent (); | 353 | bb_setpwent (); |
358 | userlen = strlen (ud + 1); | 354 | userlen = strlen (ud + 1); |
359 | 355 | ||
360 | while ((entry = getpwent ()) != NULL) { | 356 | while ((entry = bb_getpwent ()) != NULL) { |
361 | /* Null usernames should result in all users as possible completions. */ | 357 | /* Null usernames should result in all users as possible completions. */ |
362 | if (!userlen || !strncmp (ud + 1, entry->pw_name, userlen)) { | 358 | if (!userlen || !strncmp (ud + 1, entry->pw_name, userlen)) { |
363 | 359 | ||
@@ -369,7 +365,7 @@ static char** username_tab_completion(char *ud, int *num_matches) | |||
369 | } | 365 | } |
370 | } | 366 | } |
371 | 367 | ||
372 | endpwent (); | 368 | bb_endpwent (); |
373 | (*num_matches) = nm; | 369 | (*num_matches) = nm; |
374 | return (matches); | 370 | return (matches); |
375 | } | 371 | } |
diff --git a/coreutils/id.c b/coreutils/id.c index 59cfafa0a..d50de4775 100644 --- a/coreutils/id.c +++ b/coreutils/id.c | |||
@@ -23,8 +23,6 @@ | |||
23 | #include "busybox.h" | 23 | #include "busybox.h" |
24 | #include <stdio.h> | 24 | #include <stdio.h> |
25 | #include <unistd.h> | 25 | #include <unistd.h> |
26 | #include <pwd.h> | ||
27 | #include <grp.h> | ||
28 | #include <getopt.h> | 26 | #include <getopt.h> |
29 | #include <sys/types.h> | 27 | #include <sys/types.h> |
30 | 28 | ||
diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c index 279b9d6ce..7b26d2dad 100644 --- a/coreutils/uudecode.c +++ b/coreutils/uudecode.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <stdio.h> | 27 | #include <stdio.h> |
28 | #include <errno.h> | 28 | #include <errno.h> |
29 | #include <getopt.h> | 29 | #include <getopt.h> |
30 | #include <pwd.h> | ||
31 | 30 | ||
32 | /*struct passwd *getpwnam();*/ | 31 | /*struct passwd *getpwnam();*/ |
33 | 32 | ||
diff --git a/coreutils/uuencode.c b/coreutils/uuencode.c index 36bc4970f..24aabd373 100644 --- a/coreutils/uuencode.c +++ b/coreutils/uuencode.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <stdio.h> | 27 | #include <stdio.h> |
28 | #include <errno.h> | 28 | #include <errno.h> |
29 | #include <getopt.h> | 29 | #include <getopt.h> |
30 | #include <pwd.h> | ||
31 | 30 | ||
32 | #define RW (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) | 31 | #define RW (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) |
33 | 32 | ||
diff --git a/coreutils/whoami.c b/coreutils/whoami.c index 38a2b3078..d7f0a177c 100644 --- a/coreutils/whoami.c +++ b/coreutils/whoami.c | |||
@@ -22,7 +22,6 @@ | |||
22 | 22 | ||
23 | #include "busybox.h" | 23 | #include "busybox.h" |
24 | #include <stdio.h> | 24 | #include <stdio.h> |
25 | #include <pwd.h> | ||
26 | 25 | ||
27 | extern int whoami_main(int argc, char **argv) | 26 | extern int whoami_main(int argc, char **argv) |
28 | { | 27 | { |
@@ -23,8 +23,6 @@ | |||
23 | #include "busybox.h" | 23 | #include "busybox.h" |
24 | #include <stdio.h> | 24 | #include <stdio.h> |
25 | #include <unistd.h> | 25 | #include <unistd.h> |
26 | #include <pwd.h> | ||
27 | #include <grp.h> | ||
28 | #include <getopt.h> | 26 | #include <getopt.h> |
29 | #include <sys/types.h> | 27 | #include <sys/types.h> |
30 | 28 | ||
diff --git a/include/grp.h b/include/grp.h new file mode 100644 index 000000000..f27c466fd --- /dev/null +++ b/include/grp.h | |||
@@ -0,0 +1,47 @@ | |||
1 | #ifndef __BB_GRP_H | ||
2 | #define __BB_GRP_H | ||
3 | |||
4 | #if defined USE_SYSTEM_PWD_GRP | ||
5 | #include <grp.h> | ||
6 | #else | ||
7 | |||
8 | #define bb_setgrent setgrent | ||
9 | #define bb_endgrent endgrent | ||
10 | #define bb_getgrent getgrent | ||
11 | #define bb_getgrgid getgrgid | ||
12 | #define bb_getgrnam getgrnam | ||
13 | #define bb_fgetgrent fgetgrent | ||
14 | #define bb_setgroups setgroups | ||
15 | #define bb_initgroups initgroups | ||
16 | #define __bb_getgrent __getgrent | ||
17 | |||
18 | #include <sys/types.h> | ||
19 | #include <features.h> | ||
20 | #include <stdio.h> | ||
21 | |||
22 | /* The group structure */ | ||
23 | struct group | ||
24 | { | ||
25 | char *gr_name; /* Group name. */ | ||
26 | char *gr_passwd; /* Password. */ | ||
27 | gid_t gr_gid; /* Group ID. */ | ||
28 | char **gr_mem; /* Member list. */ | ||
29 | }; | ||
30 | |||
31 | extern void bb_setgrent __P ((void)); | ||
32 | extern void bb_endgrent __P ((void)); | ||
33 | extern struct group * bb_getgrent __P ((void)); | ||
34 | |||
35 | extern struct group * bb_getgrgid __P ((__const gid_t gid)); | ||
36 | extern struct group * bb_getgrnam __P ((__const char * name)); | ||
37 | |||
38 | extern struct group * bb_fgetgrent __P ((FILE * file)); | ||
39 | |||
40 | extern int bb_setgroups __P ((size_t n, __const gid_t * groups)); | ||
41 | extern int bb_initgroups __P ((__const char * user, gid_t gid)); | ||
42 | |||
43 | extern struct group * __bb_getgrent __P ((int grp_fd)); | ||
44 | |||
45 | #endif /* USE_SYSTEM_PWD_GRP */ | ||
46 | #endif /* __BB_GRP_H */ | ||
47 | |||
diff --git a/include/pwd.h b/include/pwd.h new file mode 100644 index 000000000..82743f5ad --- /dev/null +++ b/include/pwd.h | |||
@@ -0,0 +1,51 @@ | |||
1 | #ifndef __BB_PWD_H | ||
2 | #define __BB_PWD_H | ||
3 | |||
4 | #if defined USE_SYSTEM_PWD_GRP | ||
5 | #include <pwd.h> | ||
6 | #else | ||
7 | |||
8 | #define bb_setpwent setpwent | ||
9 | #define bb_endpwent endpwent | ||
10 | #define bb_getpwent getpwent | ||
11 | #define bb_putpwent putpwent | ||
12 | #define bb_getpw getpw | ||
13 | #define bb_fgetpwent fgetpwent | ||
14 | #define bb_getpwuid getpwuid | ||
15 | #define bb_getpwnam getpwnam | ||
16 | #define __bb_getpwent __bb_getpwent | ||
17 | |||
18 | |||
19 | #include <sys/types.h> | ||
20 | #include <features.h> | ||
21 | #include <stdio.h> | ||
22 | |||
23 | /* The passwd structure. */ | ||
24 | struct passwd | ||
25 | { | ||
26 | char *pw_name; /* Username. */ | ||
27 | char *pw_passwd; /* Password. */ | ||
28 | uid_t pw_uid; /* User ID. */ | ||
29 | gid_t pw_gid; /* Group ID. */ | ||
30 | char *pw_gecos; /* Real name. */ | ||
31 | char *pw_dir; /* Home directory. */ | ||
32 | char *pw_shell; /* Shell program. */ | ||
33 | }; | ||
34 | |||
35 | extern void bb_setpwent __P ((void)); | ||
36 | extern void bb_endpwent __P ((void)); | ||
37 | extern struct passwd * bb_getpwent __P ((void)); | ||
38 | |||
39 | extern int bb_putpwent __P ((__const struct passwd * __p, FILE * __f)); | ||
40 | extern int bb_getpw __P ((uid_t uid, char *buf)); | ||
41 | |||
42 | extern struct passwd * bb_fgetpwent __P ((FILE * file)); | ||
43 | |||
44 | extern struct passwd * bb_getpwuid __P ((__const uid_t)); | ||
45 | extern struct passwd * bb_getpwnam __P ((__const char *)); | ||
46 | |||
47 | extern struct passwd * __bb_getpwent __P ((__const int passwd_fd)); | ||
48 | |||
49 | #endif /* USE_SYSTEM_PWD_GRP */ | ||
50 | #endif /* __BB_PWD_H */ | ||
51 | |||
diff --git a/shell/cmdedit.c b/shell/cmdedit.c index c2b4123db..e043d5f52 100644 --- a/shell/cmdedit.c +++ b/shell/cmdedit.c | |||
@@ -54,10 +54,6 @@ | |||
54 | #include <sys/stat.h> | 54 | #include <sys/stat.h> |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | #ifdef BB_FEATURE_USERNAME_COMPLETION | ||
58 | #include <pwd.h> | ||
59 | #endif | ||
60 | |||
61 | static const int MAX_HISTORY = 15; /* Maximum length of the linked list for the command line history */ | 57 | static const int MAX_HISTORY = 15; /* Maximum length of the linked list for the command line history */ |
62 | 58 | ||
63 | enum { | 59 | enum { |
@@ -354,10 +350,10 @@ static char** username_tab_completion(char *ud, int *num_matches) | |||
354 | char *temp; | 350 | char *temp; |
355 | int nm = 0; | 351 | int nm = 0; |
356 | 352 | ||
357 | setpwent (); | 353 | bb_setpwent (); |
358 | userlen = strlen (ud + 1); | 354 | userlen = strlen (ud + 1); |
359 | 355 | ||
360 | while ((entry = getpwent ()) != NULL) { | 356 | while ((entry = bb_getpwent ()) != NULL) { |
361 | /* Null usernames should result in all users as possible completions. */ | 357 | /* Null usernames should result in all users as possible completions. */ |
362 | if (!userlen || !strncmp (ud + 1, entry->pw_name, userlen)) { | 358 | if (!userlen || !strncmp (ud + 1, entry->pw_name, userlen)) { |
363 | 359 | ||
@@ -369,7 +365,7 @@ static char** username_tab_completion(char *ud, int *num_matches) | |||
369 | } | 365 | } |
370 | } | 366 | } |
371 | 367 | ||
372 | endpwent (); | 368 | bb_endpwent (); |
373 | (*num_matches) = nm; | 369 | (*num_matches) = nm; |
374 | return (matches); | 370 | return (matches); |
375 | } | 371 | } |
@@ -52,6 +52,8 @@ | |||
52 | #include <ctype.h> | 52 | #include <ctype.h> |
53 | #include <sys/ioctl.h> | 53 | #include <sys/ioctl.h> |
54 | #include <sys/utsname.h> /* for uname(2) */ | 54 | #include <sys/utsname.h> /* for uname(2) */ |
55 | #include "pwd_grp/pwd.h" | ||
56 | #include "pwd_grp/grp.h" | ||
55 | 57 | ||
56 | /* Busybox mount uses either /proc/filesystems or /dev/mtab to get the | 58 | /* Busybox mount uses either /proc/filesystems or /dev/mtab to get the |
57 | * list of available filesystems used for the -t auto option */ | 59 | * list of available filesystems used for the -t auto option */ |
@@ -856,117 +858,72 @@ extern int parse_mode(const char *s, mode_t * theMode) | |||
856 | #if defined BB_CHMOD_CHOWN_CHGRP || defined BB_PS || defined BB_LS \ | 858 | #if defined BB_CHMOD_CHOWN_CHGRP || defined BB_PS || defined BB_LS \ |
857 | || defined BB_TAR || defined BB_ID || defined BB_LOGGER \ | 859 | || defined BB_TAR || defined BB_ID || defined BB_LOGGER \ |
858 | || defined BB_LOGNAME || defined BB_WHOAMI || defined BB_SH | 860 | || defined BB_LOGNAME || defined BB_WHOAMI || defined BB_SH |
859 | |||
860 | /* This parses entries in /etc/passwd and /etc/group. This is desirable | ||
861 | * for BusyBox, since we want to avoid using the glibc NSS stuff, which | ||
862 | * increases target size and is often not needed or wanted for embedded | ||
863 | * systems. | ||
864 | * | ||
865 | * /etc/passwd entries look like this: | ||
866 | * root:x:0:0:root:/root:/bin/bash | ||
867 | * and /etc/group entries look like this: | ||
868 | * root:x:0: | ||
869 | * | ||
870 | * This uses buf as storage to hold things. | ||
871 | * | ||
872 | */ | ||
873 | unsigned long my_getid(const char *filename, char *name, long id, long *gid) | ||
874 | { | ||
875 | FILE *file; | ||
876 | char *rname, *start, *end, buf[128]; | ||
877 | long rid; | ||
878 | long rgid = 0; | ||
879 | |||
880 | file = fopen(filename, "r"); | ||
881 | if (file == NULL) { | ||
882 | /* Do not complain. It is ok for /etc/passwd and | ||
883 | * friends to be missing... */ | ||
884 | return (-1); | ||
885 | } | ||
886 | |||
887 | while (fgets(buf, 128, file) != NULL) { | ||
888 | if (buf[0] == '#') | ||
889 | continue; | ||
890 | |||
891 | /* username/group name */ | ||
892 | start = buf; | ||
893 | end = strchr(start, ':'); | ||
894 | if (end == NULL) | ||
895 | continue; | ||
896 | *end = '\0'; | ||
897 | rname = start; | ||
898 | |||
899 | /* password */ | ||
900 | start = end + 1; | ||
901 | end = strchr(start, ':'); | ||
902 | if (end == NULL) | ||
903 | continue; | ||
904 | |||
905 | /* uid in passwd, gid in group */ | ||
906 | start = end + 1; | ||
907 | rid = (unsigned long) strtol(start, &end, 10); | ||
908 | if (end == start) | ||
909 | continue; | ||
910 | |||
911 | /* gid in passwd */ | ||
912 | start = end + 1; | ||
913 | rgid = (unsigned long) strtol(start, &end, 10); | ||
914 | |||
915 | if (name) { | ||
916 | if (0 == strcmp(rname, name)) { | ||
917 | if (gid) *gid = rgid; | ||
918 | fclose(file); | ||
919 | return (rid); | ||
920 | } | ||
921 | } | ||
922 | if (id != -1 && id == rid) { | ||
923 | strncpy(name, rname, 8); | ||
924 | name[8]='\0'; | ||
925 | if (gid) *gid = rgid; | ||
926 | fclose(file); | ||
927 | return (TRUE); | ||
928 | } | ||
929 | } | ||
930 | fclose(file); | ||
931 | return (-1); | ||
932 | } | ||
933 | |||
934 | /* returns a uid given a username */ | 861 | /* returns a uid given a username */ |
935 | long my_getpwnam(char *name) | 862 | long my_getpwnam(char *name) |
936 | { | 863 | { |
937 | return my_getid("/etc/passwd", name, -1, NULL); | 864 | struct passwd *myuser; |
865 | |||
866 | myuser = getpwnam(name); | ||
867 | if (myuser==NULL) | ||
868 | error_msg_and_die( "unknown username: %s\n", name); | ||
869 | |||
870 | return myuser->pw_uid; | ||
938 | } | 871 | } |
939 | 872 | ||
940 | /* returns a gid given a group name */ | 873 | /* returns a gid given a group name */ |
941 | long my_getgrnam(char *name) | 874 | long my_getgrnam(char *name) |
942 | { | 875 | { |
943 | return my_getid("/etc/group", name, -1, NULL); | 876 | struct group *mygroup; |
877 | |||
878 | mygroup = getgrnam(name); | ||
879 | if (mygroup==NULL) | ||
880 | error_msg_and_die( "unknown group: %s\n", name); | ||
881 | |||
882 | return (mygroup->gr_gid); | ||
944 | } | 883 | } |
945 | 884 | ||
946 | /* gets a username given a uid */ | 885 | /* gets a username given a uid */ |
947 | void my_getpwuid(char *name, long uid) | 886 | void my_getpwuid(char *name, long uid) |
948 | { | 887 | { |
949 | name[0] = '\0'; | 888 | struct passwd *myuser; |
950 | my_getid("/etc/passwd", name, uid, NULL); | 889 | |
890 | myuser = getpwuid(uid); | ||
891 | if (myuser==NULL) | ||
892 | error_msg_and_die( "unknown uid %ld\n", (long)uid); | ||
893 | |||
894 | strcpy(name, myuser->pw_name); | ||
951 | } | 895 | } |
952 | 896 | ||
953 | /* gets a groupname given a gid */ | 897 | /* gets a groupname given a gid */ |
954 | void my_getgrgid(char *group, long gid) | 898 | void my_getgrgid(char *group, long gid) |
955 | { | 899 | { |
956 | group[0] = '\0'; | 900 | struct group *mygroup; |
957 | my_getid("/etc/group", group, gid, NULL); | 901 | |
902 | mygroup = getgrgid(gid); | ||
903 | if (mygroup==NULL) | ||
904 | error_msg_and_die( "unknown gid %ld\n", (long)gid); | ||
905 | |||
906 | strcpy(group, mygroup->gr_name); | ||
958 | } | 907 | } |
959 | 908 | ||
960 | #if defined BB_ID | 909 | #if defined BB_ID |
961 | /* gets a gid given a user name */ | 910 | /* gets a gid given a user name */ |
962 | long my_getpwnamegid(char *name) | 911 | long my_getpwnamegid(char *name) |
963 | { | 912 | { |
964 | long gid; | 913 | struct group *mygroup; |
965 | my_getid("/etc/passwd", name, -1, &gid); | 914 | struct passwd *myuser; |
966 | return gid; | 915 | |
967 | } | 916 | myuser=getpwnam(name); |
968 | #endif | 917 | if (myuser==NULL) |
918 | error_msg_and_die( "unknown user name: %s\n", name); | ||
969 | 919 | ||
920 | mygroup = getgrgid(myuser->pw_gid); | ||
921 | if (mygroup==NULL) | ||
922 | error_msg_and_die( "unknown gid %ld\n", (long)myuser->pw_gid); | ||
923 | |||
924 | return mygroup->gr_gid; | ||
925 | } | ||
926 | #endif /* BB_ID */ | ||
970 | #endif | 927 | #endif |
971 | /* BB_CHMOD_CHOWN_CHGRP || BB_PS || BB_LS || BB_TAR \ | 928 | /* BB_CHMOD_CHOWN_CHGRP || BB_PS || BB_LS || BB_TAR \ |
972 | || BB_ID || BB_LOGGER || BB_LOGNAME || BB_WHOAMI */ | 929 | || BB_ID || BB_LOGGER || BB_LOGNAME || BB_WHOAMI */ |
diff --git a/uudecode.c b/uudecode.c index 279b9d6ce..7b26d2dad 100644 --- a/uudecode.c +++ b/uudecode.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <stdio.h> | 27 | #include <stdio.h> |
28 | #include <errno.h> | 28 | #include <errno.h> |
29 | #include <getopt.h> | 29 | #include <getopt.h> |
30 | #include <pwd.h> | ||
31 | 30 | ||
32 | /*struct passwd *getpwnam();*/ | 31 | /*struct passwd *getpwnam();*/ |
33 | 32 | ||
diff --git a/uuencode.c b/uuencode.c index 36bc4970f..24aabd373 100644 --- a/uuencode.c +++ b/uuencode.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <stdio.h> | 27 | #include <stdio.h> |
28 | #include <errno.h> | 28 | #include <errno.h> |
29 | #include <getopt.h> | 29 | #include <getopt.h> |
30 | #include <pwd.h> | ||
31 | 30 | ||
32 | #define RW (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) | 31 | #define RW (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) |
33 | 32 | ||
@@ -22,7 +22,6 @@ | |||
22 | 22 | ||
23 | #include "busybox.h" | 23 | #include "busybox.h" |
24 | #include <stdio.h> | 24 | #include <stdio.h> |
25 | #include <pwd.h> | ||
26 | 25 | ||
27 | extern int whoami_main(int argc, char **argv) | 26 | extern int whoami_main(int argc, char **argv) |
28 | { | 27 | { |