diff options
| author | jsorg71 <jay.sorg@gmail.com> | 2013-03-09 20:31:17 -0800 |
|---|---|---|
| committer | jsorg71 <jay.sorg@gmail.com> | 2013-03-09 20:31:17 -0800 |
| commit | 75f63e78947f48f106d6cbdb913c898edce8840f (patch) | |
| tree | 5af1d3f1d42f5ff6ecf4c9b7951dc82003ced18e /sesman/verify_user.c | |
| parent | 297fdaf1c6615a856aaaa16072eb8538f39faf19 (diff) | |
| parent | b518a3bfe91bb157948dde85e42f63f42b00da58 (diff) | |
| download | xrdp-proprietary-75f63e78947f48f106d6cbdb913c898edce8840f.tar.gz xrdp-proprietary-75f63e78947f48f106d6cbdb913c898edce8840f.zip | |
Merge pull request #64 from imprazaguy/bug_fix_nopam
Bug fix for building without PAM
Diffstat (limited to 'sesman/verify_user.c')
| -rw-r--r-- | sesman/verify_user.c | 44 |
1 files changed, 5 insertions, 39 deletions
diff --git a/sesman/verify_user.c b/sesman/verify_user.c index 5bd89c73..85e614d3 100644 --- a/sesman/verify_user.c +++ b/sesman/verify_user.c @@ -50,12 +50,9 @@ auth_account_disabled(struct spwd *stp); long DEFAULT_CC auth_userpass(char *user, char *pass, int *errorcode) { - char salt[13] = "$1$"; - char hash[35] = ""; - char *encr = 0; + const char *encr; struct passwd *spw; struct spwd *stp; - int saltcnt = 0; spw = getpwnam(user); @@ -76,50 +73,19 @@ auth_userpass(char *user, char *pass, int *errorcode) if (1 == auth_account_disabled(stp)) { - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "account %s is disabled", user); + log_message(LOG_LEVEL_INFO, "account %s is disabled", user); return 0; } - g_strncpy(hash, stp->sp_pwdp, 34); + encr = stp->sp_pwdp; } else { /* old system with only passwd */ - g_strncpy(hash, spw->pw_passwd, 34); - } - - hash[34] = '\0'; - - if (g_strncmp(hash, "$1$", 3) == 0) - { - /* gnu style crypt(); */ - saltcnt = 3; - - while ((hash[saltcnt] != '$') && (saltcnt < 11)) - { - salt[saltcnt] = hash[saltcnt]; - saltcnt++; - } - - salt[saltcnt] = '$'; - salt[saltcnt + 1] = '\0'; - } - else - { - /* classic two char salt */ - salt[0] = hash[0]; - salt[1] = hash[1]; - salt[2] = '\0'; - } - - encr = crypt(pass, salt); - - if (g_strncmp(encr, hash, 34) != 0) - { - return 0; + encr = spw->pw_passwd; } - return 1; + return (strcmp(encr, crypt(pass, encr)) == 0); } /******************************************************************************/ |
