r12900: Merge from trunk:
[sfrench/samba-autobuild/.git] / source / nsswitch / pam_winbind.h
1 /* pam_winbind header file 
2    (Solaris needs some macros from Linux for common PAM code)
3
4    Shirish Kalele 2000
5 */
6
7 #ifdef HAVE_FEATURES_H
8 #include <features.h>
9 #endif
10
11 #include <stdlib.h>
12 #include <unistd.h>
13 #include <string.h>
14 #include <syslog.h>
15 #include <stdarg.h>
16 #include <sys/types.h>
17 #include <sys/stat.h>
18 #include <fcntl.h>
19 #include <errno.h>
20
21 #include <config.h>
22
23 #define MODULE_NAME "pam_winbind"
24 #define PAM_SM_AUTH
25 #define PAM_SM_ACCOUNT
26 #define PAM_SM_PASSWORD
27
28 #if defined(SUNOS5) || defined(SUNOS4) || defined(HPUX) || defined(FREEBSD)
29
30 /* Solaris always uses dynamic pam modules */
31 #define PAM_EXTERN extern
32 #include <security/pam_appl.h> 
33
34 #ifndef PAM_AUTHTOK_RECOVER_ERR
35 #define PAM_AUTHTOK_RECOVER_ERR PAM_AUTHTOK_RECOVERY_ERR
36 #endif
37
38 #endif
39
40 #ifdef HAVE_SECURITY_PAM_MODULES_H
41 #include <security/pam_modules.h>
42 #endif
43
44 #ifdef HAVE_SECURITY__PAM_MACROS_H
45 #include <security/_pam_macros.h>
46 #else
47 /* Define required macros from (Linux PAM 0.68) security/_pam_macros.h */
48 #define _pam_drop_reply(/* struct pam_response * */ reply, /* int */ replies) \
49 do {                                              \
50     int reply_i;                                  \
51                                                   \
52     for (reply_i=0; reply_i<replies; ++reply_i) { \
53         if (reply[reply_i].resp) {                \
54             _pam_overwrite(reply[reply_i].resp);  \
55             free(reply[reply_i].resp);            \
56         }                                         \
57     }                                             \
58     if (reply)                                    \
59         free(reply);                              \
60 } while (0)
61
62 #define _pam_overwrite(x)        \
63 do {                             \
64      register char *__xx__;      \
65      if ((__xx__=(x)))           \
66           while (*__xx__)        \
67                *__xx__++ = '\0'; \
68 } while (0)
69
70 /*
71  * Don't just free it, forget it too.
72  */
73
74 #define _pam_drop(X) SAFE_FREE(X)
75
76 #define  x_strdup(s)  ( (s) ? strdup(s):NULL )     
77 #endif
78
79 #define WINBIND_DEBUG_ARG (1<<0)
80 #define WINBIND_USE_AUTHTOK_ARG (1<<1)
81 #define WINBIND_UNKNOWN_OK_ARG (1<<2)
82 #define WINBIND_TRY_FIRST_PASS_ARG (1<<3)
83 #define WINBIND_USE_FIRST_PASS_ARG (1<<4)
84 #define WINBIND__OLD_PASSWORD (1<<5)
85 #define WINBIND_REQUIRED_MEMBERSHIP (1<<6)
86
87 #define PAM_WINBIND_NEW_AUTHTOK_REQD "PAM_WINBIND_NEW_AUTHTOK_REQD"
88
89 /*
90  * here is the string to inform the user that the new passwords they
91  * typed were not the same.
92  */
93
94 #define MISTYPED_PASS "Sorry, passwords do not match"
95
96 #define on(x, y) (x & y)
97 #define off(x, y) (!(x & y))
98
99 #include "winbind_client.h"