Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/libbb/correct_password.c
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/libbb/correct_password.c
r1765 r2725 37 37 * NULL pw means "just fake it for login with bad username" */ 38 38 39 int correct_password(const struct passwd *pw)39 int FAST_FUNC correct_password(const struct passwd *pw) 40 40 { 41 41 char *unencrypted, *encrypted; 42 42 const char *correct; 43 int r; 44 #if ENABLE_FEATURE_SHADOWPASSWDS 45 /* Using _r function to avoid pulling in static buffers */ 46 struct spwd spw; 47 char buffer[256]; 48 #endif 43 49 44 50 /* fake salt. crypt() can choke otherwise. */ … … 51 57 #if ENABLE_FEATURE_SHADOWPASSWDS 52 58 if ((correct[0] == 'x' || correct[0] == '*') && !correct[1]) { 53 /* Using _r function to avoid pulling in static buffers */54 struct spwd spw;55 struct spwd *result ;56 char buffer[256];57 correct = ( getspnam_r(pw->pw_name, &spw, buffer, sizeof(buffer), &result)) ? "aa" : spw.sp_pwdp;59 /* getspnam_r may return 0 yet set result to NULL. 60 * At least glibc 2.4 does this. Be extra paranoid here. */ 61 struct spwd *result = NULL; 62 r = getspnam_r(pw->pw_name, &spw, buffer, sizeof(buffer), &result); 63 correct = (r || !result) ? "aa" : result->sp_pwdp; 58 64 } 59 65 #endif … … 63 69 64 70 fake_it: 65 unencrypted = bb_ask pass(0,"Password: ");71 unencrypted = bb_ask_stdin("Password: "); 66 72 if (!unencrypted) { 67 73 return 0; 68 74 } 69 encrypted = crypt(unencrypted, correct); 75 encrypted = pw_encrypt(unencrypted, correct, 1); 76 r = (strcmp(encrypted, correct) == 0); 77 free(encrypted); 70 78 memset(unencrypted, 0, strlen(unencrypted)); 71 return strcmp(encrypted, correct) == 0;79 return r; 72 80 }
Note:
See TracChangeset
for help on using the changeset viewer.