aboutsummaryrefslogtreecommitdiff
path: root/libpwdgrp
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-03-13 13:01:14 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-03-13 13:01:14 +0000
commitbf07ea7cef9740b0f10121a8e39965d4f7c7f0e2 (patch)
tree41763239e81807259b7532aeef540ebc4804ce3d /libpwdgrp
parent35284053c70e23ba1f7cf6484194dafe0cef6258 (diff)
downloadbusybox-w32-bf07ea7cef9740b0f10121a8e39965d4f7c7f0e2.tar.gz
busybox-w32-bf07ea7cef9740b0f10121a8e39965d4f7c7f0e2.tar.bz2
busybox-w32-bf07ea7cef9740b0f10121a8e39965d4f7c7f0e2.zip
Do not fail password check if shadow password does not exist -
fall back to ordinary one Reduced usage of functions returning datain static buffers. (mostly passwd/group/shadow related): function old new delta correct_password 143 193 +50 sulogin_main 490 533 +43 adduser_main 732 774 +42 passwd_main 1875 1915 +40 addgroup_main 330 365 +35 bb_internal_getspnam 38 - -38 bb_internal_fgetpwent 38 - -38 bb_internal_fgetgrent 38 - -38 static.resultbuf 168 88 -80 static.buffer 1872 1104 -768 ------------------------------------------------------------------------------ (add/remove: 0/3 grow/shrink: 5/2 up/down: 210/-962) Total: -752 bytes git-svn-id: svn://busybox.net/trunk/busybox@18085 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libpwdgrp')
-rw-r--r--libpwdgrp/pwd_grp.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/libpwdgrp/pwd_grp.c b/libpwdgrp/pwd_grp.c
index 7aed265b9..7a8a23745 100644
--- a/libpwdgrp/pwd_grp.c
+++ b/libpwdgrp/pwd_grp.c
@@ -121,9 +121,10 @@ int fgetspent_r(FILE *__restrict stream, struct spwd *__restrict resultbuf,
121/**********************************************************************/ 121/**********************************************************************/
122/* For the various fget??ent funcs, return NULL on failure and a 122/* For the various fget??ent funcs, return NULL on failure and a
123 * pointer to the appropriate struct (statically allocated) on success. 123 * pointer to the appropriate struct (statically allocated) on success.
124 */ 124 * TODO: audit & stop using these in bbox, they pull in static buffers */
125/**********************************************************************/ 125/**********************************************************************/
126 126
127#if 0
127struct passwd *fgetpwent(FILE *stream) 128struct passwd *fgetpwent(FILE *stream)
128{ 129{
129 static char buffer[PWD_BUFFER_SIZE]; 130 static char buffer[PWD_BUFFER_SIZE];
@@ -143,8 +144,10 @@ struct group *fgetgrent(FILE *stream)
143 fgetgrent_r(stream, &resultbuf, buffer, sizeof(buffer), &result); 144 fgetgrent_r(stream, &resultbuf, buffer, sizeof(buffer), &result);
144 return result; 145 return result;
145} 146}
147#endif
146 148
147#if ENABLE_USE_BB_SHADOW 149#if ENABLE_USE_BB_SHADOW
150#if 0
148struct spwd *fgetspent(FILE *stream) 151struct spwd *fgetspent(FILE *stream)
149{ 152{
150 static char buffer[PWD_BUFFER_SIZE]; 153 static char buffer[PWD_BUFFER_SIZE];
@@ -154,6 +157,7 @@ struct spwd *fgetspent(FILE *stream)
154 fgetspent_r(stream, &resultbuf, buffer, sizeof(buffer), &result); 157 fgetspent_r(stream, &resultbuf, buffer, sizeof(buffer), &result);
155 return result; 158 return result;
156} 159}
160#endif
157 161
158int sgetspent_r(const char *string, struct spwd *result_buf, 162int sgetspent_r(const char *string, struct spwd *result_buf,
159 char *buffer, size_t buflen, struct spwd **result) 163 char *buffer, size_t buflen, struct spwd **result)
@@ -230,7 +234,9 @@ int sgetspent_r(const char *string, struct spwd *result_buf,
230#include "pwd_grp_internal.c" 234#include "pwd_grp_internal.c"
231 235
232/**********************************************************************/ 236/**********************************************************************/
237/* TODO: audit & stop using these in bbox, they pull in static buffers */
233 238
239/* This one has many users */
234struct passwd *getpwuid(uid_t uid) 240struct passwd *getpwuid(uid_t uid)
235{ 241{
236 static char buffer[PWD_BUFFER_SIZE]; 242 static char buffer[PWD_BUFFER_SIZE];
@@ -241,6 +247,7 @@ struct passwd *getpwuid(uid_t uid)
241 return result; 247 return result;
242} 248}
243 249
250/* This one has many users */
244struct group *getgrgid(gid_t gid) 251struct group *getgrgid(gid_t gid)
245{ 252{
246 static char buffer[GRP_BUFFER_SIZE]; 253 static char buffer[GRP_BUFFER_SIZE];
@@ -286,6 +293,7 @@ struct spwd *getspuid(uid_t uid)
286} 293}
287#endif 294#endif
288 295
296/* This one has many users */
289struct passwd *getpwnam(const char *name) 297struct passwd *getpwnam(const char *name)
290{ 298{
291 static char buffer[PWD_BUFFER_SIZE]; 299 static char buffer[PWD_BUFFER_SIZE];
@@ -296,6 +304,7 @@ struct passwd *getpwnam(const char *name)
296 return result; 304 return result;
297} 305}
298 306
307/* This one has many users */
299struct group *getgrnam(const char *name) 308struct group *getgrnam(const char *name)
300{ 309{
301 static char buffer[GRP_BUFFER_SIZE]; 310 static char buffer[GRP_BUFFER_SIZE];
@@ -306,7 +315,7 @@ struct group *getgrnam(const char *name)
306 return result; 315 return result;
307} 316}
308 317
309#if ENABLE_USE_BB_SHADOW 318#if 0 //ENABLE_USE_BB_SHADOW
310struct spwd *getspnam(const char *name) 319struct spwd *getspnam(const char *name)
311{ 320{
312 static char buffer[PWD_BUFFER_SIZE]; 321 static char buffer[PWD_BUFFER_SIZE];
@@ -318,6 +327,7 @@ struct spwd *getspnam(const char *name)
318} 327}
319#endif 328#endif
320 329
330/* This one doesn't use static buffers */
321int getpw(uid_t uid, char *buf) 331int getpw(uid_t uid, char *buf)
322{ 332{
323 struct passwd resultbuf; 333 struct passwd resultbuf;
@@ -325,7 +335,7 @@ int getpw(uid_t uid, char *buf)
325 char buffer[PWD_BUFFER_SIZE]; 335 char buffer[PWD_BUFFER_SIZE];
326 336
327 if (!buf) { 337 if (!buf) {
328 errno=EINVAL; 338 errno = EINVAL;
329 } else if (!getpwuid_r(uid, &resultbuf, buffer, sizeof(buffer), &result)) { 339 } else if (!getpwuid_r(uid, &resultbuf, buffer, sizeof(buffer), &result)) {
330 if (sprintf(buf, "%s:%s:%lu:%lu:%s:%s:%s\n", 340 if (sprintf(buf, "%s:%s:%lu:%lu:%s:%s:%s\n",
331 resultbuf.pw_name, resultbuf.pw_passwd, 341 resultbuf.pw_name, resultbuf.pw_passwd,
@@ -497,6 +507,7 @@ int getspent_r(struct spwd *resultbuf, char *buffer,
497} 507}
498#endif 508#endif
499 509
510#if 0
500struct passwd *getpwent(void) 511struct passwd *getpwent(void)
501{ 512{
502 static char line_buff[PWD_BUFFER_SIZE]; 513 static char line_buff[PWD_BUFFER_SIZE];
@@ -516,8 +527,9 @@ struct group *getgrent(void)
516 getgrent_r(&gr, line_buff, sizeof(line_buff), &result); 527 getgrent_r(&gr, line_buff, sizeof(line_buff), &result);
517 return result; 528 return result;
518} 529}
530#endif
519 531
520#if ENABLE_USE_BB_SHADOW 532#if 0 //ENABLE_USE_BB_SHADOW
521struct spwd *getspent(void) 533struct spwd *getspent(void)
522{ 534{
523 static char line_buff[PWD_BUFFER_SIZE]; 535 static char line_buff[PWD_BUFFER_SIZE];