diff options
Diffstat (limited to 'ctdb/lib/replace/system')
-rw-r--r-- | ctdb/lib/replace/system/capability.h | 13 | ||||
-rw-r--r-- | ctdb/lib/replace/system/config.m4 | 72 | ||||
-rw-r--r-- | ctdb/lib/replace/system/network.h | 210 | ||||
-rw-r--r-- | ctdb/lib/replace/system/passwd.h | 13 | ||||
-rw-r--r-- | ctdb/lib/replace/system/time.h | 10 | ||||
-rw-r--r-- | ctdb/lib/replace/system/wait.h | 4 |
6 files changed, 305 insertions, 17 deletions
diff --git a/ctdb/lib/replace/system/capability.h b/ctdb/lib/replace/system/capability.h index 4fe7c8d51b..a7b78f0275 100644 --- a/ctdb/lib/replace/system/capability.h +++ b/ctdb/lib/replace/system/capability.h @@ -27,14 +27,25 @@ #ifdef HAVE_SYS_CAPABILITY_H -#if defined(BROKEN_REDHAT_7_SYSTEM_HEADERS) && !defined(_I386_STATFS_H) +#if defined(BROKEN_REDHAT_7_SYSTEM_HEADERS) && !defined(_I386_STATFS_H) && !defined(_PPC_STATFS_H) #define _I386_STATFS_H +#define _PPC_STATFS_H #define BROKEN_REDHAT_7_STATFS_WORKAROUND #endif +#if defined(BROKEN_RHEL5_SYS_CAP_HEADER) && !defined(_LINUX_TYPES_H) +#define BROKEN_RHEL5_SYS_CAP_HEADER_WORKAROUND +#endif + #include <sys/capability.h> +#ifdef BROKEN_RHEL5_SYS_CAP_HEADER_WORKAROUND +#undef _LINUX_TYPES_H +#undef BROKEN_RHEL5_SYS_CAP_HEADER_WORKAROUND +#endif + #ifdef BROKEN_REDHAT_7_STATFS_WORKAROUND +#undef _PPC_STATFS_H #undef _I386_STATFS_H #undef BROKEN_REDHAT_7_STATFS_WORKAROUND #endif diff --git a/ctdb/lib/replace/system/config.m4 b/ctdb/lib/replace/system/config.m4 index 74278787e7..799187af7d 100644 --- a/ctdb/lib/replace/system/config.m4 +++ b/ctdb/lib/replace/system/config.m4 @@ -16,8 +16,80 @@ AC_HEADER_SYS_WAIT # capability AC_CHECK_HEADERS(sys/capability.h) +case "$host_os" in +*linux*) +AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[ +AC_TRY_COMPILE([ + #ifdef HAVE_SYS_VFS_H + #include <sys/vfs.h> + #endif + #ifdef HAVE_SYS_CAPABILITY_H + #include <sys/capability.h> + #endif + ],[ + int i; + ], + samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no, + samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes +)]) +if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then + AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files]) +fi + +AC_CACHE_CHECK([for broken RHEL5 sys/capability.h],samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER,[ +AC_TRY_COMPILE([ + #ifdef HAVE_SYS_CAPABILITY_H + #include <sys/capability.h> + #endif + #include <linux/types.h> + ],[ + __s8 i; + ], + samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER=no, + samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER=yes +)]) +if test x"$samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER" = x"yes"; then + AC_DEFINE(BROKEN_RHEL5_SYS_CAP_HEADER,1,[Broken RHEL5 sys/capability.h]) +fi +;; +esac + # passwd AC_CHECK_HEADERS(grp.h sys/id.h compat.h shadow.h sys/priv.h pwd.h sys/security.h) +AC_CHECK_FUNCS(getpwnam_r getpwuid_r getpwent_r) +AC_HAVE_DECL(getpwent_r, [ + #include <unistd.h> + #include <pwd.h> + ]) +AC_VERIFY_C_PROTOTYPE([struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)], + [ + #ifndef HAVE_GETPWENT_R_DECL + #error missing getpwent_r prototype + #endif + return NULL; + ],[ + AC_DEFINE(SOLARIS_GETPWENT_R, 1, [getpwent_r solaris function prototype]) + ],[],[ + #include <unistd.h> + #include <pwd.h> + ]) +AC_CHECK_FUNCS(getgrnam_r getgrgid_r getgrent_r) +AC_HAVE_DECL(getgrent_r, [ + #include <unistd.h> + #include <grp.h> + ]) +AC_VERIFY_C_PROTOTYPE([struct group *getgrent_r(struct group *src, char *buf, int buflen)], + [ + #ifndef HAVE_GETGRENT_R_DECL + #error missing getgrent_r prototype + #endif + return NULL; + ],[ + AC_DEFINE(SOLARIS_GETGRENT_R, 1, [getgrent_r solaris function prototype]) + ],[],[ + #include <unistd.h> + #include <grp.h> + ]) # locale AC_CHECK_HEADERS(ctype.h locale.h) diff --git a/ctdb/lib/replace/system/network.h b/ctdb/lib/replace/system/network.h index 13d95a8ba7..e2fad5f686 100644 --- a/ctdb/lib/replace/system/network.h +++ b/ctdb/lib/replace/system/network.h @@ -6,6 +6,7 @@ networking system include wrappers Copyright (C) Andrew Tridgell 2004 + Copyright (C) Jelmer Vernooij 2007 ** NOTE! The following LGPL license applies to the replace ** library. This does NOT imply that all of Samba is released @@ -78,32 +79,135 @@ #include <sys/ioctl.h> #endif -#ifdef SOCKET_WRAPPER -#ifndef SOCKET_WRAPPER_NOT_REPLACE -#define SOCKET_WRAPPER_REPLACE +#ifdef REPLACE_INET_NTOA +/* define is in "replace.h" */ +char *rep_inet_ntoa(struct in_addr ip); #endif -#include "lib/socket_wrapper/socket_wrapper.h" + +#ifndef HAVE_INET_PTON +/* define is in "replace.h" */ +int rep_inet_pton(int af, const char *src, void *dst); #endif -#ifdef REPLACE_INET_NTOA -char *rep_inet_ntoa(struct in_addr ip); -#define inet_ntoa rep_inet_ntoa +#ifndef HAVE_INET_NTOP +/* define is in "replace.h" */ +const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size); +#endif + +#ifdef HAVE_IFADDRS_H +#include <ifaddrs.h> +#endif + +#ifndef HAVE_STRUCT_IFADDRS +struct ifaddrs { + struct ifaddrs *ifa_next; /* Pointer to next struct */ + char *ifa_name; /* Interface name */ + unsigned int ifa_flags; /* Interface flags */ + struct sockaddr *ifa_addr; /* Interface address */ + struct sockaddr *ifa_netmask; /* Interface netmask */ +#undef ifa_dstaddr + struct sockaddr *ifa_dstaddr; /* P2P interface destination */ + void *ifa_data; /* Address specific data */ +}; +#endif + +#ifndef HAVE_GETIFADDRS +int rep_getifaddrs(struct ifaddrs **); +#endif + +#ifndef HAVE_FREEIFADDRS +void rep_freeifaddrs(struct ifaddrs *); #endif /* - * glibc on linux doesn't seem to have MSG_WAITALL - * defined. I think the kernel has it though.. + * Some systems have getaddrinfo but not the + * defines needed to use it. */ -#ifndef MSG_WAITALL -#define MSG_WAITALL 0 + +/* Various macros that ought to be in <netdb.h>, but might not be */ + +#ifndef EAI_FAIL +#define EAI_BADFLAGS (-1) +#define EAI_NONAME (-2) +#define EAI_AGAIN (-3) +#define EAI_FAIL (-4) +#define EAI_FAMILY (-6) +#define EAI_SOCKTYPE (-7) +#define EAI_SERVICE (-8) +#define EAI_MEMORY (-10) +#define EAI_SYSTEM (-11) +#endif /* !EAI_FAIL */ + +#ifndef AI_PASSIVE +#define AI_PASSIVE 0x0001 +#endif + +#ifndef AI_CANONNAME +#define AI_CANONNAME 0x0002 +#endif + +#ifndef AI_NUMERICHOST +/* + * some platforms don't support AI_NUMERICHOST; define as zero if using + * the system version of getaddrinfo... + */ +#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO) +#define AI_NUMERICHOST 0 +#else +#define AI_NUMERICHOST 0x0004 +#endif +#endif + +#ifndef AI_ADDRCONFIG +#define AI_ADDRCONFIG 0x0020 #endif +#ifndef AI_NUMERICSERV /* - * Some older systems seem not to have MAXHOSTNAMELEN - * defined. + * logic copied from AI_NUMERICHOST */ -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 254 +#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO) +#define AI_NUMERICSERV 0 +#else +#define AI_NUMERICSERV 0x0400 +#endif +#endif + +#ifndef NI_NUMERICHOST +#define NI_NUMERICHOST 1 +#endif + +#ifndef NI_NUMERICSERV +#define NI_NUMERICSERV 2 +#endif + +#ifndef NI_NOFQDN +#define NI_NOFQDN 4 +#endif + +#ifndef NI_NAMEREQD +#define NI_NAMEREQD 8 +#endif + +#ifndef NI_DGRAM +#define NI_DGRAM 16 +#endif + + +#ifndef NI_MAXHOST +#define NI_MAXHOST 1025 +#endif + +#ifndef NI_MAXSERV +#define NI_MAXSERV 32 +#endif + +/* + * glibc on linux doesn't seem to have MSG_WAITALL + * defined. I think the kernel has it though.. + */ +#ifndef MSG_WAITALL +#define MSG_WAITALL 0 #endif #ifndef INADDR_LOOPBACK @@ -114,4 +218,80 @@ char *rep_inet_ntoa(struct in_addr ip); #define INADDR_NONE 0xffffffff #endif +#ifndef EAFNOSUPPORT +#define EAFNOSUPPORT EINVAL +#endif + +#ifndef INET_ADDRSTRLEN +#define INET_ADDRSTRLEN 16 +#endif + +#ifndef INET6_ADDRSTRLEN +#define INET6_ADDRSTRLEN 46 +#endif + +#ifndef HOST_NAME_MAX +#define HOST_NAME_MAX 256 +#endif + +#ifndef HAVE_SOCKLEN_T +#define HAVE_SOCKLEN_T +typedef int socklen_t; +#endif + +#ifndef HAVE_SA_FAMILY_T +#define HAVE_SA_FAMILY_T +typedef unsigned short int sa_family_t; +#endif + +#ifndef HAVE_STRUCT_SOCKADDR_STORAGE +#define HAVE_STRUCT_SOCKADDR_STORAGE +#ifdef HAVE_STRUCT_SOCKADDR_IN6 +#define sockaddr_storage sockaddr_in6 +#define ss_family sin6_family +#define HAVE_SS_FAMILY 1 +#else +#define sockaddr_storage sockaddr_in +#define ss_family sin_family +#define HAVE_SS_FAMILY 1 +#endif +#endif + +#ifndef HAVE_SS_FAMILY +#ifdef HAVE___SS_FAMILY +#define ss_family __ss_family +#define HAVE_SS_FAMILY 1 +#endif +#endif + +#ifndef HAVE_STRUCT_ADDRINFO +#define HAVE_STRUCT_ADDRINFO +struct addrinfo { + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + socklen_t ai_addrlen; + struct sockaddr *ai_addr; + char *ai_canonname; + struct addrinfo *ai_next; +}; +#endif /* HAVE_STRUCT_ADDRINFO */ + +#if !defined(HAVE_GETADDRINFO) +#include "getaddrinfo.h" +#endif + +/* Needed for some systems that don't define it (Solaris). */ +#ifndef ifr_netmask +#define ifr_netmask ifr_addrs +#endif + +#ifdef SOCKET_WRAPPER +#ifndef SOCKET_WRAPPER_NOT_REPLACE +#define SOCKET_WRAPPER_REPLACE +#endif +#include "lib/socket_wrapper/socket_wrapper.h" +#endif + #endif diff --git a/ctdb/lib/replace/system/passwd.h b/ctdb/lib/replace/system/passwd.h index 4e858fc89c..36fca7b4f8 100644 --- a/ctdb/lib/replace/system/passwd.h +++ b/ctdb/lib/replace/system/passwd.h @@ -27,6 +27,9 @@ */ +/* this needs to be included before nss_wrapper.h on some systems */ +#include <unistd.h> + #ifdef HAVE_PWD_H #include <pwd.h> #endif @@ -65,7 +68,8 @@ #endif #ifdef REPLACE_GETPASS -#define getpass(prompt) getsmbpass((prompt)) +#define getpass(prompt) rep_getpass(prompt) +char *rep_getpass(const char *prompt); #endif #ifndef NGROUPS_MAX @@ -92,4 +96,11 @@ #define ULTRIX_AUTH 1 #endif +#ifdef NSS_WRAPPER +#ifndef NSS_WRAPPER_NOT_REPLACE +#define NSS_WRAPPER_REPLACE +#endif +#include "lib/nss_wrapper/nss_wrapper.h" +#endif + #endif diff --git a/ctdb/lib/replace/system/time.h b/ctdb/lib/replace/system/time.h index 6bbb6b15bb..036812ab8f 100644 --- a/ctdb/lib/replace/system/time.h +++ b/ctdb/lib/replace/system/time.h @@ -41,4 +41,14 @@ #include <utime.h> #endif +#ifndef HAVE_MKTIME +/* define is in "replace.h" */ +time_t rep_mktime(struct tm *t); +#endif + +#ifndef HAVE_TIMEGM +/* define is in "replace.h" */ +time_t rep_timegm(struct tm *tm); +#endif + #endif diff --git a/ctdb/lib/replace/system/wait.h b/ctdb/lib/replace/system/wait.h index de94cf09d5..5784b1ae92 100644 --- a/ctdb/lib/replace/system/wait.h +++ b/ctdb/lib/replace/system/wait.h @@ -48,4 +48,8 @@ #define SA_RESETHAND SA_ONESHOT #endif +#if !defined(HAVE_SIG_ATOMIC_T_TYPE) +typedef int sig_atomic_t; +#endif + #endif |