From f799a2e4ba666158b0ecb269f26e4624e4425ddf Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Sat, 13 Aug 2005 02:17:12 +0000 Subject: [PATCH] replace struct msghdr macros --- build/openldap.m4 | 26 +---- configure | 166 +++++++++++++++++++++++++++----- configure.in | 16 ++- include/portable.hin | 12 +-- libraries/libldap/os-local.c | 12 +-- libraries/liblutil/getpeereid.c | 14 +-- 6 files changed, 172 insertions(+), 74 deletions(-) diff --git a/build/openldap.m4 b/build/openldap.m4 index f549252fd6..e626112774 100644 --- a/build/openldap.m4 +++ b/build/openldap.m4 @@ -1261,31 +1261,7 @@ AC_DEFUN([OL_SASL_COMPAT], ], [ol_cv_sasl_compat=yes], [ol_cv_sasl_compat=no])]) ]) dnl ==================================================================== -dnl check for msg_accrights in msghdr -AC_DEFUN([OL_MSGHDR_MSG_ACCRIGHTS], - [AC_CACHE_CHECK(for msg_accrights in msghdr, ol_cv_msghdr_msg_accrights, - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[struct msghdr m; m.msg_accrightslen=0]])], - [ol_cv_msghdr_msg_accrights=yes], - [ol_cv_msghdr_msg_accrights=no])]) - if test $ol_cv_msghdr_msg_accrights = "yes" ; then - AC_DEFINE(HAVE_MSGHDR_MSG_ACCRIGHTS,1, - [define if struct msghdr has msg_accrights]) - fi -])dnl -dnl ==================================================================== -dnl check for cmsghdr -AC_DEFUN([OL_MSGHDR_MSG_CONTROL], - [AC_CACHE_CHECK(for msg_control in msghdr, ol_cv_msghdr_msg_control, - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[struct msghdr m; m.msg_control=(struct cmsghdr *)0]])], - [ol_cv_msghdr_msg_control=yes], - [ol_cv_msghdr_msg_control=no])]) - if test $ol_cv_msghdr_msg_control = "yes" ; then - AC_DEFINE(HAVE_MSGHDR_MSG_CONTROL,1, - [define if struct msghdr has msg_control]) - fi -])dnl +dnl check for SSL compatibility AC_DEFUN([OL_SSL_COMPAT], [AC_CACHE_CHECK([OpenSSL library version (CRL checking capability)], [ol_cv_ssl_crl_compat],[ AC_EGREP_CPP(__ssl_compat,[ diff --git a/configure b/configure index d450a8f01b..ce39d73842 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in OpenLDAP: pkg/ldap/configure.in. +# From configure.in OpenLDAP: pkg/ldap/configure.in,v 1.586.2.15 2005/08/12 22:48:41 kurt Exp . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59. # @@ -51671,9 +51671,9 @@ if test "$ac_cv_func_getopt" != yes; then LIBSRCS="$LIBSRCS getopt.c" fi if test "$ac_cv_func_getpeereid" != yes; then - echo "$as_me:$LINENO: checking for msg_accrights in msghdr" >&5 -echo $ECHO_N "checking for msg_accrights in msghdr... $ECHO_C" >&6 -if test "${ol_cv_msghdr_msg_accrights+set}" = set; then + echo "$as_me:$LINENO: checking for struct msghdr.msg_accrightslen" >&5 +echo $ECHO_N "checking for struct msghdr.msg_accrightslen... $ECHO_C" >&6 +if test "${ac_cv_member_struct_msghdr_msg_accrightslen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -51682,11 +51682,17 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ +$ac_includes_default +#ifdef HAVE_SYS_SOCKET_H #include +#endif + int main () { -struct msghdr m; m.msg_accrightslen=0 +static struct msghdr ac_aggr; +if (ac_aggr.msg_accrightslen) +return 0; ; return 0; } @@ -51713,29 +51719,80 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ol_cv_msghdr_msg_accrights=yes + ac_cv_member_struct_msghdr_msg_accrightslen=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ol_cv_msghdr_msg_accrights=no +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + +int +main () +{ +static struct msghdr ac_aggr; +if (sizeof ac_aggr.msg_accrightslen) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_msghdr_msg_accrightslen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_member_struct_msghdr_msg_accrightslen=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ol_cv_msghdr_msg_accrights" >&5 -echo "${ECHO_T}$ol_cv_msghdr_msg_accrights" >&6 - if test $ol_cv_msghdr_msg_accrights = "yes" ; then +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_member_struct_msghdr_msg_accrightslen" >&5 +echo "${ECHO_T}$ac_cv_member_struct_msghdr_msg_accrightslen" >&6 +if test $ac_cv_member_struct_msghdr_msg_accrightslen = yes; then -cat >>confdefs.h <<\_ACEOF -#define HAVE_MSGHDR_MSG_ACCRIGHTS 1 +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTSLEN 1 _ACEOF - fi - if test "$ac_cv_func_getpeereid" != yes; then - echo "$as_me:$LINENO: checking for msg_control in msghdr" >&5 -echo $ECHO_N "checking for msg_control in msghdr... $ECHO_C" >&6 -if test "${ol_cv_msghdr_msg_control+set}" = set; then +fi + + if test "$ac_cv_member_struct_msghdr_msg_accrightslen" != yes; then + echo "$as_me:$LINENO: checking for struct msghdr.msg_control" >&5 +echo $ECHO_N "checking for struct msghdr.msg_control... $ECHO_C" >&6 +if test "${ac_cv_member_struct_msghdr_msg_control+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -51744,11 +51801,17 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ +$ac_includes_default +#ifdef HAVE_SYS_SOCKET_H #include +#endif + int main () { -struct msghdr m; m.msg_control=(struct cmsghdr *)0 +static struct msghdr ac_aggr; +if (ac_aggr.msg_control) +return 0; ; return 0; } @@ -51775,24 +51838,75 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ol_cv_msghdr_msg_control=yes + ac_cv_member_struct_msghdr_msg_control=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ol_cv_msghdr_msg_control=no +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + +int +main () +{ +static struct msghdr ac_aggr; +if (sizeof ac_aggr.msg_control) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_msghdr_msg_control=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_member_struct_msghdr_msg_control=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ol_cv_msghdr_msg_control" >&5 -echo "${ECHO_T}$ol_cv_msghdr_msg_control" >&6 - if test $ol_cv_msghdr_msg_control = "yes" ; then +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_member_struct_msghdr_msg_control" >&5 +echo "${ECHO_T}$ac_cv_member_struct_msghdr_msg_control" >&6 +if test $ac_cv_member_struct_msghdr_msg_control = yes; then -cat >>confdefs.h <<\_ACEOF -#define HAVE_MSGHDR_MSG_CONTROL 1 +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_MSGHDR_MSG_CONTROL 1 _ACEOF - fi + +fi fi LIBSRCS="$LIBSRCS getpeereid.c" diff --git a/configure.in b/configure.in index 4aee019972..dd12b097a1 100644 --- a/configure.in +++ b/configure.in @@ -20,7 +20,7 @@ dnl ================================================================ dnl Configure.in for OpenLDAP AC_COPYRIGHT([[Copyright 1998-2005 The OpenLDAP Foundation. All rights reserved. Restrictions apply, see COPYRIGHT and LICENSE files.]]) -AC_REVISION($OpenLDAP$) +AC_REVISION([$OpenLDAP$]) AC_INIT([OpenLDAP],,[http://www.openldap.org/its/]) AC_CONFIG_SRCDIR(build/version.sh)dnl dnl ---------------------------------------------------------------- @@ -2536,9 +2536,17 @@ if test "$ac_cv_func_getopt" != yes; then LIBSRCS="$LIBSRCS getopt.c" fi if test "$ac_cv_func_getpeereid" != yes; then - OL_MSGHDR_MSG_ACCRIGHTS - if test "$ac_cv_func_getpeereid" != yes; then - OL_MSGHDR_MSG_CONTROL + AC_CHECK_MEMBERS([struct msghdr.msg_accrightslen],,, + [$ac_includes_default +#ifdef HAVE_SYS_SOCKET_H +#include +#endif]) + if test "$ac_cv_member_struct_msghdr_msg_accrightslen" != yes; then + AC_CHECK_MEMBERS([struct msghdr.msg_control],,, + [$ac_includes_default +#ifdef HAVE_SYS_SOCKET_H +#include +#endif]) fi LIBSRCS="$LIBSRCS getpeereid.c" fi diff --git a/include/portable.hin b/include/portable.hin index ffd76b92b0..0d08b5fb8a 100644 --- a/include/portable.hin +++ b/include/portable.hin @@ -403,12 +403,6 @@ /* define this if you have mkversion */ #undef HAVE_MKVERSION -/* define if struct msghdr has msg_accrights */ -#undef HAVE_MSGHDR_MSG_ACCRIGHTS - -/* define if struct msghdr has msg_control */ -#undef HAVE_MSGHDR_MSG_CONTROL - /* define if NDBM is available */ #undef HAVE_NDBM @@ -658,6 +652,12 @@ /* Define to 1 if you have the `strtouq' function. */ #undef HAVE_STRTOUQ +/* Define to 1 if `msg_accrightslen' is member of `struct msghdr'. */ +#undef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTSLEN + +/* Define to 1 if `msg_control' is member of `struct msghdr'. */ +#undef HAVE_STRUCT_MSGHDR_MSG_CONTROL + /* Define to 1 if `pw_gecos' is member of `struct passwd'. */ #undef HAVE_STRUCT_PASSWD_PW_GECOS diff --git a/libraries/libldap/os-local.c b/libraries/libldap/os-local.c index a3d4a019d9..5c46e5c612 100644 --- a/libraries/libldap/os-local.c +++ b/libraries/libldap/os-local.c @@ -156,8 +156,8 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s) #if !defined(HAVE_GETPEEREID) && \ !defined(SO_PEERCRED) && !defined(LOCAL_PEERCRED) && \ - defined(HAVE_SENDMSG) && (defined(HAVE_MSGHDR_MSG_ACCRIGHTS) || \ - defined(HAVE_MSGHDR_MSG_CONTROL)) + defined(HAVE_SENDMSG) && (defined(HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS) || \ + defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)) #define DO_SENDMSG static const char abandonPDU[] = {LDAP_TAG_MESSAGE, 6, LDAP_TAG_MSGID, 1, 0, LDAP_REQ_ABANDON, 1, 0}; @@ -195,7 +195,7 @@ sendcred: /* Abandon, noop, has no reply */ struct iovec iov; struct msghdr msg = {0}; -# ifdef HAVE_MSGHDR_MSG_CONTROL +# ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL # ifndef CMSG_SPACE # define CMSG_SPACE(len) (_CMSG_ALIGN( sizeof(struct cmsghdr)) + _CMSG_ALIGN(len) ) # endif @@ -207,14 +207,14 @@ sendcred: unsigned char control[CMSG_SPACE(sizeof(int))]; } control_un; struct cmsghdr *cmsg; -# endif /* HAVE_MSGHDR_MSG_CONTROL */ +# endif /* HAVE_STRUCT_MSGHDR_MSG_CONTROL */ msg.msg_name = NULL; msg.msg_namelen = 0; iov.iov_base = (char *) abandonPDU; iov.iov_len = sizeof abandonPDU; msg.msg_iov = &iov; msg.msg_iovlen = 1; -# ifdef HAVE_MSGHDR_MSG_CONTROL +# ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL msg.msg_control = control_un.control; msg.msg_controllen = sizeof( control_un.control ); msg.msg_flags = 0; @@ -228,7 +228,7 @@ sendcred: # else msg.msg_accrights = (char *)fds; msg.msg_accrightslen = sizeof(int); -# endif /* HAVE_MSGHDR_MSG_CONTROL */ +# endif /* HAVE_STRUCT_MSGHDR_MSG_CONTROL */ sendmsg( s, &msg, 0 ); close(fds[0]); close(fds[1]); diff --git a/libraries/liblutil/getpeereid.c b/libraries/liblutil/getpeereid.c index ce8c232aa8..e34ae53032 100644 --- a/libraries/liblutil/getpeereid.c +++ b/libraries/liblutil/getpeereid.c @@ -32,8 +32,8 @@ #endif #if !defined(SO_PEERCRED) && !defined(LOCAL_PEERCRED) && \ - defined(HAVE_SENDMSG) && (defined(HAVE_MSGHDR_MSG_ACCRIGHTS) || \ - defined(HAVE_MSGHDR_MSG_CONTROL)) + defined(HAVE_SENDMSG) && (defined(HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS) || \ + defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)) #define DO_SENDMSG #ifdef HAVE_SYS_UIO_H #include @@ -77,7 +77,7 @@ int getpeereid( int s, uid_t *euid, gid_t *egid ) int err, fd[2]; struct iovec iov; struct msghdr msg = {0}; -# ifdef HAVE_MSGHDR_MSG_CONTROL +# ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL # ifndef CMSG_SPACE # define CMSG_SPACE(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + _CMSG_ALIGN(len)) # endif @@ -89,7 +89,7 @@ int getpeereid( int s, uid_t *euid, gid_t *egid ) unsigned char control[CMSG_SPACE(sizeof(int))]; } control_un; struct cmsghdr *cmsg; -# endif /* HAVE_MSGHDR_MSG_CONTROL */ +# endif /* HAVE_STRUCT_MSGHDR_MSG_CONTROL */ struct stat st; msg.msg_name = NULL; @@ -99,7 +99,7 @@ int getpeereid( int s, uid_t *euid, gid_t *egid ) iov.iov_len = sizeof dummy; msg.msg_iov = &iov; msg.msg_iovlen = 1; -# ifdef HAVE_MSGHDR_MSG_CONTROL +# ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL msg.msg_control = control_un.control; msg.msg_controllen = sizeof( control_un.control ); @@ -118,12 +118,12 @@ int getpeereid( int s, uid_t *euid, gid_t *egid ) msg.msg_accrights = (char *)fd; msg.msg_accrightslen = sizeof(fd); if( recvmsg( s, &msg, MSG_PEEK) >= 0 && msg.msg_accrightslen == sizeof(int) ) -# endif /* HAVE_MSGHDR_MSG_CONTROL*/ +# endif /* HAVE_STRUCT_MSGHDR_MSG_CONTROL*/ { /* We must receive a valid descriptor, it must be a pipe, * and it must only be accessible by its owner. */ -# ifdef HAVE_MSGHDR_MSG_CONTROL +# ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL fd[0] = (*(int *)CMSG_DATA( cmsg )); # endif err = fstat( fd[0], &st ); -- 2.39.5