add WITH_SENDFILE profiling data (from Pierre Belanger)
[Samba.git] / source / pam_smbpass / pam_smb_acct.c
blob22f8e7565814103e22ce39b8d575e8afad8370a8
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)
6 * any later version.
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
11 * more details.
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 */
19 #define PAM_SM_ACCT
21 #include "includes.h"
23 #ifndef LINUX
25 /* This is only used in the Sun implementation. */
26 #include <security/pam_appl.h>
28 #endif /* LINUX */
30 #include <security/pam_modules.h>
32 #include "general.h"
34 #include "support.h"
37 * pam_sm_acct_mgmt() verifies whether or not the account is disabled.
41 int pam_sm_acct_mgmt( pam_handle_t *pamh, int flags,
42 int argc, const char **argv )
44 unsigned int ctrl;
45 int retval;
47 const char *name;
48 SAM_ACCOUNT *sampass = NULL;
50 extern BOOL in_client;
52 /* Samba initialization. */
53 setup_logging( "pam_smbpass", False );
54 charset_initialise();
55 codepage_initialise(lp_client_code_page());
56 in_client = True;
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" );
67 return retval;
69 if (on( SMB_DEBUG, ctrl )) {
70 _log_err( LOG_DEBUG, "acct: username [%s] obtained", name );
73 if (!initialize_password_db(True)) {
74 _log_err( LOG_ALERT, "Cannot access samba password database" );
75 return PAM_AUTHINFO_UNAVAIL;
78 /* Get the user's record. */
79 pdb_init_sam(&sampass);
80 pdb_getsampwnam(sampass, name );
82 if (!sampass)
83 return PAM_USER_UNKNOWN;
85 if (pdb_get_acct_ctrl(sampass) & ACB_DISABLED) {
86 if (on( SMB_DEBUG, ctrl )) {
87 _log_err( LOG_DEBUG
88 , "acct: account %s is administratively disabled", name );
90 make_remark( pamh, ctrl, PAM_ERROR_MSG
91 , "Your account has been disabled; "
92 "please see your system administrator." );
94 return PAM_ACCT_EXPIRED;
97 /* TODO: support for expired passwords. */
99 return PAM_SUCCESS;
102 /* static module data */
103 #ifdef PAM_STATIC
104 struct pam_module _pam_smbpass_acct_modstruct = {
105 "pam_smbpass",
106 NULL,
107 NULL,
108 pam_sm_acct_mgmt,
109 NULL,
110 NULL,
111 NULL
113 #endif