2 Unix SMB/Netbios implementation.
5 Copyright (C) Andrew Tridgell 1992-2001
6 Copyright (C) John H Terpsta 1999-2001
7 Copyright (C) Andrew Bartlett 2001
8 Copyright (C) Jeremy Allison 2001
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 * This module provides PAM based functions for validation of
27 * username/password pairs, account managment, session and access control.
28 * Note: SMB password checking is done in smbpass.c
33 extern int DEBUGLEVEL;
37 /*******************************************************************
38 * Handle PAM authentication
39 * - Access, Authentication, Session, Password
40 * Note: See PAM Documentation and refer to local system PAM implementation
41 * which determines what actions/limitations/allowances become affected.
42 *********************************************************************/
44 #include <security/pam_appl.h>
47 * Structure used to communicate between the conversation function
48 * and the server_login/change password functions.
51 struct smb_pam_userdata {
54 char *PAM_newpassword;
57 typedef int (*smb_pam_conv_fn)(int, const struct pam_message **, struct pam_response **, void *appdata_ptr);
60 * Macros to help make life easy
62 #define COPY_STRING(s) (s) ? strdup(s) : NULL
64 /*******************************************************************
66 *********************************************************************/
68 static BOOL smb_pam_error_handler(pam_handle_t *pamh, int pam_error, char *msg, int dbglvl)
71 if( pam_error != PAM_SUCCESS) {
72 DEBUG(dbglvl, ("smb_pam_error_handler: PAM: %s : %s\n",
73 msg, pam_strerror(pamh, pam_error)));
80 /*******************************************************************
81 This function is a sanity check, to make sure that we NEVER report
83 *********************************************************************/
85 static BOOL smb_pam_nt_status_error_handler(pam_handle_t *pamh, int pam_error,
86 char *msg, int dbglvl, uint32 *nt_status)
88 if (smb_pam_error_handler(pamh, pam_error, msg, dbglvl))
91 if (*nt_status == NT_STATUS_NOPROBLEMO) {
93 DEBUG(0, ("smb_pam_nt_status_error_handler: PAM: BUG: PAM and NT_STATUS \
94 error MISMATCH, forcing to NT_STATUS_LOGON_FAILURE"));
95 *nt_status = NT_STATUS_LOGON_FAILURE;
101 * PAM conversation function
102 * Here we assume (for now, at least) that echo on means login name, and
103 * echo off means password.
106 static int smb_pam_conv(int num_msg,
107 const struct pam_message **msg,
108 struct pam_response **resp,
112 struct pam_response *reply = NULL;
113 struct smb_pam_userdata *udp = (struct smb_pam_userdata *)appdata_ptr;
121 * Apparantly HPUX has a buggy PAM that doesn't support the
122 * appdata_ptr. Fail if this is the case. JRA.
126 DEBUG(0,("smb_pam_conv: PAM on this system is broken - appdata_ptr == NULL !\n"));
130 reply = malloc(sizeof(struct pam_response) * num_msg);
134 memset(reply, '\0', sizeof(struct pam_response) * num_msg);
136 for (replies = 0; replies < num_msg; replies++) {
137 switch (msg[replies]->msg_style) {
138 case PAM_PROMPT_ECHO_ON:
139 reply[replies].resp_retcode = PAM_SUCCESS;
140 reply[replies].resp = COPY_STRING(udp->PAM_username);
144 case PAM_PROMPT_ECHO_OFF:
145 reply[replies].resp_retcode = PAM_SUCCESS;
146 reply[replies].resp = COPY_STRING(udp->PAM_password);
155 reply[replies].resp_retcode = PAM_SUCCESS;
156 reply[replies].resp = NULL;
160 /* Must be an error of some sort... */
171 * PAM password change conversation function
172 * Here we assume (for now, at least) that echo on means login name, and
173 * echo off means password.
176 static void special_char_sub(char *buf)
178 all_string_sub(buf, "\\n", "", 0);
179 all_string_sub(buf, "\\r", "", 0);
180 all_string_sub(buf, "\\s", " ", 0);
181 all_string_sub(buf, "\\t", "\t", 0);
184 static void pwd_sub(char *buf, char *username, char *oldpass, char *newpass)
186 pstring_sub(buf, "%u", username);
187 all_string_sub(buf, "%o", oldpass, sizeof(fstring));
188 all_string_sub(buf, "%n", newpass, sizeof(fstring));
193 struct chat_struct *next, *prev;
198 /**************************************************************
199 Create a linked list containing chat data.
200 ***************************************************************/
202 static struct chat_struct *make_pw_chat(char *p)
206 struct chat_struct *list = NULL;
207 struct chat_struct *t;
208 struct chat_struct *tmp;
211 t = (struct chat_struct *)malloc(sizeof(*t));
213 DEBUG(0,("make_pw_chat: malloc failed!\n"));
219 DLIST_ADD_END(list, t, tmp);
221 if (!next_token(&p, prompt, NULL, sizeof(fstring)))
224 if (strequal(prompt,"."))
227 special_char_sub(prompt);
228 fstrcpy(t->prompt, prompt);
230 trim_string(t->prompt, " ", " ");
232 if (!next_token(&p, reply, NULL, sizeof(fstring)))
235 if (strequal(reply,"."))
238 special_char_sub(reply);
239 fstrcpy(t->reply, reply);
241 trim_string(t->reply, " ", " ");
247 static void free_pw_chat(struct chat_struct *list)
250 struct chat_struct *old_head = list;
251 DLIST_REMOVE(list, list);
256 static int smb_pam_passchange_conv(int num_msg,
257 const struct pam_message **msg,
258 struct pam_response **resp,
262 struct pam_response *reply = NULL;
263 fstring current_prompt;
264 fstring current_reply;
265 struct smb_pam_userdata *udp = (struct smb_pam_userdata *)appdata_ptr;
266 struct chat_struct *pw_chat= make_pw_chat(lp_passwd_chat());
267 struct chat_struct *t;
271 DEBUG(10,("smb_pam_passchange_conv: starting converstation for %d messages\n", num_msg));
280 * Apparantly HPUX has a buggy PAM that doesn't support the
281 * appdata_ptr. Fail if this is the case. JRA.
285 DEBUG(0,("smb_pam_passchange_conv: PAM on this system is broken - appdata_ptr == NULL !\n"));
286 free_pw_chat(pw_chat);
290 reply = malloc(sizeof(struct pam_response) * num_msg);
292 DEBUG(0,("smb_pam_passchange_conv: malloc for reply failed!\n"));
293 free_pw_chat(pw_chat);
297 for (replies = 0; replies < num_msg; replies++) {
299 DEBUG(10,("smb_pam_passchange_conv: Processing message %d\n", replies));
300 switch (msg[replies]->msg_style) {
301 case PAM_PROMPT_ECHO_ON:
302 DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_ON: PAM said: %s\n", msg[replies]->msg));
303 fstrcpy(current_prompt, msg[replies]->msg);
304 trim_string(current_prompt, " ", " ");
305 for (t=pw_chat; t; t=t->next) {
307 DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_ON: trying to match |%s| to |%s|\n",
308 t->prompt, current_prompt ));
310 if (wild_match(t->prompt, current_prompt) == 0) {
311 fstrcpy(current_reply, t->reply);
312 DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_ON: We sent: %s\n", current_reply));
313 pwd_sub(current_reply, udp->PAM_username, udp->PAM_password, udp->PAM_newpassword);
314 #ifdef DEBUG_PASSWORD
315 DEBUG(100,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_ON: We actualy sent: %s\n", current_reply));
317 reply[replies].resp_retcode = PAM_SUCCESS;
318 reply[replies].resp = COPY_STRING(current_reply);
325 DEBUG(3,("smb_pam_passchange_conv: Could not find reply for PAM prompt: %s\n",msg[replies]->msg));
326 free_pw_chat(pw_chat);
333 case PAM_PROMPT_ECHO_OFF:
334 DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_OFF: PAM said: %s\n", msg[replies]->msg));
335 fstrcpy(current_prompt, msg[replies]->msg);
336 trim_string(current_prompt, " ", " ");
337 for (t=pw_chat; t; t=t->next) {
339 DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_OFF: trying to match |%s| to |%s|\n",
340 t->prompt, current_prompt ));
342 if (wild_match(t->prompt, current_prompt) == 0) {
343 fstrcpy(current_reply, t->reply);
344 DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_OFF: We sent: %s\n", current_reply));
345 pwd_sub(current_reply, udp->PAM_username, udp->PAM_password, udp->PAM_newpassword);
346 reply[replies].resp_retcode = PAM_SUCCESS;
347 reply[replies].resp = COPY_STRING(current_reply);
348 #ifdef DEBUG_PASSWORD
349 DEBUG(100,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_OFF: We actualy sent: %s\n", current_reply));
358 DEBUG(3,("smb_pam_passchange_conv: Could not find reply for PAM prompt: %s\n",msg[replies]->msg));
359 free_pw_chat(pw_chat);
371 reply[replies].resp_retcode = PAM_SUCCESS;
372 reply[replies].resp = NULL;
376 /* Must be an error of some sort... */
377 free_pw_chat(pw_chat);
384 free_pw_chat(pw_chat);
390 /***************************************************************************
391 Free up a malloced pam_conv struct.
392 ****************************************************************************/
394 static void smb_free_pam_conv(struct pam_conv *pconv)
397 safe_free(pconv->appdata_ptr);
402 /***************************************************************************
403 Allocate a pam_conv struct.
404 ****************************************************************************/
406 static struct pam_conv *smb_setup_pam_conv(smb_pam_conv_fn smb_pam_conv_fnptr, char *user,
407 char *passwd, char *newpass)
409 struct pam_conv *pconv = (struct pam_conv *)malloc(sizeof(struct pam_conv));
410 struct smb_pam_userdata *udp = (struct smb_pam_userdata *)malloc(sizeof(struct smb_pam_userdata));
412 if (pconv == NULL || udp == NULL) {
418 udp->PAM_username = user;
419 udp->PAM_password = passwd;
420 udp->PAM_newpassword = newpass;
422 pconv->conv = smb_pam_conv_fnptr;
423 pconv->appdata_ptr = (void *)udp;
428 * PAM Closing out cleanup handler
431 static BOOL smb_pam_end(pam_handle_t *pamh, struct pam_conv *smb_pam_conv_ptr)
435 smb_free_pam_conv(smb_pam_conv_ptr);
438 pam_error = pam_end(pamh, 0);
439 if(smb_pam_error_handler(pamh, pam_error, "End Cleanup Failed", 2) == True) {
440 DEBUG(4, ("smb_pam_end: PAM: PAM_END OK.\n"));
444 DEBUG(2,("smb_pam_end: PAM: not initialised"));
449 * Start PAM authentication for specified account
452 static BOOL smb_pam_start(pam_handle_t **pamh, char *user, char *rhost, struct pam_conv *pconv)
456 *pamh = (pam_handle_t *)NULL;
458 DEBUG(4,("smb_pam_start: PAM: Init user: %s\n", user));
460 pam_error = pam_start("samba", user, pconv, pamh);
461 if( !smb_pam_error_handler(*pamh, pam_error, "Init Failed", 0)) {
462 *pamh = (pam_handle_t *)NULL;
467 rhost = client_name();
468 if (strequal(rhost,"UNKNOWN"))
469 rhost = client_addr();
473 DEBUG(4,("smb_pam_start: PAM: setting rhost to: %s\n", rhost));
474 pam_error = pam_set_item(*pamh, PAM_RHOST, rhost);
475 if(!smb_pam_error_handler(*pamh, pam_error, "set rhost failed", 0)) {
476 smb_pam_end(*pamh, pconv);
477 *pamh = (pam_handle_t *)NULL;
482 DEBUG(4,("smb_pam_start: PAM: setting tty\n"));
483 pam_error = pam_set_item(*pamh, PAM_TTY, "samba");
484 if (!smb_pam_error_handler(*pamh, pam_error, "set tty failed", 0)) {
485 smb_pam_end(*pamh, pconv);
486 *pamh = (pam_handle_t *)NULL;
490 DEBUG(4,("smb_pam_start: PAM: Init passed for user: %s\n", user));
495 * PAM Authentication Handler
497 static uint32 smb_pam_auth(pam_handle_t *pamh, char *user)
500 uint32 nt_status = NT_STATUS_LOGON_FAILURE;
503 * To enable debugging set in /etc/pam.d/samba:
504 * auth required /lib/security/pam_pwdb.so nullok shadow audit
507 DEBUG(4,("smb_pam_auth: PAM: Authenticate User: %s\n", user));
508 pam_error = pam_authenticate(pamh, PAM_SILENT | lp_null_passwords() ? 0 : PAM_DISALLOW_NULL_AUTHTOK);
511 DEBUG(2, ("smb_pam_auth: PAM: Athentication Error for user %s\n", user));
512 nt_status = NT_STATUS_WRONG_PASSWORD;
514 case PAM_CRED_INSUFFICIENT:
515 DEBUG(2, ("smb_pam_auth: PAM: Insufficient Credentials for user %s\n", user));
516 nt_status = NT_STATUS_INSUFFICIENT_LOGON_INFO;
518 case PAM_AUTHINFO_UNAVAIL:
519 DEBUG(2, ("smb_pam_auth: PAM: Authentication Information Unavailable for user %s\n", user));
520 nt_status = NT_STATUS_LOGON_FAILURE;
522 case PAM_USER_UNKNOWN:
523 DEBUG(2, ("smb_pam_auth: PAM: Username %s NOT known to Authentication system\n", user));
524 nt_status = NT_STATUS_NO_SUCH_USER;
527 DEBUG(2, ("smb_pam_auth: PAM: One or more authentication modules reports user limit for user %s exceeeded\n", user));
528 nt_status = NT_STATUS_REMOTE_SESSION_LIMIT;
531 DEBUG(0, ("smb_pam_auth: PAM: One or more PAM modules failed to load for user %s\n", user));
532 nt_status = NT_STATUS_LOGON_FAILURE;
535 DEBUG(4, ("smb_pam_auth: PAM: User %s Authenticated OK\n", user));
536 nt_status = NT_STATUS_NOPROBLEMO;
539 DEBUG(0, ("smb_pam_auth: PAM: UNKNOWN ERROR while authenticating user %s\n", user));
540 nt_status = NT_STATUS_LOGON_FAILURE;
544 smb_pam_nt_status_error_handler(pamh, pam_error, "Authentication Failure", 2, &nt_status);
549 * PAM Account Handler
551 static uint32 smb_pam_account(pam_handle_t *pamh, char * user)
554 uint32 nt_status = NT_STATUS_ACCOUNT_DISABLED;
556 DEBUG(4,("smb_pam_account: PAM: Account Management for User: %s\n", user));
557 pam_error = pam_acct_mgmt(pamh, PAM_SILENT); /* Is user account enabled? */
558 switch( pam_error ) {
559 case PAM_AUTHTOK_EXPIRED:
560 DEBUG(2, ("smb_pam_account: PAM: User %s is valid but password is expired\n", user));
561 nt_status = NT_STATUS_PASSWORD_EXPIRED;
563 case PAM_ACCT_EXPIRED:
564 DEBUG(2, ("smb_pam_account: PAM: User %s no longer permitted to access system\n", user));
565 nt_status = NT_STATUS_ACCOUNT_EXPIRED;
568 DEBUG(2, ("smb_pam_account: PAM: There was an authentication error for user %s\n", user));
569 nt_status = NT_STATUS_LOGON_FAILURE;
571 case PAM_PERM_DENIED:
572 DEBUG(0, ("smb_pam_account: PAM: User %s is NOT permitted to access system at this time\n", user));
573 nt_status = NT_STATUS_ACCOUNT_RESTRICTION;
575 case PAM_USER_UNKNOWN:
576 DEBUG(0, ("smb_pam_account: PAM: User \"%s\" is NOT known to account management\n", user));
577 nt_status = NT_STATUS_NO_SUCH_USER;
580 DEBUG(4, ("smb_pam_account: PAM: Account OK for User: %s\n", user));
581 nt_status = NT_STATUS_NOPROBLEMO;
584 nt_status = NT_STATUS_ACCOUNT_DISABLED;
585 DEBUG(0, ("smb_pam_account: PAM: UNKNOWN PAM ERROR (%d) during Account Management for User: %s\n", pam_error, user));
589 smb_pam_nt_status_error_handler(pamh, pam_error, "Account Check Failed", 2, &nt_status);
594 * PAM Credential Setting
597 static uint32 smb_pam_setcred(pam_handle_t *pamh, char * user)
600 uint32 nt_status = NT_STATUS_NO_TOKEN;
603 * This will allow samba to aquire a kerberos token. And, when
604 * exporting an AFS cell, be able to /write/ to this cell.
607 DEBUG(4,("PAM: Account Management SetCredentials for User: %s\n", user));
608 pam_error = pam_setcred(pamh, (PAM_ESTABLISH_CRED|PAM_SILENT));
609 switch( pam_error ) {
610 case PAM_CRED_UNAVAIL:
611 DEBUG(0, ("smb_pam_setcred: PAM: Credentials not found for user:%s\n", user ));
612 nt_status = NT_STATUS_NO_TOKEN;
614 case PAM_CRED_EXPIRED:
615 DEBUG(0, ("smb_pam_setcred: PAM: Credentials for user: \"%s\" EXPIRED!\n", user ));
616 nt_status = NT_STATUS_PASSWORD_EXPIRED;
618 case PAM_USER_UNKNOWN:
619 DEBUG(0, ("smb_pam_setcred: PAM: User: \"%s\" is NOT known so can not set credentials!\n", user ));
620 nt_status = NT_STATUS_NO_SUCH_USER;
623 DEBUG(0, ("smb_pam_setcred: PAM: Unknown setcredentials error - unable to set credentials for %s\n", user ));
624 nt_status = NT_STATUS_LOGON_FAILURE;
627 DEBUG(4, ("smb_pam_setcred: PAM: SetCredentials OK for User: %s\n", user));
628 nt_status = NT_STATUS_NOPROBLEMO;
631 DEBUG(0, ("smb_pam_setcred: PAM: UNKNOWN PAM ERROR (%d) during SetCredentials for User: %s\n", pam_error, user));
632 nt_status = NT_STATUS_NO_TOKEN;
636 smb_pam_nt_status_error_handler(pamh, pam_error, "Set Credential Failure", 2, &nt_status);
641 * PAM Internal Session Handler
643 static BOOL smb_internal_pam_session(pam_handle_t *pamh, char *user, char *tty, BOOL flag)
648 DEBUG(4,("smb_internal_pam_session: PAM: tty set to: %s\n", tty));
649 pam_error = pam_set_item(pamh, PAM_TTY, tty);
650 if (!smb_pam_error_handler(pamh, pam_error, "set tty failed", 0))
655 pam_error = pam_open_session(pamh, PAM_SILENT);
656 if (!smb_pam_error_handler(pamh, pam_error, "session setup failed", 0))
659 pam_setcred(pamh, (PAM_DELETE_CRED|PAM_SILENT)); /* We don't care if this fails */
660 pam_error = pam_close_session(pamh, PAM_SILENT); /* This will probably pick up the error anyway */
661 if (!smb_pam_error_handler(pamh, pam_error, "session close failed", 0))
668 * Internal PAM Password Changer.
671 static BOOL smb_pam_chauthtok(pam_handle_t *pamh, char * user)
675 DEBUG(4,("smb_pam_chauthtok: PAM: Password Change for User: %s\n", user));
677 pam_error = pam_chauthtok(pamh, PAM_SILENT); /* Change Password */
679 switch( pam_error ) {
680 case PAM_AUTHTOK_ERR:
681 DEBUG(2, ("PAM: unable to obtain the new authentication token - is password to weak?\n"));
684 /* This doesn't seem to be defined on Solaris. JRA */
685 #ifdef PAM_AUTHTOK_RECOVER_ERR
686 case PAM_AUTHTOK_RECOVER_ERR:
687 DEBUG(2, ("PAM: unable to obtain the old authentication token - was the old password wrong?.\n"));
691 case PAM_AUTHTOK_LOCK_BUSY:
692 DEBUG(2, ("PAM: unable to change the authentication token since it is currently locked.\n"));
694 case PAM_AUTHTOK_DISABLE_AGING:
695 DEBUG(2, ("PAM: Authentication token aging has been disabled.\n"));
697 case PAM_PERM_DENIED:
698 DEBUG(0, ("PAM: Permission denied.\n"));
701 DEBUG(0, ("PAM: Could not update all authentication token(s). No authentication tokens were updated.\n"));
703 case PAM_USER_UNKNOWN:
704 DEBUG(0, ("PAM: User not known to PAM\n"));
707 DEBUG(4, ("PAM: Account OK for User: %s\n", user));
710 DEBUG(0, ("PAM: UNKNOWN PAM ERROR (%d) for User: %s\n", pam_error, user));
713 if(!smb_pam_error_handler(pamh, pam_error, "Password Change Failed", 2)) {
717 /* If this point is reached, the password has changed. */
722 * PAM Externally accessible Session handler
725 BOOL smb_pam_claim_session(char *user, char *tty, char *rhost)
727 pam_handle_t *pamh = NULL;
728 struct pam_conv *pconv = NULL;
730 /* Ignore PAM if told to. */
732 if (!lp_obey_pam_restrictions())
735 if ((pconv = smb_setup_pam_conv(smb_pam_conv, user, NULL, NULL)) == NULL)
738 if (!smb_pam_start(&pamh, user, rhost, pconv))
741 if (!smb_internal_pam_session(pamh, user, tty, True)) {
742 smb_pam_end(pamh, pconv);
746 return smb_pam_end(pamh, pconv);
750 * PAM Externally accessible Session handler
753 BOOL smb_pam_close_session(char *user, char *tty, char *rhost)
755 pam_handle_t *pamh = NULL;
756 struct pam_conv *pconv = NULL;
758 /* Ignore PAM if told to. */
760 if (!lp_obey_pam_restrictions())
763 if ((pconv = smb_setup_pam_conv(smb_pam_conv, user, NULL, NULL)) == NULL)
766 if (!smb_pam_start(&pamh, user, rhost, pconv))
769 if (!smb_internal_pam_session(pamh, user, tty, False)) {
770 smb_pam_end(pamh, pconv);
774 return smb_pam_end(pamh, pconv);
778 * PAM Externally accessible Account handler
781 uint32 smb_pam_accountcheck(char * user)
783 uint32 nt_status = NT_STATUS_ACCOUNT_DISABLED;
784 pam_handle_t *pamh = NULL;
785 struct pam_conv *pconv = NULL;
787 /* Ignore PAM if told to. */
789 if (!lp_obey_pam_restrictions())
790 return NT_STATUS_NOPROBLEMO;
792 if ((pconv = smb_setup_pam_conv(smb_pam_conv, user, NULL, NULL)) == NULL)
795 if (!smb_pam_start(&pamh, user, NULL, pconv))
796 return NT_STATUS_ACCOUNT_DISABLED;
798 if ((nt_status = smb_pam_account(pamh, user)) != NT_STATUS_NOPROBLEMO)
799 DEBUG(0, ("smb_pam_accountcheck: PAM: Account Validation Failed - Rejecting User %s!\n", user));
801 smb_pam_end(pamh, pconv);
806 * PAM Password Validation Suite
809 uint32 smb_pam_passcheck(char * user, char * password)
811 pam_handle_t *pamh = NULL;
812 uint32 nt_status = NT_STATUS_LOGON_FAILURE;
813 struct pam_conv *pconv = NULL;
816 * Note we can't ignore PAM here as this is the only
817 * way of doing auths on plaintext passwords when
818 * compiled --with-pam.
821 if ((pconv = smb_setup_pam_conv(smb_pam_conv, user, password, NULL)) == NULL)
822 return NT_STATUS_LOGON_FAILURE;
824 if (!smb_pam_start(&pamh, user, NULL, pconv))
825 return NT_STATUS_LOGON_FAILURE;
827 if ((nt_status = smb_pam_auth(pamh, user)) != NT_STATUS_NOPROBLEMO) {
828 DEBUG(0, ("smb_pam_passcheck: PAM: smb_pam_auth failed - Rejecting User %s !\n", user));
829 smb_pam_end(pamh, pconv);
833 if ((nt_status = smb_pam_account(pamh, user)) != NT_STATUS_NOPROBLEMO) {
834 DEBUG(0, ("smb_pam_passcheck: PAM: smb_pam_account failed - Rejecting User %s !\n", user));
835 smb_pam_end(pamh, pconv);
839 if ((nt_status = smb_pam_setcred(pamh, user)) != NT_STATUS_NOPROBLEMO) {
840 DEBUG(0, ("smb_pam_passcheck: PAM: smb_pam_setcred failed - Rejecting User %s !\n", user));
841 smb_pam_end(pamh, pconv);
845 smb_pam_end(pamh, pconv);
850 * PAM Password Change Suite
853 BOOL smb_pam_passchange(char * user, char * oldpassword, char * newpassword)
855 /* Appropriate quantities of root should be obtained BEFORE calling this function */
856 struct pam_conv *pconv = NULL;
857 pam_handle_t *pamh = NULL;
859 if ((pconv = smb_setup_pam_conv(smb_pam_passchange_conv, user, oldpassword, newpassword)) == NULL)
862 if(!smb_pam_start(&pamh, user, NULL, pconv))
865 if (!smb_pam_chauthtok(pamh, user)) {
866 DEBUG(0, ("smb_pam_passchange: PAM: Password Change Failed for user %s!\n", user));
867 smb_pam_end(pamh, pconv);
871 return smb_pam_end(pamh, pconv);
876 /* If PAM not used, no PAM restrictions on accounts. */
877 uint32 smb_pam_accountcheck(char * user)
879 return NT_STATUS_NOPROBLEMO;
882 /* If PAM not used, also no PAM restrictions on sessions. */
883 BOOL smb_pam_claim_session(char *user, char *tty, char *rhost)
888 /* If PAM not used, also no PAM restrictions on sessions. */
889 BOOL smb_pam_close_session(char *in_user, char *tty, char *rhost)
893 #endif /* WITH_PAM */