r19158: Remove root and nobody users from ldif, from Björn Jacke
[Samba/nascimento.git] / source3 / nsswitch / pam_winbind.h
blob0ca30c28aae3e8529ecf0a4074dd279e9a4a6ac5
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"
11 #define MODULE_NAME "pam_winbind"
12 #define PAM_SM_AUTH
13 #define PAM_SM_ACCOUNT
14 #define PAM_SM_PASSWORD
16 #ifndef PAM_WINBIND_CONFIG_FILE
17 #define PAM_WINBIND_CONFIG_FILE "/etc/security/pam_winbind.conf"
18 #endif
20 #include <iniparser.h>
22 #ifndef LINUX
24 /* Solaris always uses dynamic pam modules */
25 #define PAM_EXTERN extern
26 #include <security/pam_appl.h>
28 #ifndef PAM_AUTHTOK_RECOVER_ERR
29 #define PAM_AUTHTOK_RECOVER_ERR PAM_AUTHTOK_RECOVERY_ERR
30 #endif
32 #endif /* defined(SUNOS5) || defined(SUNOS4) || defined(HPUX) || defined(FREEBSD) || defined(AIX) */
34 #ifdef HAVE_SECURITY_PAM_MODULES_H
35 #include <security/pam_modules.h>
36 #endif
38 #ifdef HAVE_SECURITY__PAM_MACROS_H
39 #include <security/_pam_macros.h>
40 #else
41 /* Define required macros from (Linux PAM 0.68) security/_pam_macros.h */
42 #define _pam_drop_reply(/* struct pam_response * */ reply, /* int */ replies) \
43 do { \
44 int reply_i; \
46 for (reply_i=0; reply_i<replies; ++reply_i) { \
47 if (reply[reply_i].resp) { \
48 _pam_overwrite(reply[reply_i].resp); \
49 free(reply[reply_i].resp); \
50 } \
51 } \
52 if (reply) \
53 free(reply); \
54 } while (0)
56 #define _pam_overwrite(x) \
57 do { \
58 register char *__xx__; \
59 if ((__xx__=(x))) \
60 while (*__xx__) \
61 *__xx__++ = '\0'; \
62 } while (0)
65 * Don't just free it, forget it too.
68 #define _pam_drop(X) SAFE_FREE(X)
70 #define x_strdup(s) ( (s) ? strdup(s):NULL )
71 #endif /* HAVE_SECURITY__PAM_MACROS_H */
73 #ifdef HAVE_SECURITY_PAM_EXT_H
74 #include <security/pam_ext.h>
75 #endif
77 #define WINBIND_DEBUG_ARG (1<<0)
78 #define WINBIND_USE_AUTHTOK_ARG (1<<1)
79 #define WINBIND_UNKNOWN_OK_ARG (1<<2)
80 #define WINBIND_TRY_FIRST_PASS_ARG (1<<3)
81 #define WINBIND_USE_FIRST_PASS_ARG (1<<4)
82 #define WINBIND__OLD_PASSWORD (1<<5)
83 #define WINBIND_REQUIRED_MEMBERSHIP (1<<6)
84 #define WINBIND_KRB5_AUTH (1<<7)
85 #define WINBIND_KRB5_CCACHE_TYPE (1<<8)
86 #define WINBIND_CACHED_LOGIN (1<<9)
87 #define WINBIND_CONFIG_FILE (1<<10)
88 #define WINBIND_SILENT (1<<11)
91 * here is the string to inform the user that the new passwords they
92 * typed were not the same.
95 #define MISTYPED_PASS "Sorry, passwords do not match"
97 #define on(x, y) (x & y)
98 #define off(x, y) (!(x & y))
100 #define PAM_WINBIND_NEW_AUTHTOK_REQD "PAM_WINBIND_NEW_AUTHTOK_REQD"
101 #define PAM_WINBIND_HOMEDIR "PAM_WINBIND_HOMEDIR"
102 #define PAM_WINBIND_LOGONSCRIPT "PAM_WINBIND_LOGONSCRIPT"
103 #define PAM_WINBIND_PWD_LAST_SET "PAM_WINBIND_PWD_LAST_SET"
105 #define SECONDS_PER_DAY 86400
107 #define DAYS_TO_WARN_BEFORE_PWD_EXPIRES 5
109 #include "winbind_client.h"
111 #define PAM_WB_REMARK_DIRECT(h,x)\
113 const char *error_string = NULL; \
114 error_string = _get_ntstatus_error_string(x);\
115 if (error_string != NULL) {\
116 _make_remark(h, PAM_ERROR_MSG, error_string);\
117 } else {\
118 _make_remark(h, PAM_ERROR_MSG, x);\
122 #define PAM_WB_REMARK_DIRECT_RET(h,x)\
124 const char *error_string = NULL; \
125 error_string = _get_ntstatus_error_string(x);\
126 if (error_string != NULL) {\
127 _make_remark(h, PAM_ERROR_MSG, error_string);\
128 return ret;\
130 _make_remark(h, PAM_ERROR_MSG, x);\
131 return ret;\
134 #define PAM_WB_REMARK_CHECK_RESPONSE_RET(h,x,y)\
136 const char *ntstatus = x.data.auth.nt_status_string; \
137 const char *error_string = NULL; \
138 if (!strcasecmp(ntstatus,y)) {\
139 error_string = _get_ntstatus_error_string(y);\
140 if (error_string != NULL) {\
141 _make_remark(h, PAM_ERROR_MSG, error_string);\
142 return ret;\
144 if (x.data.auth.error_string[0] != '\0') {\
145 _make_remark(h, PAM_ERROR_MSG, x.data.auth.error_string);\
146 return ret;\
148 _make_remark(h, PAM_ERROR_MSG, y);\
149 return ret;\
153 /* from include/rpc_samr.h */
154 #define DOMAIN_PASSWORD_COMPLEX 0x00000001
156 #define REJECT_REASON_OTHER 0x00000000
157 #define REJECT_REASON_TOO_SHORT 0x00000001
158 #define REJECT_REASON_IN_HISTORY 0x00000002
159 #define REJECT_REASON_NOT_COMPLEX 0x00000005
161 /* from include/smb.h */
162 #define ACB_PWNOEXP 0x00000200
164 /* from include/rpc_netlogon.h */
165 #define LOGON_CACHED_ACCOUNT 0x00000004