1 /* pam_winbind header file
2 (Solaris needs some macros from Linux for common PAM code)
17 #include <sys/types.h>
25 #define MODULE_NAME "pam_winbind"
27 #define PAM_SM_ACCOUNT
28 #define PAM_SM_PASSWORD
30 #ifndef PAM_WINBIND_CONFIG_FILE
31 #define PAM_WINBIND_CONFIG_FILE "/etc/security/pam_winbind.conf"
34 #include <iniparser.h>
36 #if defined(SUNOS5) || defined(SUNOS4) || defined(HPUX) || defined(FREEBSD) || defined(AIX)
38 /* Solaris always uses dynamic pam modules */
39 #define PAM_EXTERN extern
40 #include <security/pam_appl.h>
42 #ifndef PAM_AUTHTOK_RECOVER_ERR
43 #define PAM_AUTHTOK_RECOVER_ERR PAM_AUTHTOK_RECOVERY_ERR
48 #ifdef HAVE_SECURITY_PAM_MODULES_H
49 #include <security/pam_modules.h>
52 #ifdef HAVE_SECURITY__PAM_MACROS_H
53 #include <security/_pam_macros.h>
55 /* Define required macros from (Linux PAM 0.68) security/_pam_macros.h */
56 #define _pam_drop_reply(/* struct pam_response * */ reply, /* int */ replies) \
60 for (reply_i=0; reply_i<replies; ++reply_i) { \
61 if (reply[reply_i].resp) { \
62 _pam_overwrite(reply[reply_i].resp); \
63 free(reply[reply_i].resp); \
70 #define _pam_overwrite(x) \
72 register char *__xx__; \
79 * Don't just free it, forget it too.
82 #define _pam_drop(X) SAFE_FREE(X)
84 #define x_strdup(s) ( (s) ? strdup(s):NULL )
87 #define WINBIND_DEBUG_ARG (1<<0)
88 #define WINBIND_USE_AUTHTOK_ARG (1<<1)
89 #define WINBIND_UNKNOWN_OK_ARG (1<<2)
90 #define WINBIND_TRY_FIRST_PASS_ARG (1<<3)
91 #define WINBIND_USE_FIRST_PASS_ARG (1<<4)
92 #define WINBIND__OLD_PASSWORD (1<<5)
93 #define WINBIND_REQUIRED_MEMBERSHIP (1<<6)
94 #define WINBIND_KRB5_AUTH (1<<7)
95 #define WINBIND_KRB5_CCACHE_TYPE (1<<8)
96 #define WINBIND_CACHED_LOGIN (1<<9)
97 #define WINBIND_CONFIG_FILE (1<<10)
100 * here is the string to inform the user that the new passwords they
101 * typed were not the same.
104 #define MISTYPED_PASS "Sorry, passwords do not match"
106 #define on(x, y) (x & y)
107 #define off(x, y) (!(x & y))
109 #define PAM_WINBIND_NEW_AUTHTOK_REQD "PAM_WINBIND_NEW_AUTHTOK_REQD"
110 #define PAM_WINBIND_HOMEDIR "PAM_WINBIND_HOMEDIR"
111 #define PAM_WINBIND_LOGONSCRIPT "PAM_WINBIND_LOGONSCRIPT"
112 #define PAM_WINBIND_PWD_LAST_SET "PAM_WINBIND_PWD_LAST_SET"
114 #define SECONDS_PER_DAY 86400
116 #define DAYS_TO_WARN_BEFORE_PWD_EXPIRES 5
118 #include "winbind_client.h"
120 #define PAM_WB_REMARK_DIRECT(h,x)\
122 const char *error_string = NULL; \
123 error_string = _get_ntstatus_error_string(x);\
124 if (error_string != NULL) {\
125 _make_remark(h, PAM_ERROR_MSG, error_string);\
127 _make_remark(h, PAM_ERROR_MSG, x);\
131 #define PAM_WB_REMARK_DIRECT_RET(h,x)\
133 const char *error_string = NULL; \
134 error_string = _get_ntstatus_error_string(x);\
135 if (error_string != NULL) {\
136 _make_remark(h, PAM_ERROR_MSG, error_string);\
139 _make_remark(h, PAM_ERROR_MSG, x);\
143 #define PAM_WB_REMARK_CHECK_RESPONSE_RET(h,x,y)\
145 const char *ntstatus = x.data.auth.nt_status_string; \
146 const char *error_string = NULL; \
147 if (!strcasecmp(ntstatus,y)) {\
148 error_string = _get_ntstatus_error_string(y);\
149 if (error_string != NULL) {\
150 _make_remark(h, PAM_ERROR_MSG, error_string);\
153 if (x.data.auth.error_string[0] != '\0') {\
154 _make_remark(h, PAM_ERROR_MSG, x.data.auth.error_string);\
157 _make_remark(h, PAM_ERROR_MSG, y);\
162 /* from include/rpc_samr.h */
163 #define DOMAIN_PASSWORD_COMPLEX 0x00000001
165 #define REJECT_REASON_OTHER 0x00000000
166 #define REJECT_REASON_TOO_SHORT 0x00000001
167 #define REJECT_REASON_IN_HISTORY 0x00000002
168 #define REJECT_REASON_NOT_COMPLEX 0x00000005
170 /* from include/smb.h */
171 #define ACB_PWNOEXP 0x00000200
173 /* from include/rpc_netlogon.h */
174 #define LOGON_CACHED_ACCOUNT 0x00000004