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