From: Todd C. Miller Date: Tue, 1 Jun 2004 20:53:31 +0000 (+0000) Subject: Better check for dirfd macro--we now set HAVE_DIRFD for the macro version too. X-Git-Tag: SUDO_1_6_8~89 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e009af0c9c900349c97944e2377c7e9aace8e639;p=sudo Better check for dirfd macro--we now set HAVE_DIRFD for the macro version too. Added check for dd_fd in `DIR' if no dirfd is found; this is now used to confitionally define the dirfd macro in compat.h. --- diff --git a/configure b/configure index 20c6b8ff7..c6b34b46b 100755 --- a/configure +++ b/configure @@ -26147,8 +26147,7 @@ _ACEOF - -for ac_func in strerror strcasecmp sigaction strlcpy strlcat closefrom dirfd +for ac_func in strerror strcasecmp sigaction strlcpy strlcat closefrom do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -26323,6 +26322,86 @@ else fi done +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include <$ac_header_dirent> +int +main () +{ +DIR d; (void)dirfd(&d); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (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 + +cat >>confdefs.h <<\_ACEOF +#define HAVE_DIRFD 1 +_ACEOF + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include <$ac_header_dirent> +int +main () +{ +DIR d; (void)&d.dd_fd; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (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 + +cat >>confdefs.h <<\_ACEOF +#define HAVE_DD_FD 1 +_ACEOF + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext if test -n "$NEED_SNPRINTF"; then LIBOBJS="$LIBOBJS snprintf.$ac_objext" fi diff --git a/configure.in b/configure.in index 72b95ec6b..0cda41d28 100644 --- a/configure.in +++ b/configure.in @@ -1705,9 +1705,16 @@ AC_CHECK_FUNCS(lsearch, , [AC_CHECK_LIB(compat, lsearch, AC_CHECK_HEADER(search. AC_CHECK_FUNCS(utime, [SUDO_FUNC_UTIME_POSIX], [AC_LIBOBJ(utime)]) SUDO_FUNC_FNMATCH(AC_DEFINE(HAVE_FNMATCH, 1, [Define if you have the `fnmatch' function.]), AC_LIBOBJ(fnmatch)) SUDO_FUNC_ISBLANK -AC_REPLACE_FUNCS(strerror strcasecmp sigaction strlcpy strlcat closefrom dirfd) +AC_REPLACE_FUNCS(strerror strcasecmp sigaction strlcpy strlcat closefrom) AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf, , [NEED_SNPRINTF=1]) dnl +dnl Check for the dirfd function/macro. If not found, look for dd_fd in DIR. +dnl +AC_TRY_LINK([#include +#include <$ac_header_dirent>], [DIR d; (void)dirfd(&d);], [AC_DEFINE(HAVE_DIRFD, 1, [Define if you have the `fnmatch' function or macro.])], [AC_TRY_LINK([#include +#include <$ac_header_dirent>], [DIR d; (void)&d.dd_fd;], [AC_DEFINE(HAVE_DD_FD, + 1, [Define to 1 if your `DIR' contains dd_fd.])], [])]) +dnl dnl If NEED_SNPRINTF is set, add snprintf.c to LIBOBJS dnl (it contains snprintf, vsnprintf, asprintf, and vasprintf) dnl