diff options
author | Denis Vlasenko | 2007-03-13 13:01:14 +0000 |
---|---|---|
committer | Denis Vlasenko | 2007-03-13 13:01:14 +0000 |
commit | 5df955fce2fbdc5b2acc365a120327ff943403da (patch) | |
tree | 41763239e81807259b7532aeef540ebc4804ce3d /libpwdgrp/pwd_grp.c | |
parent | c9c893d4f59418c50c8eb42bd80390026e123dd8 (diff) | |
download | busybox-5df955fce2fbdc5b2acc365a120327ff943403da.zip busybox-5df955fce2fbdc5b2acc365a120327ff943403da.tar.gz |
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
Diffstat (limited to 'libpwdgrp/pwd_grp.c')
-rw-r--r-- | libpwdgrp/pwd_grp.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/libpwdgrp/pwd_grp.c b/libpwdgrp/pwd_grp.c index 7aed265..7a8a237 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, /**********************************************************************/ /* For the various fget??ent funcs, return NULL on failure and a * pointer to the appropriate struct (statically allocated) on success. - */ + * TODO: audit & stop using these in bbox, they pull in static buffers */ /**********************************************************************/ +#if 0 struct passwd *fgetpwent(FILE *stream) { static char buffer[PWD_BUFFER_SIZE]; @@ -143,8 +144,10 @@ struct group *fgetgrent(FILE *stream) fgetgrent_r(stream, &resultbuf, buffer, sizeof(buffer), &result); return result; } +#endif #if ENABLE_USE_BB_SHADOW +#if 0 struct spwd *fgetspent(FILE *stream) { static char buffer[PWD_BUFFER_SIZE]; @@ -154,6 +157,7 @@ struct spwd *fgetspent(FILE *stream) fgetspent_r(stream, &resultbuf, buffer, sizeof(buffer), &result); return result; } +#endif int sgetspent_r(const char *string, struct spwd *result_buf, char *buffer, size_t buflen, struct spwd **result) @@ -230,7 +234,9 @@ int sgetspent_r(const char *string, struct spwd *result_buf, #include "pwd_grp_internal.c" /**********************************************************************/ +/* TODO: audit & stop using these in bbox, they pull in static buffers */ +/* This one has many users */ struct passwd *getpwuid(uid_t uid) { static char buffer[PWD_BUFFER_SIZE]; @@ -241,6 +247,7 @@ struct passwd *getpwuid(uid_t uid) return result; } +/* This one has many users */ struct group *getgrgid(gid_t gid) { static char buffer[GRP_BUFFER_SIZE]; @@ -286,6 +293,7 @@ struct spwd *getspuid(uid_t uid) } #endif +/* This one has many users */ struct passwd *getpwnam(const char *name) { static char buffer[PWD_BUFFER_SIZE]; @@ -296,6 +304,7 @@ struct passwd *getpwnam(const char *name) return result; } +/* This one has many users */ struct group *getgrnam(const char *name) { static char buffer[GRP_BUFFER_SIZE]; @@ -306,7 +315,7 @@ struct group *getgrnam(const char *name) return result; } -#if ENABLE_USE_BB_SHADOW +#if 0 //ENABLE_USE_BB_SHADOW struct spwd *getspnam(const char *name) { static char buffer[PWD_BUFFER_SIZE]; @@ -318,6 +327,7 @@ struct spwd *getspnam(const char *name) } #endif +/* This one doesn't use static buffers */ int getpw(uid_t uid, char *buf) { struct passwd resultbuf; @@ -325,7 +335,7 @@ int getpw(uid_t uid, char *buf) char buffer[PWD_BUFFER_SIZE]; if (!buf) { - errno=EINVAL; + errno = EINVAL; } else if (!getpwuid_r(uid, &resultbuf, buffer, sizeof(buffer), &result)) { if (sprintf(buf, "%s:%s:%lu:%lu:%s:%s:%s\n", resultbuf.pw_name, resultbuf.pw_passwd, @@ -497,6 +507,7 @@ int getspent_r(struct spwd *resultbuf, char *buffer, } #endif +#if 0 struct passwd *getpwent(void) { static char line_buff[PWD_BUFFER_SIZE]; @@ -516,8 +527,9 @@ struct group *getgrent(void) getgrent_r(&gr, line_buff, sizeof(line_buff), &result); return result; } +#endif -#if ENABLE_USE_BB_SHADOW +#if 0 //ENABLE_USE_BB_SHADOW struct spwd *getspent(void) { static char line_buff[PWD_BUFFER_SIZE]; |