pam_winbind: add _pam_check_remark_auth_err().
authorGünther Deschner <gd@samba.org>
Tue, 19 Aug 2008 11:36:39 +0000 (13:36 +0200)
committerGünther Deschner <gd@samba.org>
Fri, 10 Oct 2008 13:38:29 +0000 (15:38 +0200)
Guenther

source3/nsswitch/pam_winbind.c

index c840bba9d4dd9d8df9bd9714af1447b86a88d7a9..41dacd7105849cd15e5f03cc0b6de8377e921aa2 100644 (file)
@@ -1292,6 +1292,47 @@ static void _pam_warn_krb5_failure(struct pwb_context *ctx,
        }
 }
 
+static bool _pam_check_remark_auth_err(struct pwb_context *ctx,
+                                      const struct wbcAuthErrorInfo *e,
+                                      const char *nt_status_string,
+                                      int *pam_error)
+{
+       const char *ntstatus = NULL;
+       const char *error_string = NULL;
+
+       if (!e || !pam_error) {
+               return false;
+       }
+
+       ntstatus = e->nt_string;
+       if (!ntstatus) {
+               return false;
+       }
+
+       if (strcasecmp(ntstatus, nt_status_string) == 0) {
+
+               error_string = _get_ntstatus_error_string(nt_status_string);
+               if (error_string) {
+                       _make_remark(ctx, PAM_ERROR_MSG, error_string);
+                       *pam_error = e->pam_error;
+                       return true;
+               }
+
+               if (e->display_string) {
+                       _make_remark(ctx, PAM_ERROR_MSG, e->display_string);
+                       *pam_error = e->pam_error;
+                       return true;
+               }
+
+               _make_remark(ctx, PAM_ERROR_MSG, nt_status_string);
+               *pam_error = e->pam_error;
+
+               return true;
+       }
+
+       return false;
+};
+
 /**
  * Compose Password Restriction String for a PAM_ERROR_MSG conversation.
  *