selftest: Replace perl subunit formatter with python subunit formatter,
[Samba/gebeck_regimport.git] / nsswitch / pam_winbind.h
blobed924794c4866ae516c701c30034c1676e07603d
1 /* pam_winbind header file
2 (Solaris needs some macros from Linux for common PAM code)
4 Shirish Kalele 2000
5 */
7 #include "../lib/replace/replace.h"
8 #include "system/syslog.h"
9 #include "system/time.h"
10 #include <talloc.h>
11 #include "libwbclient/wbclient.h"
13 #define MODULE_NAME "pam_winbind"
14 #define PAM_SM_AUTH
15 #define PAM_SM_ACCOUNT
16 #define PAM_SM_PASSWORD
17 #define PAM_SM_SESSION
19 #ifndef PAM_WINBIND_CONFIG_FILE
20 #define PAM_WINBIND_CONFIG_FILE "/etc/security/pam_winbind.conf"
21 #endif
23 #include <iniparser.h>
25 #ifdef HAVE_LIBINTL_H
26 #include <libintl.h>
27 #endif
29 #if defined(LINUX)
31 /* newer versions of PAM have this in _pam_compat.h */
32 #ifndef PAM_AUTHTOK_RECOVERY_ERR
33 #define PAM_AUTHTOK_RECOVERY_ERR PAM_AUTHTOK_RECOVER_ERR
34 #endif
36 #else /* !LINUX */
38 /* Solaris always uses dynamic pam modules */
39 #define PAM_EXTERN extern
40 #if defined(HAVE_SECURITY_PAM_APPL_H)
41 #include <security/pam_appl.h>
42 #elif defined(HAVE_PAM_PAM_APPL_H)
43 #include <pam/pam_appl.h>
44 #endif
46 #ifndef PAM_AUTHTOK_RECOVER_ERR
47 #define PAM_AUTHTOK_RECOVER_ERR PAM_AUTHTOK_RECOVERY_ERR
48 #endif
50 #endif /* defined(SUNOS5) || defined(SUNOS4) || defined(HPUX) || defined(FREEBSD) || defined(AIX) */
52 #if defined(HAVE_SECURITY_PAM_MODULES_H)
53 #include <security/pam_modules.h>
54 #elif defined(HAVE_PAM_PAM_MODULES_H)
55 #include <pam/pam_modules.h>
56 #endif
58 #if defined(HAVE_SECURITY__PAM_MACROS_H)
59 #include <security/_pam_macros.h>
60 #elif defined(HAVE_PAM__PAM_MACROS_H)
61 #include <pam/_pam_macros.h>
62 #else
63 /* Define required macros from (Linux PAM 0.68) security/_pam_macros.h */
64 #define _pam_drop_reply(/* struct pam_response * */ reply, /* int */ replies) \
65 do { \
66 int reply_i; \
68 for (reply_i=0; reply_i<replies; ++reply_i) { \
69 if (reply[reply_i].resp) { \
70 _pam_overwrite(reply[reply_i].resp); \
71 free(reply[reply_i].resp); \
72 } \
73 } \
74 if (reply) \
75 free(reply); \
76 } while (0)
78 #define _pam_overwrite(x) \
79 do { \
80 register char *__xx__; \
81 if ((__xx__=(x))) \
82 while (*__xx__) \
83 *__xx__++ = '\0'; \
84 } while (0)
87 * Don't just free it, forget it too.
90 #define _pam_drop(X) SAFE_FREE(X)
92 #define x_strdup(s) ( (s) ? strdup(s):NULL )
93 #endif /* HAVE_SECURITY__PAM_MACROS_H */
95 #ifdef HAVE_SECURITY_PAM_EXT_H
96 #include <security/pam_ext.h>
97 #endif
99 #define WINBIND_DEBUG_ARG 0x00000001
100 #define WINBIND_USE_AUTHTOK_ARG 0x00000002
101 #define WINBIND_UNKNOWN_OK_ARG 0x00000004
102 #define WINBIND_TRY_FIRST_PASS_ARG 0x00000008
103 #define WINBIND_USE_FIRST_PASS_ARG 0x00000010
104 #define WINBIND__OLD_PASSWORD 0x00000020
105 #define WINBIND_REQUIRED_MEMBERSHIP 0x00000040
106 #define WINBIND_KRB5_AUTH 0x00000080
107 #define WINBIND_KRB5_CCACHE_TYPE 0x00000100
108 #define WINBIND_CACHED_LOGIN 0x00000200
109 #define WINBIND_CONFIG_FILE 0x00000400
110 #define WINBIND_SILENT 0x00000800
111 #define WINBIND_DEBUG_STATE 0x00001000
112 #define WINBIND_WARN_PWD_EXPIRE 0x00002000
113 #define WINBIND_MKHOMEDIR 0x00004000
115 #if defined(HAVE_GETTEXT) && !defined(__LCLINT__)
116 #define _(string) dgettext(MODULE_NAME, string)
117 #else
118 #define _(string) string
119 #endif
121 #define N_(string) string
124 * here is the string to inform the user that the new passwords they
125 * typed were not the same.
128 #define MISTYPED_PASS _("Sorry, passwords do not match")
130 #define on(x, y) (x & y)
131 #define off(x, y) (!(x & y))
133 #define PAM_WINBIND_NEW_AUTHTOK_REQD "PAM_WINBIND_NEW_AUTHTOK_REQD"
134 #define PAM_WINBIND_NEW_AUTHTOK_REQD_DURING_AUTH "PAM_WINBIND_NEW_AUTHTOK_REQD_DURING_AUTH"
135 #define PAM_WINBIND_HOMEDIR "PAM_WINBIND_HOMEDIR"
136 #define PAM_WINBIND_LOGONSCRIPT "PAM_WINBIND_LOGONSCRIPT"
137 #define PAM_WINBIND_LOGONSERVER "PAM_WINBIND_LOGONSERVER"
138 #define PAM_WINBIND_PROFILEPATH "PAM_WINBIND_PROFILEPATH"
139 #define PAM_WINBIND_PWD_LAST_SET "PAM_WINBIND_PWD_LAST_SET"
141 #define SECONDS_PER_DAY 86400
143 #define DEFAULT_DAYS_TO_WARN_BEFORE_PWD_EXPIRES 14
145 #include "winbind_client.h"
147 #define PAM_WB_REMARK_DIRECT(c,x)\
149 const char *error_string = NULL; \
150 error_string = _get_ntstatus_error_string(x);\
151 if (error_string != NULL) {\
152 _make_remark(c, PAM_ERROR_MSG, error_string);\
153 } else {\
154 _make_remark(c, PAM_ERROR_MSG, x);\
158 #define LOGON_KRB5_FAIL_CLOCK_SKEW 0x02000000
160 #define PAM_WB_CACHED_LOGON(x) (x & WBC_AUTH_USER_INFO_CACHED_ACCOUNT)
161 #define PAM_WB_KRB5_CLOCK_SKEW(x) (x & LOGON_KRB5_FAIL_CLOCK_SKEW)
162 #define PAM_WB_GRACE_LOGON(x) ((WBC_AUTH_USER_INFO_CACHED_ACCOUNT|WBC_AUTH_USER_INFO_GRACE_LOGON) == ( x & (WBC_AUTH_USER_INFO_CACHED_ACCOUNT|WBC_AUTH_USER_INFO_GRACE_LOGON)))
164 struct pwb_context {
165 pam_handle_t *pamh;
166 int flags;
167 int argc;
168 const char **argv;
169 dictionary *dict;
170 uint32_t ctrl;
173 #ifndef TALLOC_FREE
174 #define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0)
175 #endif
176 #define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
177 #define TALLOC_P(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type)