2 Unix SMB/CIFS implementation.
4 Copyright (C) Andrew Tridgell 1992-2001
5 Copyright (C) John H Terpsta 1999-2001
6 Copyright (C) Andrew Bartlett 2001
7 Copyright (C) Jeremy Allison 2001
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * This module provides PAM based functions for validation of
26 * username/password pairs, account managment, session and access control.
27 * Note: SMB password checking is done in smbpass.c
34 /*******************************************************************
35 * Handle PAM authentication
36 * - Access, Authentication, Session, Password
37 * Note: See PAM Documentation and refer to local system PAM implementation
38 * which determines what actions/limitations/allowances become affected.
39 *********************************************************************/
41 #include <security/pam_appl.h>
44 * Structure used to communicate between the conversation function
45 * and the server_login/change password functions.
48 struct smb_pam_userdata {
49 const char *PAM_username;
50 const char *PAM_password;
51 const char *PAM_newpassword;
54 typedef int (*smb_pam_conv_fn)(int, const struct pam_message **, struct pam_response **, void *appdata_ptr);
57 * Macros to help make life easy
59 #define COPY_STRING(s) (s) ? strdup(s) : NULL
61 /*******************************************************************
63 *********************************************************************/
65 static BOOL smb_pam_error_handler(pam_handle_t *pamh, int pam_error, char *msg, int dbglvl)
68 if( pam_error != PAM_SUCCESS) {
69 DEBUG(dbglvl, ("smb_pam_error_handler: PAM: %s : %s\n",
70 msg, pam_strerror(pamh, pam_error)));
77 /*******************************************************************
78 This function is a sanity check, to make sure that we NEVER report
80 *********************************************************************/
82 static BOOL smb_pam_nt_status_error_handler(pam_handle_t *pamh, int pam_error,
83 char *msg, int dbglvl,
86 *nt_status = pam_to_nt_status(pam_error);
88 if (smb_pam_error_handler(pamh, pam_error, msg, dbglvl))
91 if (NT_STATUS_IS_OK(*nt_status)) {
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, const char *username, const char *oldpass, const 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 (unix_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);
332 case PAM_PROMPT_ECHO_OFF:
333 DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_OFF: PAM said: %s\n", msg[replies]->msg));
334 fstrcpy(current_prompt, msg[replies]->msg);
335 trim_string(current_prompt, " ", " ");
336 for (t=pw_chat; t; t=t->next) {
338 DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_OFF: trying to match |%s| to |%s|\n",
339 t->prompt, current_prompt ));
341 if (unix_wild_match(t->prompt, current_prompt) == 0) {
342 fstrcpy(current_reply, t->reply);
343 DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_OFF: We sent: %s\n", current_reply));
344 pwd_sub(current_reply, udp->PAM_username, udp->PAM_password, udp->PAM_newpassword);
345 reply[replies].resp_retcode = PAM_SUCCESS;
346 reply[replies].resp = COPY_STRING(current_reply);
347 #ifdef DEBUG_PASSWORD
348 DEBUG(100,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_OFF: We actualy sent: %s\n", current_reply));
357 DEBUG(3,("smb_pam_passchange_conv: Could not find reply for PAM prompt: %s\n",msg[replies]->msg));
358 free_pw_chat(pw_chat);
369 reply[replies].resp_retcode = PAM_SUCCESS;
370 reply[replies].resp = NULL;
374 /* Must be an error of some sort... */
375 free_pw_chat(pw_chat);
381 free_pw_chat(pw_chat);
387 /***************************************************************************
388 Free up a malloced pam_conv struct.
389 ****************************************************************************/
391 static void smb_free_pam_conv(struct pam_conv *pconv)
394 SAFE_FREE(pconv->appdata_ptr);
399 /***************************************************************************
400 Allocate a pam_conv struct.
401 ****************************************************************************/
403 static struct pam_conv *smb_setup_pam_conv(smb_pam_conv_fn smb_pam_conv_fnptr, const char *user,
404 const char *passwd, const char *newpass)
406 struct pam_conv *pconv = (struct pam_conv *)malloc(sizeof(struct pam_conv));
407 struct smb_pam_userdata *udp = (struct smb_pam_userdata *)malloc(sizeof(struct smb_pam_userdata));
409 if (pconv == NULL || udp == NULL) {
415 udp->PAM_username = user;
416 udp->PAM_password = passwd;
417 udp->PAM_newpassword = newpass;
419 pconv->conv = smb_pam_conv_fnptr;
420 pconv->appdata_ptr = (void *)udp;
425 * PAM Closing out cleanup handler
428 static BOOL smb_pam_end(pam_handle_t *pamh, struct pam_conv *smb_pam_conv_ptr)
432 smb_free_pam_conv(smb_pam_conv_ptr);
435 pam_error = pam_end(pamh, 0);
436 if(smb_pam_error_handler(pamh, pam_error, "End Cleanup Failed", 2) == True) {
437 DEBUG(4, ("smb_pam_end: PAM: PAM_END OK.\n"));
441 DEBUG(2,("smb_pam_end: PAM: not initialised"));
446 * Start PAM authentication for specified account
449 static BOOL smb_pam_start(pam_handle_t **pamh, const char *user, const char *rhost, struct pam_conv *pconv)
452 const char *our_rhost;
454 *pamh = (pam_handle_t *)NULL;
456 DEBUG(4,("smb_pam_start: PAM: Init user: %s\n", user));
458 pam_error = pam_start("samba", user, pconv, pamh);
459 if( !smb_pam_error_handler(*pamh, pam_error, "Init Failed", 0)) {
460 *pamh = (pam_handle_t *)NULL;
465 our_rhost = client_name();
466 if (strequal(rhost,"UNKNOWN"))
467 our_rhost = client_addr();
473 DEBUG(4,("smb_pam_start: PAM: setting rhost to: %s\n", our_rhost));
474 pam_error = pam_set_item(*pamh, PAM_RHOST, our_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 NTSTATUS smb_pam_auth(pam_handle_t *pamh, char *user)
500 NTSTATUS 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));
513 case PAM_CRED_INSUFFICIENT:
514 DEBUG(2, ("smb_pam_auth: PAM: Insufficient Credentials for user %s\n", user));
516 case PAM_AUTHINFO_UNAVAIL:
517 DEBUG(2, ("smb_pam_auth: PAM: Authentication Information Unavailable for user %s\n", user));
519 case PAM_USER_UNKNOWN:
520 DEBUG(2, ("smb_pam_auth: PAM: Username %s NOT known to Authentication system\n", user));
523 DEBUG(2, ("smb_pam_auth: PAM: One or more authentication modules reports user limit for user %s exceeeded\n", user));
526 DEBUG(0, ("smb_pam_auth: PAM: One or more PAM modules failed to load for user %s\n", user));
529 DEBUG(4, ("smb_pam_auth: PAM: User %s Authenticated OK\n", user));
532 DEBUG(0, ("smb_pam_auth: PAM: UNKNOWN ERROR while authenticating user %s\n", user));
536 smb_pam_nt_status_error_handler(pamh, pam_error, "Authentication Failure", 2, &nt_status);
541 * PAM Account Handler
543 static NTSTATUS smb_pam_account(pam_handle_t *pamh, const char * user)
546 NTSTATUS nt_status = NT_STATUS_ACCOUNT_DISABLED;
548 DEBUG(4,("smb_pam_account: PAM: Account Management for User: %s\n", user));
549 pam_error = pam_acct_mgmt(pamh, PAM_SILENT); /* Is user account enabled? */
550 switch( pam_error ) {
551 case PAM_AUTHTOK_EXPIRED:
552 DEBUG(2, ("smb_pam_account: PAM: User %s is valid but password is expired\n", user));
554 case PAM_ACCT_EXPIRED:
555 DEBUG(2, ("smb_pam_account: PAM: User %s no longer permitted to access system\n", user));
558 DEBUG(2, ("smb_pam_account: PAM: There was an authentication error for user %s\n", user));
560 case PAM_PERM_DENIED:
561 DEBUG(0, ("smb_pam_account: PAM: User %s is NOT permitted to access system at this time\n", user));
563 case PAM_USER_UNKNOWN:
564 DEBUG(0, ("smb_pam_account: PAM: User \"%s\" is NOT known to account management\n", user));
567 DEBUG(4, ("smb_pam_account: PAM: Account OK for User: %s\n", user));
570 DEBUG(0, ("smb_pam_account: PAM: UNKNOWN PAM ERROR (%d) during Account Management for User: %s\n", pam_error, user));
574 smb_pam_nt_status_error_handler(pamh, pam_error, "Account Check Failed", 2, &nt_status);
579 * PAM Credential Setting
582 static NTSTATUS smb_pam_setcred(pam_handle_t *pamh, char * user)
585 NTSTATUS nt_status = NT_STATUS_NO_TOKEN;
588 * This will allow samba to aquire a kerberos token. And, when
589 * exporting an AFS cell, be able to /write/ to this cell.
592 DEBUG(4,("PAM: Account Management SetCredentials for User: %s\n", user));
593 pam_error = pam_setcred(pamh, (PAM_ESTABLISH_CRED|PAM_SILENT));
594 switch( pam_error ) {
595 case PAM_CRED_UNAVAIL:
596 DEBUG(0, ("smb_pam_setcred: PAM: Credentials not found for user:%s\n", user ));
598 case PAM_CRED_EXPIRED:
599 DEBUG(0, ("smb_pam_setcred: PAM: Credentials for user: \"%s\" EXPIRED!\n", user ));
601 case PAM_USER_UNKNOWN:
602 DEBUG(0, ("smb_pam_setcred: PAM: User: \"%s\" is NOT known so can not set credentials!\n", user ));
605 DEBUG(0, ("smb_pam_setcred: PAM: Unknown setcredentials error - unable to set credentials for %s\n", user ));
608 DEBUG(4, ("smb_pam_setcred: PAM: SetCredentials OK for User: %s\n", user));
611 DEBUG(0, ("smb_pam_setcred: PAM: UNKNOWN PAM ERROR (%d) during SetCredentials for User: %s\n", pam_error, user));
615 smb_pam_nt_status_error_handler(pamh, pam_error, "Set Credential Failure", 2, &nt_status);
620 * PAM Internal Session Handler
622 static BOOL smb_internal_pam_session(pam_handle_t *pamh, char *user, char *tty, BOOL flag)
627 DEBUG(4,("smb_internal_pam_session: PAM: tty set to: %s\n", tty));
628 pam_error = pam_set_item(pamh, PAM_TTY, tty);
629 if (!smb_pam_error_handler(pamh, pam_error, "set tty failed", 0))
634 pam_error = pam_open_session(pamh, PAM_SILENT);
635 if (!smb_pam_error_handler(pamh, pam_error, "session setup failed", 0))
638 pam_setcred(pamh, (PAM_DELETE_CRED|PAM_SILENT)); /* We don't care if this fails */
639 pam_error = pam_close_session(pamh, PAM_SILENT); /* This will probably pick up the error anyway */
640 if (!smb_pam_error_handler(pamh, pam_error, "session close failed", 0))
647 * Internal PAM Password Changer.
650 static BOOL smb_pam_chauthtok(pam_handle_t *pamh, const char * user)
654 DEBUG(4,("smb_pam_chauthtok: PAM: Password Change for User: %s\n", user));
656 pam_error = pam_chauthtok(pamh, PAM_SILENT); /* Change Password */
658 switch( pam_error ) {
659 case PAM_AUTHTOK_ERR:
660 DEBUG(2, ("PAM: unable to obtain the new authentication token - is password to weak?\n"));
663 /* This doesn't seem to be defined on Solaris. JRA */
664 #ifdef PAM_AUTHTOK_RECOVER_ERR
665 case PAM_AUTHTOK_RECOVER_ERR:
666 DEBUG(2, ("PAM: unable to obtain the old authentication token - was the old password wrong?.\n"));
670 case PAM_AUTHTOK_LOCK_BUSY:
671 DEBUG(2, ("PAM: unable to change the authentication token since it is currently locked.\n"));
673 case PAM_AUTHTOK_DISABLE_AGING:
674 DEBUG(2, ("PAM: Authentication token aging has been disabled.\n"));
676 case PAM_PERM_DENIED:
677 DEBUG(0, ("PAM: Permission denied.\n"));
680 DEBUG(0, ("PAM: Could not update all authentication token(s). No authentication tokens were updated.\n"));
682 case PAM_USER_UNKNOWN:
683 DEBUG(0, ("PAM: User not known to PAM\n"));
686 DEBUG(4, ("PAM: Account OK for User: %s\n", user));
689 DEBUG(0, ("PAM: UNKNOWN PAM ERROR (%d) for User: %s\n", pam_error, user));
692 if(!smb_pam_error_handler(pamh, pam_error, "Password Change Failed", 2)) {
696 /* If this point is reached, the password has changed. */
701 * PAM Externally accessible Session handler
704 BOOL smb_pam_claim_session(char *user, char *tty, char *rhost)
706 pam_handle_t *pamh = NULL;
707 struct pam_conv *pconv = NULL;
709 /* Ignore PAM if told to. */
711 if (!lp_obey_pam_restrictions())
714 if ((pconv = smb_setup_pam_conv(smb_pam_conv, user, NULL, NULL)) == NULL)
717 if (!smb_pam_start(&pamh, user, rhost, pconv))
720 if (!smb_internal_pam_session(pamh, user, tty, True)) {
721 smb_pam_end(pamh, pconv);
725 return smb_pam_end(pamh, pconv);
729 * PAM Externally accessible Session handler
732 BOOL smb_pam_close_session(char *user, char *tty, char *rhost)
734 pam_handle_t *pamh = NULL;
735 struct pam_conv *pconv = NULL;
737 /* Ignore PAM if told to. */
739 if (!lp_obey_pam_restrictions())
742 if ((pconv = smb_setup_pam_conv(smb_pam_conv, user, NULL, NULL)) == NULL)
745 if (!smb_pam_start(&pamh, user, rhost, pconv))
748 if (!smb_internal_pam_session(pamh, user, tty, False)) {
749 smb_pam_end(pamh, pconv);
753 return smb_pam_end(pamh, pconv);
757 * PAM Externally accessible Account handler
760 NTSTATUS smb_pam_accountcheck(const char * user)
762 NTSTATUS nt_status = NT_STATUS_ACCOUNT_DISABLED;
763 pam_handle_t *pamh = NULL;
764 struct pam_conv *pconv = NULL;
766 /* Ignore PAM if told to. */
768 if (!lp_obey_pam_restrictions())
771 if ((pconv = smb_setup_pam_conv(smb_pam_conv, user, NULL, NULL)) == NULL)
772 return NT_STATUS_NO_MEMORY;
774 if (!smb_pam_start(&pamh, user, NULL, pconv))
775 return NT_STATUS_ACCOUNT_DISABLED;
777 if (!NT_STATUS_IS_OK(nt_status = smb_pam_account(pamh, user)))
778 DEBUG(0, ("smb_pam_accountcheck: PAM: Account Validation Failed - Rejecting User %s!\n", user));
780 smb_pam_end(pamh, pconv);
785 * PAM Password Validation Suite
788 NTSTATUS smb_pam_passcheck(char * user, char * password)
790 pam_handle_t *pamh = NULL;
791 NTSTATUS nt_status = NT_STATUS_LOGON_FAILURE;
792 struct pam_conv *pconv = NULL;
795 * Note we can't ignore PAM here as this is the only
796 * way of doing auths on plaintext passwords when
797 * compiled --with-pam.
800 if ((pconv = smb_setup_pam_conv(smb_pam_conv, user, password, NULL)) == NULL)
801 return NT_STATUS_LOGON_FAILURE;
803 if (!smb_pam_start(&pamh, user, NULL, pconv))
804 return NT_STATUS_LOGON_FAILURE;
806 if (!NT_STATUS_IS_OK(nt_status = smb_pam_auth(pamh, user))) {
807 DEBUG(0, ("smb_pam_passcheck: PAM: smb_pam_auth failed - Rejecting User %s !\n", user));
808 smb_pam_end(pamh, pconv);
812 if (!NT_STATUS_IS_OK(nt_status = smb_pam_account(pamh, user))) {
813 DEBUG(0, ("smb_pam_passcheck: PAM: smb_pam_account failed - Rejecting User %s !\n", user));
814 smb_pam_end(pamh, pconv);
818 if (!NT_STATUS_IS_OK(nt_status = smb_pam_setcred(pamh, user))) {
819 DEBUG(0, ("smb_pam_passcheck: PAM: smb_pam_setcred failed - Rejecting User %s !\n", user));
820 smb_pam_end(pamh, pconv);
824 smb_pam_end(pamh, pconv);
829 * PAM Password Change Suite
832 BOOL smb_pam_passchange(const char * user, const char * oldpassword, const char * newpassword)
834 /* Appropriate quantities of root should be obtained BEFORE calling this function */
835 struct pam_conv *pconv = NULL;
836 pam_handle_t *pamh = NULL;
838 if ((pconv = smb_setup_pam_conv(smb_pam_passchange_conv, user, oldpassword, newpassword)) == NULL)
841 if(!smb_pam_start(&pamh, user, NULL, pconv))
844 if (!smb_pam_chauthtok(pamh, user)) {
845 DEBUG(0, ("smb_pam_passchange: PAM: Password Change Failed for user %s!\n", user));
846 smb_pam_end(pamh, pconv);
850 return smb_pam_end(pamh, pconv);
855 /* If PAM not used, no PAM restrictions on accounts. */
856 NTSTATUS smb_pam_accountcheck(const char * user)
861 /* If PAM not used, also no PAM restrictions on sessions. */
862 BOOL smb_pam_claim_session(char *user, char *tty, char *rhost)
867 /* If PAM not used, also no PAM restrictions on sessions. */
868 BOOL smb_pam_close_session(char *in_user, char *tty, char *rhost)
872 #endif /* WITH_PAM */