Commit f799a2e4 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

replace struct msghdr macros

parent d9e8e395
......@@ -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 <sys/socket.h>]],
[[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 <sys/socket.h>]],
[[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,[
......
#! /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 <sys/socket.h>
#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 <sys/socket.h>
#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 <sys/socket.h>
#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 <sys/socket.h>
#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"
......@@ -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 <sys/socket.h>
#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 <sys/socket.h>
#endif])
fi
LIBSRCS="$LIBSRCS getpeereid.c"
fi
......
......@@ -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
......
......@@ -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]);
......
......@@ -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 <sys/uio.h>
......@@ -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 );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment