aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-12-30 21:11:57 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-12-30 21:11:57 +0000
commit42a8c1bf937d50f9d9d94255064bba1577f5ae2d (patch)
treeadde9e8d46920ae48f3768e6b7fa76bdd123f618
parenta3adb6f4577bd75a302749299472c8227995c1bf (diff)
downloadbusybox-w32-42a8c1bf937d50f9d9d94255064bba1577f5ae2d.tar.gz
busybox-w32-42a8c1bf937d50f9d9d94255064bba1577f5ae2d.tar.bz2
busybox-w32-42a8c1bf937d50f9d9d94255064bba1577f5ae2d.zip
fixdep.c: avoit doing memcmp in most cases
uidgid_get.c: add forgotten copyright notice pwd/grp/shadow: avoid collisions with libc names git-svn-id: svn://busybox.net/trunk/busybox@17112 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--include/grp_.h74
-rw-r--r--include/pwd_.h71
-rw-r--r--include/shadow_.h26
-rw-r--r--libpwdgrp/pwd_grp.c85
-rw-r--r--libpwdgrp/pwd_grp_internal.c10
-rw-r--r--libpwdgrp/uidgid_get.c27
-rw-r--r--scripts/basic/fixdep.c6
7 files changed, 191 insertions, 108 deletions
diff --git a/include/grp_.h b/include/grp_.h
index b34addfa2..061b86ef7 100644
--- a/include/grp_.h
+++ b/include/grp_.h
@@ -21,50 +21,71 @@
21 * POSIX Standard: 9.2.1 Group Database Access <grp.h> 21 * POSIX Standard: 9.2.1 Group Database Access <grp.h>
22 */ 22 */
23 23
24#if !ENABLE_USE_BB_PWD_GRP
24 25
25#if !defined CONFIG_USE_BB_PWD_GRP
26#include <grp.h> 26#include <grp.h>
27 27
28#else 28#else
29 29
30#ifndef _GRP_H 30#ifndef _GRP_H
31#define _GRP_H 1 31#define _GRP_H 1
32
33#include <sys/types.h>
34#include <features.h>
35#include <stdio.h>
36 32
37/* The group structure. */ 33/* The group structure. */
38struct group 34struct group {
39{ 35 char *gr_name; /* Group name. */
40 char *gr_name; /* Group name. */ 36 char *gr_passwd; /* Password. */
41 char *gr_passwd; /* Password. */ 37 gid_t gr_gid; /* Group ID. */
42 gid_t gr_gid; /* Group ID. */ 38 char **gr_mem; /* Member list. */
43 char **gr_mem; /* Member list. */
44}; 39};
45 40
41/* We don't reimplement this, just supplying prototype */
42/* The function itself is in libc */
43/* Set the group set for the current user to GROUPS (N of them). */
44extern int setgroups(size_t __n, __const gid_t *__groups);
45
46
47#define setgrent bb_internal_setgrent
48#define endgrent bb_internal_endgrent
49#define getgrent bb_internal_getgrent
50#define fgetgrent bb_internal_fgetgrent
51#define putgrent bb_internal_putgrent
52#define getgrgid bb_internal_getgrgid
53#define getgrnam bb_internal_getgrnam
54#define getgrent_r bb_internal_getgrent_r
55#define getgrgid_r bb_internal_getgrgid_r
56#define getgrnam_r bb_internal_getgrnam_r
57#define fgetgrent_r bb_internal_fgetgrent_r
58#define getgrouplist bb_internal_getgrouplist
59#define initgroups bb_internal_initgroups
60
61
62/* All function names below should be remapped by #defines above
63 * in order to not collide with libc names.
64 * In theory it isn't necessary, but I saw weird interactions at link time.
65 * Let's play safe */
66
46 67
47/* Rewind the group-file stream. */ 68/* Rewind the group-file stream. */
48extern void setgrent (void); 69extern void setgrent(void);
49 70
50/* Close the group-file stream. */ 71/* Close the group-file stream. */
51extern void endgrent (void); 72extern void endgrent(void);
52 73
53/* Read an entry from the group-file stream, opening it if necessary. */ 74/* Read an entry from the group-file stream, opening it if necessary. */
54extern struct group *getgrent (void); 75extern struct group *getgrent(void);
55 76
56/* Read a group entry from STREAM. */ 77/* Read a group entry from STREAM. */
57extern struct group *fgetgrent (FILE *__stream); 78extern struct group *fgetgrent(FILE *__stream);
58 79
59/* Write the given entry onto the given stream. */ 80/* Write the given entry onto the given stream. */
60extern int putgrent (__const struct group *__restrict __p, 81extern int putgrent(__const struct group *__restrict __p,
61 FILE *__restrict __f); 82 FILE *__restrict __f);
62 83
63/* Search for an entry with a matching group ID. */ 84/* Search for an entry with a matching group ID. */
64extern struct group *getgrgid (gid_t __gid); 85extern struct group *getgrgid(gid_t __gid);
65 86
66/* Search for an entry with a matching group name. */ 87/* Search for an entry with a matching group name. */
67extern struct group *getgrnam (__const char *__name); 88extern struct group *getgrnam(__const char *__name);
68 89
69/* Reentrant versions of some of the functions above. 90/* Reentrant versions of some of the functions above.
70 91
@@ -74,41 +95,38 @@ extern struct group *getgrnam (__const char *__name);
74 other reentrant functions so the chances are good this is what the 95 other reentrant functions so the chances are good this is what the
75 POSIX people would choose. */ 96 POSIX people would choose. */
76 97
77extern int getgrent_r (struct group *__restrict __resultbuf, 98extern int getgrent_r(struct group *__restrict __resultbuf,
78 char *__restrict __buffer, size_t __buflen, 99 char *__restrict __buffer, size_t __buflen,
79 struct group **__restrict __result); 100 struct group **__restrict __result);
80 101
81/* Search for an entry with a matching group ID. */ 102/* Search for an entry with a matching group ID. */
82extern int getgrgid_r (gid_t __gid, struct group *__restrict __resultbuf, 103extern int getgrgid_r(gid_t __gid, struct group *__restrict __resultbuf,
83 char *__restrict __buffer, size_t __buflen, 104 char *__restrict __buffer, size_t __buflen,
84 struct group **__restrict __result); 105 struct group **__restrict __result);
85 106
86/* Search for an entry with a matching group name. */ 107/* Search for an entry with a matching group name. */
87extern int getgrnam_r (__const char *__restrict __name, 108extern int getgrnam_r(__const char *__restrict __name,
88 struct group *__restrict __resultbuf, 109 struct group *__restrict __resultbuf,
89 char *__restrict __buffer, size_t __buflen, 110 char *__restrict __buffer, size_t __buflen,
90 struct group **__restrict __result); 111 struct group **__restrict __result);
91 112
92/* Read a group entry from STREAM. This function is not standardized 113/* Read a group entry from STREAM. This function is not standardized
93 an probably never will. */ 114 an probably never will. */
94extern int fgetgrent_r (FILE *__restrict __stream, 115extern int fgetgrent_r(FILE *__restrict __stream,
95 struct group *__restrict __resultbuf, 116 struct group *__restrict __resultbuf,
96 char *__restrict __buffer, size_t __buflen, 117 char *__restrict __buffer, size_t __buflen,
97 struct group **__restrict __result); 118 struct group **__restrict __result);
98 119
99/* Set the group set for the current user to GROUPS (N of them). */
100extern int setgroups (size_t __n, __const gid_t *__groups);
101
102/* Store at most *NGROUPS members of the group set for USER into 120/* Store at most *NGROUPS members of the group set for USER into
103 *GROUPS. Also include GROUP. The actual number of groups found is 121 *GROUPS. Also include GROUP. The actual number of groups found is
104 returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. */ 122 returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. */
105extern int getgrouplist (__const char *__user, gid_t __group, 123extern int getgrouplist(__const char *__user, gid_t __group,
106 gid_t *__groups, int *__ngroups); 124 gid_t *__groups, int *__ngroups);
107 125
108/* Initialize the group set for the current user 126/* Initialize the group set for the current user
109 by reading the group database and using all groups 127 by reading the group database and using all groups
110 of which USER is a member. Also include GROUP. */ 128 of which USER is a member. Also include GROUP. */
111extern int initgroups (__const char *__user, gid_t __group); 129extern int initgroups(__const char *__user, gid_t __group);
112 130
113 131
114#endif /* grp.h */ 132#endif /* grp.h */
diff --git a/include/pwd_.h b/include/pwd_.h
index d161c0e8f..f47e4eb2c 100644
--- a/include/pwd_.h
+++ b/include/pwd_.h
@@ -21,52 +21,68 @@
21 * POSIX Standard: 9.2.2 User Database Access <pwd.h> 21 * POSIX Standard: 9.2.2 User Database Access <pwd.h>
22 */ 22 */
23 23
24#if !defined CONFIG_USE_BB_PWD_GRP 24#if !ENABLE_USE_BB_PWD_GRP
25
25#include <pwd.h> 26#include <pwd.h>
26 27
27#else 28#else
28 29
29#ifndef _PWD_H 30#ifndef _PWD_H
30#define _PWD_H 1 31#define _PWD_H 1
31
32#include <sys/types.h>
33#include <features.h>
34#include <stdio.h>
35 32
36/* The passwd structure. */ 33/* The passwd structure. */
37struct passwd 34struct passwd {
38{ 35 char *pw_name; /* Username. */
39 char *pw_name; /* Username. */ 36 char *pw_passwd; /* Password. */
40 char *pw_passwd; /* Password. */ 37 uid_t pw_uid; /* User ID. */
41 uid_t pw_uid; /* User ID. */ 38 gid_t pw_gid; /* Group ID. */
42 gid_t pw_gid; /* Group ID. */ 39 char *pw_gecos; /* Real name. */
43 char *pw_gecos; /* Real name. */ 40 char *pw_dir; /* Home directory. */
44 char *pw_dir; /* Home directory. */ 41 char *pw_shell; /* Shell program. */
45 char *pw_shell; /* Shell program. */
46}; 42};
47 43
48 44
45#define setpwent bb_internal_setpwent
46#define endpwent bb_internal_endpwent
47#define getpwent bb_internal_getpwent
48#define fgetpwent bb_internal_fgetpwent
49#define putpwent bb_internal_putpwent
50#define getpwuid bb_internal_getpwuid
51#define getpwnam bb_internal_getpwnam
52#define getpwent_r bb_internal_getpwent_r
53#define getpwuid_r bb_internal_getpwuid_r
54#define getpwnam_r bb_internal_getpwnam_r
55#define fgetpwent_r bb_internal_fgetpwent_r
56#define getpw bb_internal_getpw
57
58
59/* All function names below should be remapped by #defines above
60 * in order to not collide with libc names.
61 * In theory it isn't necessary, but I saw weird interactions at link time.
62 * Let's play safe */
63
64
49/* Rewind the password-file stream. */ 65/* Rewind the password-file stream. */
50extern void setpwent (void); 66extern void setpwent(void);
51 67
52/* Close the password-file stream. */ 68/* Close the password-file stream. */
53extern void endpwent (void); 69extern void endpwent(void);
54 70
55/* Read an entry from the password-file stream, opening it if necessary. */ 71/* Read an entry from the password-file stream, opening it if necessary. */
56extern struct passwd *getpwent (void); 72extern struct passwd *getpwent(void);
57 73
58/* Read an entry from STREAM. */ 74/* Read an entry from STREAM. */
59extern struct passwd *fgetpwent (FILE *__stream); 75extern struct passwd *fgetpwent(FILE *__stream);
60 76
61/* Write the given entry onto the given stream. */ 77/* Write the given entry onto the given stream. */
62extern int putpwent (__const struct passwd *__restrict __p, 78extern int putpwent(__const struct passwd *__restrict __p,
63 FILE *__restrict __f); 79 FILE *__restrict __f);
64 80
65/* Search for an entry with a matching user ID. */ 81/* Search for an entry with a matching user ID. */
66extern struct passwd *getpwuid (uid_t __uid); 82extern struct passwd *getpwuid(uid_t __uid);
67 83
68/* Search for an entry with a matching username. */ 84/* Search for an entry with a matching username. */
69extern struct passwd *getpwnam (__const char *__name); 85extern struct passwd *getpwnam(__const char *__name);
70 86
71/* Reentrant versions of some of the functions above. 87/* Reentrant versions of some of the functions above.
72 88
@@ -76,24 +92,23 @@ extern struct passwd *getpwnam (__const char *__name);
76 other reentrant functions so the chances are good this is what the 92 other reentrant functions so the chances are good this is what the
77 POSIX people would choose. */ 93 POSIX people would choose. */
78 94
79extern int getpwent_r (struct passwd *__restrict __resultbuf, 95extern int getpwent_r(struct passwd *__restrict __resultbuf,
80 char *__restrict __buffer, size_t __buflen, 96 char *__restrict __buffer, size_t __buflen,
81 struct passwd **__restrict __result); 97 struct passwd **__restrict __result);
82 98
83extern int getpwuid_r (uid_t __uid, 99extern int getpwuid_r(uid_t __uid,
84 struct passwd *__restrict __resultbuf, 100 struct passwd *__restrict __resultbuf,
85 char *__restrict __buffer, size_t __buflen, 101 char *__restrict __buffer, size_t __buflen,
86 struct passwd **__restrict __result); 102 struct passwd **__restrict __result);
87 103
88extern int getpwnam_r (__const char *__restrict __name, 104extern int getpwnam_r(__const char *__restrict __name,
89 struct passwd *__restrict __resultbuf, 105 struct passwd *__restrict __resultbuf,
90 char *__restrict __buffer, size_t __buflen, 106 char *__restrict __buffer, size_t __buflen,
91 struct passwd **__restrict __result); 107 struct passwd **__restrict __result);
92 108
93
94/* Read an entry from STREAM. This function is not standardized and 109/* Read an entry from STREAM. This function is not standardized and
95 probably never will. */ 110 probably never will. */
96extern int fgetpwent_r (FILE *__restrict __stream, 111extern int fgetpwent_r(FILE *__restrict __stream,
97 struct passwd *__restrict __resultbuf, 112 struct passwd *__restrict __resultbuf,
98 char *__restrict __buffer, size_t __buflen, 113 char *__restrict __buffer, size_t __buflen,
99 struct passwd **__restrict __result); 114 struct passwd **__restrict __result);
@@ -101,7 +116,7 @@ extern int fgetpwent_r (FILE *__restrict __stream,
101/* Re-construct the password-file line for the given uid 116/* Re-construct the password-file line for the given uid
102 in the given buffer. This knows the format that the caller 117 in the given buffer. This knows the format that the caller
103 will expect, but this need not be the format of the password file. */ 118 will expect, but this need not be the format of the password file. */
104extern int getpw (uid_t __uid, char *__buffer); 119extern int getpw(uid_t __uid, char *__buffer);
105 120
106#endif /* pwd.h */ 121#endif /* pwd.h */
107#endif 122#endif
diff --git a/include/shadow_.h b/include/shadow_.h
index 634dfb466..fb2153c52 100644
--- a/include/shadow_.h
+++ b/include/shadow_.h
@@ -20,11 +20,13 @@
20/* Declaration of types and functions for shadow password suite */ 20/* Declaration of types and functions for shadow password suite */
21 21
22#if !ENABLE_USE_BB_SHADOW 22#if !ENABLE_USE_BB_SHADOW
23
23#include <shadow.h> 24#include <shadow.h>
25
24#else 26#else
25 27
26#ifndef _SHADOW_H 28#ifndef _SHADOW_H
27#define _SHADOW_H 1 29#define _SHADOW_H 1
28 30
29/* Paths to the user database files */ 31/* Paths to the user database files */
30#ifndef _PATH_SHADOW 32#ifndef _PATH_SHADOW
@@ -44,6 +46,28 @@ struct spwd {
44 unsigned long int sp_flag; /* Reserved */ 46 unsigned long int sp_flag; /* Reserved */
45}; 47};
46 48
49
50#define setspent bb_internal_setspent
51#define endspent bb_internal_endspent
52#define getspent bb_internal_getspent
53#define getspnam bb_internal_getspnam
54#define sgetspent bb_internal_sgetspent
55#define fgetspent bb_internal_fgetspent
56#define putspent bb_internal_putspent
57#define getspent_r bb_internal_getspent_r
58#define getspnam_r bb_internal_getspnam_r
59#define sgetspent_r bb_internal_sgetspent_r
60#define fgetspent_r bb_internal_fgetspent_r
61#define lckpwdf bb_internal_lckpwdf
62#define ulckpwdf bb_internal_ulckpwdf
63
64
65/* All function names below should be remapped by #defines above
66 * in order to not collide with libc names.
67 * In theory it isn't necessary, but I saw weird interactions at link time.
68 * Let's play safe */
69
70
47/* Open database for reading */ 71/* Open database for reading */
48extern void setspent(void); 72extern void setspent(void);
49 73
diff --git a/libpwdgrp/pwd_grp.c b/libpwdgrp/pwd_grp.c
index fcf6eaffe..7aed265b9 100644
--- a/libpwdgrp/pwd_grp.c
+++ b/libpwdgrp/pwd_grp.c
@@ -43,13 +43,13 @@
43/**********************************************************************/ 43/**********************************************************************/
44/* Prototypes for internal functions. */ 44/* Prototypes for internal functions. */
45 45
46static int __pgsreader(int (*parserfunc)(void *d, char *line), void *data, 46static int bb__pgsreader(int (*parserfunc)(void *d, char *line), void *data,
47 char *__restrict line_buff, size_t buflen, FILE *f); 47 char *__restrict line_buff, size_t buflen, FILE *f);
48 48
49static int __parsepwent(void *pw, char *line); 49static int bb__parsepwent(void *pw, char *line);
50static int __parsegrent(void *gr, char *line); 50static int bb__parsegrent(void *gr, char *line);
51#if ENABLE_USE_BB_SHADOW 51#if ENABLE_USE_BB_SHADOW
52static int __parsespent(void *sp, char *line); 52static int bb__parsespent(void *sp, char *line);
53#endif 53#endif
54 54
55/**********************************************************************/ 55/**********************************************************************/
@@ -58,7 +58,7 @@ static int __parsespent(void *sp, char *line);
58 * 0: success 58 * 0: success
59 * ENOENT: end-of-file encountered 59 * ENOENT: end-of-file encountered
60 * ERANGE: buflen too small 60 * ERANGE: buflen too small
61 * other error values possible. See __pgsreader. 61 * other error values possible. See bb__pgsreader.
62 * 62 *
63 * Also, *result == resultbuf on success and NULL on failure. 63 * Also, *result == resultbuf on success and NULL on failure.
64 * 64 *
@@ -76,7 +76,7 @@ int fgetpwent_r(FILE *__restrict stream, struct passwd *__restrict resultbuf,
76 76
77 *result = NULL; 77 *result = NULL;
78 78
79 rv = __pgsreader(__parsepwent, resultbuf, buffer, buflen, stream); 79 rv = bb__pgsreader(bb__parsepwent, resultbuf, buffer, buflen, stream);
80 if (!rv) { 80 if (!rv) {
81 *result = resultbuf; 81 *result = resultbuf;
82 } 82 }
@@ -92,7 +92,7 @@ int fgetgrent_r(FILE *__restrict stream, struct group *__restrict resultbuf,
92 92
93 *result = NULL; 93 *result = NULL;
94 94
95 rv = __pgsreader(__parsegrent, resultbuf, buffer, buflen, stream); 95 rv = bb__pgsreader(bb__parsegrent, resultbuf, buffer, buflen, stream);
96 if (!rv) { 96 if (!rv) {
97 *result = resultbuf; 97 *result = resultbuf;
98 } 98 }
@@ -109,7 +109,7 @@ int fgetspent_r(FILE *__restrict stream, struct spwd *__restrict resultbuf,
109 109
110 *result = NULL; 110 *result = NULL;
111 111
112 rv = __pgsreader(__parsespent, resultbuf, buffer, buflen, stream); 112 rv = bb__pgsreader(bb__parsespent, resultbuf, buffer, buflen, stream);
113 if (!rv) { 113 if (!rv) {
114 *result = resultbuf; 114 *result = resultbuf;
115 } 115 }
@@ -175,7 +175,7 @@ int sgetspent_r(const char *string, struct spwd *result_buf,
175 strcpy(buffer, string); 175 strcpy(buffer, string);
176 } 176 }
177 177
178 rv = __parsespent(result_buf, buffer); 178 rv = bb__parsespent(result_buf, buffer);
179 if (!rv) { 179 if (!rv) {
180 *result = result_buf; 180 *result = result_buf;
181 } 181 }
@@ -187,50 +187,46 @@ int sgetspent_r(const char *string, struct spwd *result_buf,
187 187
188/**********************************************************************/ 188/**********************************************************************/
189 189
190#ifdef GETXXKEY_R_FUNC 190#define GETXXKEY_R_FUNC getpwnam_r
191#error GETXXKEY_R_FUNC is already defined! 191#define GETXXKEY_R_PARSER bb__parsepwent
192#endif
193
194#define GETXXKEY_R_FUNC getpwnam_R
195#define GETXXKEY_R_PARSER __parsepwent
196#define GETXXKEY_R_ENTTYPE struct passwd 192#define GETXXKEY_R_ENTTYPE struct passwd
197#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->pw_name, key)) 193#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->pw_name, key))
198#define DO_GETXXKEY_R_KEYTYPE const char *__restrict 194#define GETXXKEY_R_KEYTYPE const char *__restrict
199#define DO_GETXXKEY_R_PATHNAME _PATH_PASSWD 195#define GETXXKEY_R_PATHNAME _PATH_PASSWD
200#include "pwd_grp_internal.c" 196#include "pwd_grp_internal.c"
201 197
202#define GETXXKEY_R_FUNC getgrnam_R 198#define GETXXKEY_R_FUNC getgrnam_r
203#define GETXXKEY_R_PARSER __parsegrent 199#define GETXXKEY_R_PARSER bb__parsegrent
204#define GETXXKEY_R_ENTTYPE struct group 200#define GETXXKEY_R_ENTTYPE struct group
205#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->gr_name, key)) 201#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->gr_name, key))
206#define DO_GETXXKEY_R_KEYTYPE const char *__restrict 202#define GETXXKEY_R_KEYTYPE const char *__restrict
207#define DO_GETXXKEY_R_PATHNAME _PATH_GROUP 203#define GETXXKEY_R_PATHNAME _PATH_GROUP
208#include "pwd_grp_internal.c" 204#include "pwd_grp_internal.c"
209 205
210#if ENABLE_USE_BB_SHADOW 206#if ENABLE_USE_BB_SHADOW
211#define GETXXKEY_R_FUNC getspnam_R 207#define GETXXKEY_R_FUNC getspnam_r
212#define GETXXKEY_R_PARSER __parsespent 208#define GETXXKEY_R_PARSER bb__parsespent
213#define GETXXKEY_R_ENTTYPE struct spwd 209#define GETXXKEY_R_ENTTYPE struct spwd
214#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->sp_namp, key)) 210#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->sp_namp, key))
215#define DO_GETXXKEY_R_KEYTYPE const char *__restrict 211#define GETXXKEY_R_KEYTYPE const char *__restrict
216#define DO_GETXXKEY_R_PATHNAME _PATH_SHADOW 212#define GETXXKEY_R_PATHNAME _PATH_SHADOW
217#include "pwd_grp_internal.c" 213#include "pwd_grp_internal.c"
218#endif 214#endif
219 215
220#define GETXXKEY_R_FUNC getpwuid_R 216#define GETXXKEY_R_FUNC getpwuid_r
221#define GETXXKEY_R_PARSER __parsepwent 217#define GETXXKEY_R_PARSER bb__parsepwent
222#define GETXXKEY_R_ENTTYPE struct passwd 218#define GETXXKEY_R_ENTTYPE struct passwd
223#define GETXXKEY_R_TEST(ENT) ((ENT)->pw_uid == key) 219#define GETXXKEY_R_TEST(ENT) ((ENT)->pw_uid == key)
224#define DO_GETXXKEY_R_KEYTYPE uid_t 220#define GETXXKEY_R_KEYTYPE uid_t
225#define DO_GETXXKEY_R_PATHNAME _PATH_PASSWD 221#define GETXXKEY_R_PATHNAME _PATH_PASSWD
226#include "pwd_grp_internal.c" 222#include "pwd_grp_internal.c"
227 223
228#define GETXXKEY_R_FUNC getgrgid_R 224#define GETXXKEY_R_FUNC getgrgid_r
229#define GETXXKEY_R_PARSER __parsegrent 225#define GETXXKEY_R_PARSER bb__parsegrent
230#define GETXXKEY_R_ENTTYPE struct group 226#define GETXXKEY_R_ENTTYPE struct group
231#define GETXXKEY_R_TEST(ENT) ((ENT)->gr_gid == key) 227#define GETXXKEY_R_TEST(ENT) ((ENT)->gr_gid == key)
232#define DO_GETXXKEY_R_KEYTYPE gid_t 228#define GETXXKEY_R_KEYTYPE gid_t
233#define DO_GETXXKEY_R_PATHNAME _PATH_GROUP 229#define GETXXKEY_R_PATHNAME _PATH_GROUP
234#include "pwd_grp_internal.c" 230#include "pwd_grp_internal.c"
235 231
236/**********************************************************************/ 232/**********************************************************************/
@@ -347,6 +343,8 @@ int getpw(uid_t uid, char *buf)
347 343
348/**********************************************************************/ 344/**********************************************************************/
349 345
346/* FIXME: we don't have such CONFIG_xx - ?! */
347
350#if defined CONFIG_USE_BB_THREADSAFE_SHADOW && defined PTHREAD_MUTEX_INITIALIZER 348#if defined CONFIG_USE_BB_THREADSAFE_SHADOW && defined PTHREAD_MUTEX_INITIALIZER
351static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; 349static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER;
352# define LOCK pthread_mutex_lock(&mylock) 350# define LOCK pthread_mutex_lock(&mylock)
@@ -394,7 +392,7 @@ int getpwent_r(struct passwd *__restrict resultbuf,
394 } 392 }
395 } 393 }
396 394
397 rv = __pgsreader(__parsepwent, resultbuf, buffer, buflen, pwf); 395 rv = bb__pgsreader(bb__parsepwent, resultbuf, buffer, buflen, pwf);
398 if (!rv) { 396 if (!rv) {
399 *result = resultbuf; 397 *result = resultbuf;
400 } 398 }
@@ -441,7 +439,7 @@ int getgrent_r(struct group *__restrict resultbuf,
441 } 439 }
442 } 440 }
443 441
444 rv = __pgsreader(__parsegrent, resultbuf, buffer, buflen, grf); 442 rv = bb__pgsreader(bb__parsegrent, resultbuf, buffer, buflen, grf);
445 if (!rv) { 443 if (!rv) {
446 *result = resultbuf; 444 *result = resultbuf;
447 } 445 }
@@ -488,7 +486,7 @@ int getspent_r(struct spwd *resultbuf, char *buffer,
488 } 486 }
489 } 487 }
490 488
491 rv = __pgsreader(__parsespent, resultbuf, buffer, buflen, spf); 489 rv = bb__pgsreader(bb__parsespent, resultbuf, buffer, buflen, spf);
492 if (!rv) { 490 if (!rv) {
493 *result = resultbuf; 491 *result = resultbuf;
494 } 492 }
@@ -560,7 +558,7 @@ int initgroups(const char *user, gid_t gid)
560 *group_list = gid; 558 *group_list = gid;
561 num_groups = 1; 559 num_groups = 1;
562 560
563 while (!__pgsreader(__parsegrent, &group, buff, sizeof(buff), grfile)) { 561 while (!bb__pgsreader(bb__parsegrent, &group, buff, sizeof(buff), grfile)) {
564 assert(group.gr_mem); /* Must have at least a NULL terminator. */ 562 assert(group.gr_mem); /* Must have at least a NULL terminator. */
565 if (group.gr_gid != gid) { 563 if (group.gr_gid != gid) {
566 for (m=group.gr_mem ; *m ; m++) { 564 for (m=group.gr_mem ; *m ; m++) {
@@ -705,7 +703,7 @@ DO_UNLOCK:
705#endif 703#endif
706 704
707/**********************************************************************/ 705/**********************************************************************/
708/* Internal uClibc functions. */ 706/* Internal uClibc functions. */
709/**********************************************************************/ 707/**********************************************************************/
710 708
711static const unsigned char pw_off[] = { 709static const unsigned char pw_off[] = {
@@ -718,7 +716,7 @@ static const unsigned char pw_off[] = {
718 offsetof(struct passwd, pw_shell) /* 6 */ 716 offsetof(struct passwd, pw_shell) /* 6 */
719}; 717};
720 718
721static int __parsepwent(void *data, char *line) 719static int bb__parsepwent(void *data, char *line)
722{ 720{
723 char *endptr; 721 char *endptr;
724 char *p; 722 char *p;
@@ -772,7 +770,7 @@ static const unsigned char gr_off[] = {
772 offsetof(struct group, gr_gid) /* 2 - not a char ptr */ 770 offsetof(struct group, gr_gid) /* 2 - not a char ptr */
773}; 771};
774 772
775static int __parsegrent(void *data, char *line) 773static int bb__parsegrent(void *data, char *line)
776{ 774{
777 char *endptr; 775 char *endptr;
778 char *p; 776 char *p;
@@ -862,6 +860,7 @@ static int __parsegrent(void *data, char *line)
862} 860}
863 861
864/**********************************************************************/ 862/**********************************************************************/
863
865#if ENABLE_USE_BB_SHADOW 864#if ENABLE_USE_BB_SHADOW
866static const unsigned char sp_off[] = { 865static const unsigned char sp_off[] = {
867 offsetof(struct spwd, sp_namp), /* 0 */ 866 offsetof(struct spwd, sp_namp), /* 0 */
@@ -875,7 +874,7 @@ static const unsigned char sp_off[] = {
875 offsetof(struct spwd, sp_flag) /* 8 - not a char ptr */ 874 offsetof(struct spwd, sp_flag) /* 8 - not a char ptr */
876}; 875};
877 876
878static int __parsespent(void *data, char * line) 877static int bb__parsespent(void *data, char * line)
879{ 878{
880 char *endptr; 879 char *endptr;
881 char *p; 880 char *p;
@@ -928,7 +927,7 @@ static int __parsespent(void *data, char * line)
928 * Returns 0 on success and ENOENT for end-of-file (glibc concession). 927 * Returns 0 on success and ENOENT for end-of-file (glibc concession).
929 */ 928 */
930 929
931static int __pgsreader(int (*parserfunc)(void *d, char *line), void *data, 930static int bb__pgsreader(int (*parserfunc)(void *d, char *line), void *data,
932 char *__restrict line_buff, size_t buflen, FILE *f) 931 char *__restrict line_buff, size_t buflen, FILE *f)
933{ 932{
934 int line_len; 933 int line_len;
@@ -966,7 +965,7 @@ static int __pgsreader(int (*parserfunc)(void *d, char *line), void *data,
966 /* Skip empty lines, comment lines, and lines with leading 965 /* Skip empty lines, comment lines, and lines with leading
967 * whitespace. */ 966 * whitespace. */
968 if (*line_buff && (*line_buff != '#') && !isspace(*line_buff)) { 967 if (*line_buff && (*line_buff != '#') && !isspace(*line_buff)) {
969 if (parserfunc == __parsegrent) { /* Do evil group hack. */ 968 if (parserfunc == bb__parsegrent) { /* Do evil group hack. */
970 /* The group entry parsing function needs to know where 969 /* The group entry parsing function needs to know where
971 * the end of the buffer is so that it can construct the 970 * the end of the buffer is so that it can construct the
972 * group member ptr table. */ 971 * group member ptr table. */
diff --git a/libpwdgrp/pwd_grp_internal.c b/libpwdgrp/pwd_grp_internal.c
index 866ed3699..d55edc349 100644
--- a/libpwdgrp/pwd_grp_internal.c
+++ b/libpwdgrp/pwd_grp_internal.c
@@ -22,7 +22,7 @@
22#error GETXXKEY_R_FUNC is not defined! 22#error GETXXKEY_R_FUNC is not defined!
23#endif 23#endif
24 24
25int GETXXKEY_R_FUNC(DO_GETXXKEY_R_KEYTYPE key, 25int GETXXKEY_R_FUNC(GETXXKEY_R_KEYTYPE key,
26 GETXXKEY_R_ENTTYPE *__restrict resultbuf, 26 GETXXKEY_R_ENTTYPE *__restrict resultbuf,
27 char *__restrict buffer, size_t buflen, 27 char *__restrict buffer, size_t buflen,
28 GETXXKEY_R_ENTTYPE **__restrict result) 28 GETXXKEY_R_ENTTYPE **__restrict result)
@@ -32,11 +32,11 @@ int GETXXKEY_R_FUNC(DO_GETXXKEY_R_KEYTYPE key,
32 32
33 *result = NULL; 33 *result = NULL;
34 34
35 stream = fopen(DO_GETXXKEY_R_PATHNAME, "r"); 35 stream = fopen(GETXXKEY_R_PATHNAME, "r");
36 if (!stream) 36 if (!stream)
37 return errno; 37 return errno;
38 while (1) { 38 while (1) {
39 rv = __pgsreader(GETXXKEY_R_PARSER, resultbuf, buffer, buflen, stream); 39 rv = bb__pgsreader(GETXXKEY_R_PARSER, resultbuf, buffer, buflen, stream);
40 if (!rv) { 40 if (!rv) {
41 if (GETXXKEY_R_TEST(resultbuf)) { /* Found key? */ 41 if (GETXXKEY_R_TEST(resultbuf)) { /* Found key? */
42 *result = resultbuf; 42 *result = resultbuf;
@@ -58,5 +58,5 @@ int GETXXKEY_R_FUNC(DO_GETXXKEY_R_KEYTYPE key,
58#undef GETXXKEY_R_PARSER 58#undef GETXXKEY_R_PARSER
59#undef GETXXKEY_R_ENTTYPE 59#undef GETXXKEY_R_ENTTYPE
60#undef GETXXKEY_R_TEST 60#undef GETXXKEY_R_TEST
61#undef DO_GETXXKEY_R_KEYTYPE 61#undef GETXXKEY_R_KEYTYPE
62#undef DO_GETXXKEY_R_PATHNAME 62#undef GETXXKEY_R_PATHNAME
diff --git a/libpwdgrp/uidgid_get.c b/libpwdgrp/uidgid_get.c
index 32cbd21b9..69c228e16 100644
--- a/libpwdgrp/uidgid_get.c
+++ b/libpwdgrp/uidgid_get.c
@@ -1,3 +1,30 @@
1/*
2Copyright (c) 2001-2006, Gerrit Pape
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7
8 1. Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 3. The name of the author may not be used to endorse or promote products
14 derived from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
1#include "busybox.h" 28#include "busybox.h"
2 29
3int get_uidgid(struct bb_uidgid_t *u, const char *ug, int numeric_ok) 30int get_uidgid(struct bb_uidgid_t *u, const char *ug, int numeric_ok)
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index 65bae4dac..a96239d38 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -239,11 +239,11 @@ void parse_config_file(char *map, size_t len)
239 /* We have at least 5 chars: for() has 239 /* We have at least 5 chars: for() has
240 * "p < end-4", not "p <= end-4" 240 * "p < end-4", not "p <= end-4"
241 * therefore we don't need to check p <= end-5 here */ 241 * therefore we don't need to check p <= end-5 here */
242 if (p[4] == '_') { 242 if (p[4] == '_')
243 if (!memcmp(p, "SKIP", 4)) goto conf5; 243 if (!memcmp(p, "SKIP", 4)) goto conf5;
244 }
245 /* Ehhh, gcc is too stupid to just compare it as 32bit int */ 244 /* Ehhh, gcc is too stupid to just compare it as 32bit int */
246 if (!memcmp(p, "USE_", 4)) goto conf4; 245 if (p[0] == 'U')
246 if (!memcmp(p, "USE_", 4)) goto conf4;
247 continue; 247 continue;
248 248
249 conf4: off = 4; 249 conf4: off = 4;