From: Todd C. Miller Date: Tue, 1 Jun 2004 19:13:37 +0000 (+0000) Subject: Add a check for a dirfd() function (like Linux) and add a dirfd X-Git-Tag: SUDO_1_6_8~93 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=54cb0921dea0d82e409a5ddf316c9c6f0e750013;p=sudo Add a check for a dirfd() function (like Linux) and add a dirfd macro in compat.h if there is no dirfd() function or macro. --- diff --git a/compat.h b/compat.h index f6fb926e6..2d87cffc7 100644 --- a/compat.h +++ b/compat.h @@ -203,6 +203,13 @@ typedef struct sigaction sigaction_t; # endif #endif +/* + * If dirfd() does not exists, hopefully dd_fd does. + */ +#if !defined(HAVE_DIRFD) && !defined(dirfd) +# define dirfd(_d) ((_d)->dd_fd) +#endif + /* * If we lack getprogname(), emulate with __progname if possible. * Otherwise, add a prototype for use with our own getprogname.c. diff --git a/config.h.in b/config.h.in index 80778bd20..7e61baab3 100644 --- a/config.h.in +++ b/config.h.in @@ -75,6 +75,9 @@ */ #undef HAVE_DIRENT_H +/* Define to 1 if you have the `dirfd' function (not macro). */ +#undef HAVE_DIRFD + /* Define to 1 if you have the `dispcrypt' function. */ #undef HAVE_DISPCRYPT diff --git a/configure b/configure index 4dcec3142..20c6b8ff7 100755 --- a/configure +++ b/configure @@ -26147,7 +26147,8 @@ _ACEOF -for ac_func in strerror strcasecmp sigaction strlcpy strlcat closefrom + +for ac_func in strerror strcasecmp sigaction strlcpy strlcat closefrom dirfd do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 diff --git a/configure.in b/configure.in index 234d7a31f..72b95ec6b 100644 --- a/configure.in +++ b/configure.in @@ -1705,7 +1705,7 @@ 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) +AC_REPLACE_FUNCS(strerror strcasecmp sigaction strlcpy strlcat closefrom dirfd) AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf, , [NEED_SNPRINTF=1]) dnl dnl If NEED_SNPRINTF is set, add snprintf.c to LIBOBJS