summaryrefslogtreecommitdiff
path: root/loginutils/sulogin.c
diff options
context:
space:
mode:
authorDenis Vlasenko2007-03-13 13:01:14 +0000
committerDenis Vlasenko2007-03-13 13:01:14 +0000
commit5df955fce2fbdc5b2acc365a120327ff943403da (patch)
tree41763239e81807259b7532aeef540ebc4804ce3d /loginutils/sulogin.c
parentc9c893d4f59418c50c8eb42bd80390026e123dd8 (diff)
downloadbusybox-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 'loginutils/sulogin.c')
-rw-r--r--loginutils/sulogin.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c
index 8e3095c..38503f7 100644
--- a/loginutils/sulogin.c
+++ b/loginutils/sulogin.c
@@ -43,6 +43,12 @@ int sulogin_main(int argc, char **argv)
const char * const *p;
struct passwd *pwd;
const char *shell;
+#if ENABLE_FEATURE_SHADOWPASSWDS
+ /* Using _r function to avoid pulling in static buffers */
+ char buffer[256];
+ struct spwd spw;
+ struct spwd *result;
+#endif
logmode = LOGMODE_BOTH;
openlog(applet_name, 0, LOG_AUTH);
@@ -76,13 +82,10 @@ int sulogin_main(int argc, char **argv)
}
#if ENABLE_FEATURE_SHADOWPASSWDS
- {
- struct spwd *spwd = getspnam(pwd->pw_name);
- if (!spwd) {
- goto auth_error;
- }
- pwd->pw_passwd = spwd->sp_pwdp;
+ if (getspnam_r(pwd->pw_name, &spw, buffer, sizeof(buffer), &result)) {
+ goto auth_error;
}
+ pwd->pw_passwd = spw.sp_pwdp;
#endif
while (1) {