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