diff options
-rw-r--r-- | libbb/correct_password.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/libbb/correct_password.c b/libbb/correct_password.c index f832635e6..815c51c43 100644 --- a/libbb/correct_password.c +++ b/libbb/correct_password.c | |||
@@ -40,12 +40,6 @@ int correct_password(const struct passwd *pw) | |||
40 | { | 40 | { |
41 | char *unencrypted, *encrypted; | 41 | char *unencrypted, *encrypted; |
42 | const char *correct; | 42 | const char *correct; |
43 | #if ENABLE_FEATURE_SHADOWPASSWDS | ||
44 | /* Using _r function to avoid pulling in static buffers */ | ||
45 | struct spwd spw; | ||
46 | struct spwd *result; | ||
47 | char buffer[256]; | ||
48 | #endif | ||
49 | 43 | ||
50 | /* fake salt. crypt() can choke otherwise. */ | 44 | /* fake salt. crypt() can choke otherwise. */ |
51 | correct = "aa"; | 45 | correct = "aa"; |
@@ -55,11 +49,14 @@ int correct_password(const struct passwd *pw) | |||
55 | } | 49 | } |
56 | correct = pw->pw_passwd; | 50 | correct = pw->pw_passwd; |
57 | #if ENABLE_FEATURE_SHADOWPASSWDS | 51 | #if ENABLE_FEATURE_SHADOWPASSWDS |
58 | if (LONE_CHAR(pw->pw_passwd, 'x') || LONE_CHAR(pw->pw_passwd, '*')) { | 52 | if ((correct[0] == 'x' || correct[0] == '*') && !correct[1]) { |
59 | if (getspnam_r(pw->pw_name, &spw, buffer, sizeof(buffer), &result)) | 53 | /* Using _r function to avoid pulling in static buffers */ |
60 | bb_error_msg("no valid shadow password, checking ordinary one"); | 54 | struct spwd spw; |
61 | else | 55 | struct spwd *result; |
56 | char buffer[256]; | ||
57 | if (getspnam_r(pw->pw_name, &spw, buffer, sizeof(buffer), &result) == 0) | ||
62 | correct = spw.sp_pwdp; | 58 | correct = spw.sp_pwdp; |
59 | /* else: no valid shadow password, checking ordinary one */ | ||
63 | } | 60 | } |
64 | #endif | 61 | #endif |
65 | 62 | ||