pam_winbind: fix wbc_auth_error_to_pam_error().
authorGünther Deschner <gd@samba.org>
Tue, 19 Aug 2008 12:52:24 +0000 (14:52 +0200)
committerGünther Deschner <gd@samba.org>
Fri, 10 Oct 2008 13:42:23 +0000 (15:42 +0200)
Guenther

source3/nsswitch/pam_winbind.c

index 43157b7727f76110afb16ef2f2e5d5bc23eee506..cac8550e606301d237ea2e82cf8ff61d71dfdb95 100644 (file)
@@ -733,7 +733,8 @@ static int pam_winbind_request(struct pwb_context *ctx,
 
 static int pam_winbind_request_log(struct pwb_context *ctx,
                                   int retval,
-                                  const char *user)
+                                  const char *user,
+                                  const char *fn)
 {
        switch (retval) {
        case PAM_AUTH_ERR:
@@ -766,24 +767,19 @@ static int pam_winbind_request_log(struct pwb_context *ctx,
                return retval;
        case PAM_SUCCESS:
                /* Otherwise, the authentication looked good */
-#if 0
-               switch (req_type) {
-                       case WINBINDD_PAM_AUTH:
-                               _pam_log(ctx, LOG_NOTICE,
-                                        "user '%s' granted access", user);
-                               break;
-                       default:
-                               _pam_log(ctx, LOG_NOTICE,
-                                        "user '%s' OK", user);
-                               break;
+               if (strcmp(fn, "wbcLogonUser") == 0) {
+                       _pam_log(ctx, LOG_NOTICE,
+                                "user '%s' granted access", user);
+               } else {
+                       _pam_log(ctx, LOG_NOTICE,
+                                "user '%s' OK", user);
                }
-#endif
                return retval;
        default:
                /* we don't know anything about this return value */
                _pam_log(ctx, LOG_ERR,
-                        "internal module error (retval = %d, user = '%s')",
-                        retval, user);
+                        "internal module error (retval = %s(%d), user = '%s')",
+                       _pam_error_code_str(retval), retval, user);
                return retval;
        }
 }
@@ -800,7 +796,7 @@ static int wbc_auth_error_to_pam_error(struct pwb_context *ctx,
                _pam_log_debug(ctx, LOG_DEBUG, "request %s succeeded",
                        fn);
                ret = PAM_SUCCESS;
-               return pam_winbind_request_log(ctx, ret, username);
+               return pam_winbind_request_log(ctx, ret, username, fn);
        }
 
        if (e) {
@@ -816,17 +812,17 @@ static int wbc_auth_error_to_pam_error(struct pwb_context *ctx,
                                 e->nt_string,
                                 e->display_string);
                        ret = e->pam_error;
-                       return pam_winbind_request_log(ctx, ret, username);
+                       return pam_winbind_request_log(ctx, ret, username, fn);
                }
 
                _pam_log(ctx, LOG_ERR, "request %s failed, but PAM error 0!", fn);
 
                ret = PAM_SERVICE_ERR;
-               return pam_winbind_request_log(ctx, ret, username);
+               return pam_winbind_request_log(ctx, ret, username, fn);
        }
 
        ret = wbc_error_to_pam_error(status);
-       return pam_winbind_request_log(ctx, ret, username);
+       return pam_winbind_request_log(ctx, ret, username, fn);
 }