s3/doc: add missing documentation for vfs_time_audit
[Samba.git] / source3 / pam_smbpass / general.h
blobf6b3e672aeeeccebd5f4802039f4695b6d9e4a2e
1 #include "../librpc/gen_ndr/samr.h"
3 #ifndef LINUX
4 /* This is only needed by modules in the Sun implementation. */
5 #if defined(HAVE_SECURITY_PAM_APPL_H)
6 #include <security/pam_appl.h>
7 #elif defined(HAVE_PAM_PAM_APPL_H)
8 #include <pam/pam_appl.h>
9 #endif
10 #endif /* LINUX */
12 #if defined(HAVE_SECURITY_PAM_MODULES_H)
13 #include <security/pam_modules.h>
14 #elif defined(HAVE_PAM_PAM_MODULES_H)
15 #include <pam/pam_modules.h>
16 #endif
18 #ifndef PAM_AUTHTOK_RECOVER_ERR
19 #define PAM_AUTHTOK_RECOVER_ERR PAM_AUTHTOK_RECOVERY_ERR
20 #endif
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <syslog.h>
25 #include <unistd.h>
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #include <sys/wait.h>
31 * here is the string to inform the user that the new passwords they
32 * typed were not the same.
35 #define MISTYPED_PASS "Sorry, passwords do not match"
37 /* type definition for the control options */
39 typedef struct {
40 const char *token;
41 unsigned int mask; /* shall assume 32 bits of flags */
42 unsigned int flag;
43 } SMB_Ctrls;
45 #ifndef False
46 #define False (0)
47 #endif
49 #ifndef True
50 #define True (1)
51 #endif
53 /* macro to determine if a given flag is on */
54 #define on(x,ctrl) (smb_args[x].flag & ctrl)
56 /* macro to determine that a given flag is NOT on */
57 #define off(x,ctrl) (!on(x,ctrl))
59 /* macro to turn on/off a ctrl flag manually */
60 #define set(x,ctrl) (ctrl = ((ctrl)&smb_args[x].mask)|smb_args[x].flag)
61 #define unset(x,ctrl) (ctrl &= ~(smb_args[x].flag))
63 /* the generic mask */
64 #define _ALL_ON_ (~0U)
66 /* end of macro definitions definitions for the control flags */
69 * These are the options supported by the smb password module, very
70 * similar to the pwdb options
73 #define SMB__OLD_PASSWD 0 /* internal */
74 #define SMB__VERIFY_PASSWD 1 /* internal */
76 #define SMB_AUDIT 2 /* print more things than debug..
77 some information may be sensitive */
78 #define SMB_USE_FIRST_PASS 3
79 #define SMB_TRY_FIRST_PASS 4
80 #define SMB_NOT_SET_PASS 5 /* don't set the AUTHTOK items */
82 #define SMB__NONULL 6 /* internal */
83 #define SMB__QUIET 7 /* internal */
84 #define SMB_USE_AUTHTOK 8 /* insist on reading PAM_AUTHTOK */
85 #define SMB__NULLOK 9 /* Null token ok */
86 #define SMB_DEBUG 10 /* send more info to syslog(3) */
87 #define SMB_NODELAY 11 /* admin does not want a fail-delay */
88 #define SMB_MIGRATE 12 /* Does no authentication, just
89 updates the smb database. */
90 #define SMB_CONF_FILE 13 /* Alternate location of smb.conf */
92 #define SMB_CTRLS_ 14 /* number of ctrl arguments defined */
94 static const SMB_Ctrls smb_args[SMB_CTRLS_] = {
95 /* symbol token name ctrl mask ctrl *
96 * ------------------ ------------------ -------------- ---------- */
98 /* SMB__OLD_PASSWD */ { NULL, _ALL_ON_, 01 },
99 /* SMB__VERIFY_PASSWD */ { NULL, _ALL_ON_, 02 },
100 /* SMB_AUDIT */ { "audit", _ALL_ON_, 04 },
101 /* SMB_USE_FIRST_PASS */ { "use_first_pass", _ALL_ON_^(030), 010 },
102 /* SMB_TRY_FIRST_PASS */ { "try_first_pass", _ALL_ON_^(030), 020 },
103 /* SMB_NOT_SET_PASS */ { "not_set_pass", _ALL_ON_, 040 },
104 /* SMB__NONULL */ { "nonull", _ALL_ON_, 0100 },
105 /* SMB__QUIET */ { NULL, _ALL_ON_, 0200 },
106 /* SMB_USE_AUTHTOK */ { "use_authtok", _ALL_ON_, 0400 },
107 /* SMB__NULLOK */ { "nullok", _ALL_ON_^(0100), 0 },
108 /* SMB_DEBUG */ { "debug", _ALL_ON_, 01000 },
109 /* SMB_NODELAY */ { "nodelay", _ALL_ON_, 02000 },
110 /* SMB_MIGRATE */ { "migrate", _ALL_ON_^(0100), 04000 },
111 /* SMB_CONF_FILE */ { "smbconf=", _ALL_ON_, 0 },
114 #define SMB_DEFAULTS (smb_args[SMB__NONULL].flag)
117 * the following is used to keep track of the number of times a user fails
118 * to authenticate themself.
121 #define SMB_MAX_RETRIES 3
123 struct _pam_failed_auth {
124 char *user; /* user that's failed to be authenticated */
125 uid_t id; /* uid of requested user */
126 char *agent; /* attempt from user with name */
127 int count; /* number of failures so far */
131 * General use functions go here
134 /* from support.c */
135 int make_remark(pam_handle_t *, unsigned int, int, const char *);