Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/libbb/correct_password.c

    r1765 r2725  
    3737 * NULL pw means "just fake it for login with bad username" */
    3838
    39 int correct_password(const struct passwd *pw)
     39int FAST_FUNC correct_password(const struct passwd *pw)
    4040{
    4141    char *unencrypted, *encrypted;
    4242    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
    4349
    4450    /* fake salt. crypt() can choke otherwise. */
     
    5157#if ENABLE_FEATURE_SHADOWPASSWDS
    5258    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;
    5864    }
    5965#endif
     
    6369
    6470 fake_it:
    65     unencrypted = bb_askpass(0, "Password: ");
     71    unencrypted = bb_ask_stdin("Password: ");
    6672    if (!unencrypted) {
    6773        return 0;
    6874    }
    69     encrypted = crypt(unencrypted, correct);
     75    encrypted = pw_encrypt(unencrypted, correct, 1);
     76    r = (strcmp(encrypted, correct) == 0);
     77    free(encrypted);
    7078    memset(unencrypted, 0, strlen(unencrypted));
    71     return strcmp(encrypted, correct) == 0;
     79    return r;
    7280}
Note: See TracChangeset for help on using the changeset viewer.