diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-03-13 13:01:14 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-03-13 13:01:14 +0000 |
commit | 5df955fce2fbdc5b2acc365a120327ff943403da (patch) | |
tree | 41763239e81807259b7532aeef540ebc4804ce3d /loginutils/sulogin.c | |
parent | c9c893d4f59418c50c8eb42bd80390026e123dd8 (diff) | |
download | busybox-w32-5df955fce2fbdc5b2acc365a120327ff943403da.tar.gz busybox-w32-5df955fce2fbdc5b2acc365a120327ff943403da.tar.bz2 busybox-w32-5df955fce2fbdc5b2acc365a120327ff943403da.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
Diffstat (limited to 'loginutils/sulogin.c')
-rw-r--r-- | loginutils/sulogin.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c index 8e3095c87..38503f7b1 100644 --- a/loginutils/sulogin.c +++ b/loginutils/sulogin.c | |||
@@ -43,6 +43,12 @@ int sulogin_main(int argc, char **argv) | |||
43 | const char * const *p; | 43 | const char * const *p; |
44 | struct passwd *pwd; | 44 | struct passwd *pwd; |
45 | const char *shell; | 45 | const char *shell; |
46 | #if ENABLE_FEATURE_SHADOWPASSWDS | ||
47 | /* Using _r function to avoid pulling in static buffers */ | ||
48 | char buffer[256]; | ||
49 | struct spwd spw; | ||
50 | struct spwd *result; | ||
51 | #endif | ||
46 | 52 | ||
47 | logmode = LOGMODE_BOTH; | 53 | logmode = LOGMODE_BOTH; |
48 | openlog(applet_name, 0, LOG_AUTH); | 54 | openlog(applet_name, 0, LOG_AUTH); |
@@ -76,13 +82,10 @@ int sulogin_main(int argc, char **argv) | |||
76 | } | 82 | } |
77 | 83 | ||
78 | #if ENABLE_FEATURE_SHADOWPASSWDS | 84 | #if ENABLE_FEATURE_SHADOWPASSWDS |
79 | { | 85 | if (getspnam_r(pwd->pw_name, &spw, buffer, sizeof(buffer), &result)) { |
80 | struct spwd *spwd = getspnam(pwd->pw_name); | 86 | goto auth_error; |
81 | if (!spwd) { | ||
82 | goto auth_error; | ||
83 | } | ||
84 | pwd->pw_passwd = spwd->sp_pwdp; | ||
85 | } | 87 | } |
88 | pwd->pw_passwd = spw.sp_pwdp; | ||
86 | #endif | 89 | #endif |
87 | 90 | ||
88 | while (1) { | 91 | while (1) { |