move to SAFE_FREE()
[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)
29
30 /* Solaris always uses dynamic pam modules */
31 #define PAM_EXTERN extern
32 #include <security/pam_appl.h> 
33
34 #define PAM_AUTHTOK_RECOVER_ERR PAM_AUTHTOK_RECOVERY_ERR
35 #endif
36
37 #ifdef HAVE_SECURITY_PAM_MODULES_H
38 #include <security/pam_modules.h>
39 #endif
40
41 #ifdef HAVE_SECURITY__PAM_MACROS_H
42 #include <security/_pam_macros.h>
43 #else
44 /* Define required macros from (Linux PAM 0.68) security/_pam_macros.h */
45 #define _pam_drop_reply(/* struct pam_response * */ reply, /* int */ replies) \
46 do {                                              \
47     int reply_i;                                  \
48                                                   \
49     for (reply_i=0; reply_i<replies; ++reply_i) { \
50         if (reply[reply_i].resp) {                \
51             _pam_overwrite(reply[reply_i].resp);  \
52             free(reply[reply_i].resp);            \
53         }                                         \
54     }                                             \
55     if (reply)                                    \
56         free(reply);                              \
57 } while (0)
58
59 #define _pam_overwrite(x)        \
60 do {                             \
61      register char *__xx__;      \
62      if ((__xx__=(x)))           \
63           while (*__xx__)        \
64                *__xx__++ = '\0'; \
65 } while (0)
66
67 /*
68  * Don't just free it, forget it too.
69  */
70
71 #define _pam_drop(X) SAFE_FREE(X)
72
73 #define  x_strdup(s)  ( (s) ? strdup(s):NULL )     
74 #endif
75
76 #define PAM_DEBUG_ARG (1<<0)
77 #define PAM_USE_AUTHTOK_ARG (1<<1)
78 #define PAM_UNKNOWN_OK_ARG (1<<2)
79
80 #include "winbind_nss_config.h"
81 #include "winbindd_nss.h"