pam: map more NT password errors to PAM errors
authorBjörn Jacke <bj@sernet.de>
Wed, 25 Nov 2015 13:04:24 +0000 (14:04 +0100)
committerBjoern Jacke <bj@sernet.de>
Tue, 13 Dec 2016 13:12:06 +0000 (14:12 +0100)
NT_STATUS_ACCOUNT_DISABLED,
NT_STATUS_PASSWORD_RESTRICTION,
NT_STATUS_PWD_HISTORY_CONFLICT,
NT_STATUS_PWD_TOO_RECENT,
NT_STATUS_PWD_TOO_SHORT

now map to PAM_AUTHTOK_ERR (Authentication token manipulation error), which is
the closest match.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=2210

Signed-off-by: Bjoern Jacke <bj@sernet.de>
Reviewed by: Jeremy Allison <jra@samba.org>

libcli/auth/pam_errors.c
nsswitch/pam_winbind.c

index 978f8ffdde322982312ec0d6c57f3909d2c37156..5592d39dd8065a26bab7f1d5a0915ac78f565993 100644 (file)
@@ -71,11 +71,15 @@ static const struct {
        {NT_STATUS_WRONG_PASSWORD, PAM_AUTH_ERR},
        {NT_STATUS_LOGON_FAILURE, PAM_AUTH_ERR},
        {NT_STATUS_ACCOUNT_EXPIRED, PAM_ACCT_EXPIRED},
        {NT_STATUS_WRONG_PASSWORD, PAM_AUTH_ERR},
        {NT_STATUS_LOGON_FAILURE, PAM_AUTH_ERR},
        {NT_STATUS_ACCOUNT_EXPIRED, PAM_ACCT_EXPIRED},
+       {NT_STATUS_ACCOUNT_DISABLED, PAM_ACCT_EXPIRED},
        {NT_STATUS_PASSWORD_EXPIRED, PAM_AUTHTOK_EXPIRED},
        {NT_STATUS_PASSWORD_MUST_CHANGE, PAM_NEW_AUTHTOK_REQD},
        {NT_STATUS_ACCOUNT_LOCKED_OUT, PAM_MAXTRIES},
        {NT_STATUS_NO_MEMORY, PAM_BUF_ERR},
        {NT_STATUS_PASSWORD_EXPIRED, PAM_AUTHTOK_EXPIRED},
        {NT_STATUS_PASSWORD_MUST_CHANGE, PAM_NEW_AUTHTOK_REQD},
        {NT_STATUS_ACCOUNT_LOCKED_OUT, PAM_MAXTRIES},
        {NT_STATUS_NO_MEMORY, PAM_BUF_ERR},
-       {NT_STATUS_PASSWORD_RESTRICTION, PAM_PERM_DENIED},
+       {NT_STATUS_PASSWORD_RESTRICTION, PAM_AUTHTOK_ERR},
+       {NT_STATUS_PWD_HISTORY_CONFLICT, PAM_AUTHTOK_ERR},
+       {NT_STATUS_PWD_TOO_RECENT, PAM_AUTHTOK_ERR},
+       {NT_STATUS_PWD_TOO_SHORT, PAM_AUTHTOK_ERR},
        {NT_STATUS_BACKUP_CONTROLLER, PAM_AUTHINFO_UNAVAIL},
        {NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND, PAM_AUTHINFO_UNAVAIL},
        {NT_STATUS_NO_LOGON_SERVERS, PAM_AUTHINFO_UNAVAIL},
        {NT_STATUS_BACKUP_CONTROLLER, PAM_AUTHINFO_UNAVAIL},
        {NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND, PAM_AUTHINFO_UNAVAIL},
        {NT_STATUS_NO_LOGON_SERVERS, PAM_AUTHINFO_UNAVAIL},
index 42c4f8e59649f05a065a3913789b2733da0fd3f6..4ae78b35f005e2c42ece9fcf6fdb4926d3a05d14 100644 (file)
@@ -775,6 +775,11 @@ static int pam_winbind_request_log(struct pwb_context *ctx,
                        return PAM_IGNORE;
                }
                return retval;
                        return PAM_IGNORE;
                }
                return retval;
+       case PAM_AUTHTOK_ERR:
+               /* Authentication token manipulation error */
+               _pam_log(ctx, LOG_WARNING, "user `%s' authentication token change failed "
+                       "(pwd complexity/history/min_age not met?)", user);
+               return retval;
        case PAM_SUCCESS:
                /* Otherwise, the authentication looked good */
                if (strcmp(fn, "wbcLogonUser") == 0) {
        case PAM_SUCCESS:
                /* Otherwise, the authentication looked good */
                if (strcmp(fn, "wbcLogonUser") == 0) {