Commit 0bdc2655 0bdc2655831421634652f66931ca75757b4e44ac by Sergey Poznyakoff

Changed PAM error handling.

1 parent 08890024
...@@ -28,10 +28,6 @@ static char *_pwd; ...@@ -28,10 +28,6 @@ static char *_pwd;
28 static char *_user; 28 static char *_user;
29 static int _perr = 0; 29 static int _perr = 0;
30 30
31 #define PAM_ERROR if (_perr || (pamerror != PAM_SUCCESS)) { \
32 pam_end(pamh, 0); \
33 return util_finish (command, RESP_NO, "User name or passwd rejected"); }
34
35 static int 31 static int
36 PAM_gnuimap4d_conv (int num_msg, const struct pam_message **msg, 32 PAM_gnuimap4d_conv (int num_msg, const struct pam_message **msg,
37 struct pam_response **resp, void *appdata_ptr) 33 struct pam_response **resp, void *appdata_ptr)
...@@ -77,6 +73,8 @@ PAM_gnuimap4d_conv (int num_msg, const struct pam_message **msg, ...@@ -77,6 +73,8 @@ PAM_gnuimap4d_conv (int num_msg, const struct pam_message **msg,
77 static struct pam_conv PAM_conversation = { &PAM_gnuimap4d_conv, NULL }; 73 static struct pam_conv PAM_conversation = { &PAM_gnuimap4d_conv, NULL };
78 #endif /* USE_LIBPAM */ 74 #endif /* USE_LIBPAM */
79 75
76 #define PAM_ERROR if (_perr || (pamerror != PAM_SUCCESS)) goto pam_errlab;
77
80 int 78 int
81 imap4d_login (struct imap4d_command *command, char *arg) 79 imap4d_login (struct imap4d_command *command, char *arg)
82 { 80 {
...@@ -138,9 +136,11 @@ imap4d_login (struct imap4d_command *command, char *arg) ...@@ -138,9 +136,11 @@ imap4d_login (struct imap4d_command *command, char *arg)
138 pamerror = pam_acct_mgmt (pamh, 0); 136 pamerror = pam_acct_mgmt (pamh, 0);
139 PAM_ERROR; 137 PAM_ERROR;
140 pamerror = pam_setcred (pamh, PAM_ESTABLISH_CRED); 138 pamerror = pam_setcred (pamh, PAM_ESTABLISH_CRED);
141 PAM_ERROR; 139 pam_errlab:
142 pam_end (pamh, PAM_SUCCESS); 140 pam_end (pamh, PAM_SUCCESS);
143 openlog ("gnu-imap4d", LOG_PID, log_facility); 141 openlog ("gnu-imap4d", LOG_PID, log_facility);
142 if (_perr || (pamerror != PAM_SUCCESS))
143 return util_finish (command, RESP_NO, "User name or passwd rejected");
144 #endif /* USE_LIBPAM */ 144 #endif /* USE_LIBPAM */
145 145
146 if (pw->pw_uid > 0 && !mu_virtual_domain) 146 if (pw->pw_uid > 0 && !mu_virtual_domain)
......