1
/* Unix NT password database implementation, version 0.7.5.
3
* This program is free software; you can redistribute it and/or modify it under
4
* the terms of the GNU General Public License as published by the Free
5
* Software Foundation; either version 2 of the License, or (at your option)
8
* This program is distributed in the hope that it will be useful, but WITHOUT
9
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13
* You should have received a copy of the GNU General Public License along with
14
* this program; if not, write to the Free Software Foundation, Inc., 675
15
* Mass Ave, Cambridge, MA 02139, USA.
18
/* indicate the following groups are defined */
25
/* This is only used in the Sun implementation. */
26
#include <security/pam_appl.h>
30
#include <security/pam_modules.h>
38
* pam_sm_acct_mgmt() verifies whether or not the account is disabled.
42
int pam_sm_acct_mgmt( pam_handle_t *pamh, int flags,
43
int argc, const char **argv )
49
struct samu *sampass = NULL;
50
void (*oldsig_handler)(int);
51
extern BOOL in_client;
53
/* Samba initialization. */
55
setup_logging( "pam_smbpass", False );
58
ctrl = set_ctrl( flags, argc, argv );
60
/* get the username */
62
retval = pam_get_user( pamh, &name, "Username: " );
63
if (retval != PAM_SUCCESS) {
64
if (on( SMB_DEBUG, ctrl )) {
65
_log_err( LOG_DEBUG, "acct: could not identify user" );
69
if (on( SMB_DEBUG, ctrl )) {
70
_log_err( LOG_DEBUG, "acct: username [%s] obtained", name );
73
/* Getting into places that might use LDAP -- protect the app
74
from a SIGPIPE it's not expecting */
75
oldsig_handler = CatchSignal(SIGPIPE, SIGNAL_CAST SIG_IGN);
76
if (!initialize_password_db(True)) {
77
_log_err( LOG_ALERT, "Cannot access samba password database" );
78
CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler);
79
return PAM_AUTHINFO_UNAVAIL;
82
/* Get the user's record. */
84
if (!(sampass = samu_new( NULL ))) {
85
CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler);
87
return nt_status_to_pam(NT_STATUS_NO_MEMORY);
90
if (!pdb_getsampwnam(sampass, name )) {
91
_log_err( LOG_DEBUG, "acct: could not identify user" );
92
CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler);
93
return PAM_USER_UNKNOWN;
96
/* check for lookup failure */
97
if (!strlen(pdb_get_username(sampass)) ) {
98
CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler);
99
return PAM_USER_UNKNOWN;
102
if (pdb_get_acct_ctrl(sampass) & ACB_DISABLED) {
103
if (on( SMB_DEBUG, ctrl )) {
105
, "acct: account %s is administratively disabled", name );
107
make_remark( pamh, ctrl, PAM_ERROR_MSG
108
, "Your account has been disabled; "
109
"please see your system administrator." );
111
CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler);
112
return PAM_ACCT_EXPIRED;
115
/* TODO: support for expired passwords. */
117
CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler);
121
/* static module data */
123
struct pam_module _pam_smbpass_acct_modstruct = {