2 /* This is only needed by modules in the Sun implementation. */
3 #include <security/pam_appl.h>
6 #include <security/pam_modules.h>
8 #ifndef PAM_AUTHTOK_RECOVER_ERR
9 #define PAM_AUTHTOK_RECOVER_ERR PAM_AUTHTOK_RECOVERY_ERR
15 #include <sys/types.h>
24 * here is the string to inform the user that the new passwords they
25 * typed were not the same.
28 #define MISTYPED_PASS "Sorry, passwords do not match"
30 /* type definition for the control options */
34 unsigned int mask
; /* shall assume 32 bits of flags */
46 /* macro to determine if a given flag is on */
47 #define on(x,ctrl) (smb_args[x].flag & ctrl)
49 /* macro to determine that a given flag is NOT on */
50 #define off(x,ctrl) (!on(x,ctrl))
52 /* macro to turn on/off a ctrl flag manually */
53 #define set(x,ctrl) (ctrl = ((ctrl)&smb_args[x].mask)|smb_args[x].flag)
54 #define unset(x,ctrl) (ctrl &= ~(smb_args[x].flag))
57 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
60 /* the generic mask */
61 #define _ALL_ON_ (~0U)
63 /* end of macro definitions definitions for the control flags */
66 * These are the options supported by the smb password module, very
67 * similar to the pwdb options
70 #define SMB__OLD_PASSWD 0 /* internal */
71 #define SMB__VERIFY_PASSWD 1 /* internal */
73 #define SMB_AUDIT 2 /* print more things than debug..
74 some information may be sensitive */
75 #define SMB_USE_FIRST_PASS 3
76 #define SMB_TRY_FIRST_PASS 4
77 #define SMB_NOT_SET_PASS 5 /* don't set the AUTHTOK items */
79 #define SMB__NONULL 6 /* internal */
80 #define SMB__QUIET 7 /* internal */
81 #define SMB_USE_AUTHTOK 8 /* insist on reading PAM_AUTHTOK */
82 #define SMB__NULLOK 9 /* Null token ok */
83 #define SMB_DEBUG 10 /* send more info to syslog(3) */
84 #define SMB_NODELAY 11 /* admin does not want a fail-delay */
85 #define SMB_MIGRATE 12 /* Does no authentication, just
86 updates the smb database. */
87 #define SMB_CONF_FILE 13 /* Alternate location of smb.conf */
89 #define SMB_CTRLS_ 14 /* number of ctrl arguments defined */
91 static const SMB_Ctrls smb_args
[SMB_CTRLS_
] = {
92 /* symbol token name ctrl mask ctrl *
93 * ------------------ ------------------ -------------- ---------- */
95 /* SMB__OLD_PASSWD */ { NULL
, _ALL_ON_
, 01 },
96 /* SMB__VERIFY_PASSWD */ { NULL
, _ALL_ON_
, 02 },
97 /* SMB_AUDIT */ { "audit", _ALL_ON_
, 04 },
98 /* SMB_USE_FIRST_PASS */ { "use_first_pass", _ALL_ON_
^(030), 010 },
99 /* SMB_TRY_FIRST_PASS */ { "try_first_pass", _ALL_ON_
^(030), 020 },
100 /* SMB_NOT_SET_PASS */ { "not_set_pass", _ALL_ON_
, 040 },
101 /* SMB__NONULL */ { "nonull", _ALL_ON_
, 0100 },
102 /* SMB__QUIET */ { NULL
, _ALL_ON_
, 0200 },
103 /* SMB_USE_AUTHTOK */ { "use_authtok", _ALL_ON_
, 0400 },
104 /* SMB__NULLOK */ { "nullok", _ALL_ON_
^(0100), 0 },
105 /* SMB_DEBUG */ { "debug", _ALL_ON_
, 01000 },
106 /* SMB_NODELAY */ { "nodelay", _ALL_ON_
, 02000 },
107 /* SMB_MIGRATE */ { "migrate", _ALL_ON_
^(0100), 04000 },
108 /* SMB_CONF_FILE */ { "smbconf=", _ALL_ON_
, 0 },
111 #define SMB_DEFAULTS (smb_args[SMB__NONULL].flag)
114 * the following is used to keep track of the number of times a user fails
115 * to authenticate themself.
118 #define FAIL_PREFIX "-SMB-FAIL-"
119 #define SMB_MAX_RETRIES 3
121 struct _pam_failed_auth
{
122 char *user
; /* user that's failed to be authenticated */
123 int id
; /* uid of requested user */
124 char *agent
; /* attempt from user with name */
125 int count
; /* number of failures so far */