From: Todd C. Miller Date: Thu, 5 Feb 2015 18:08:55 +0000 (-0700) Subject: Check whether getdomainname(), innetgr(), setresuid() and setresgid() X-Git-Tag: SUDO_1_8_12^2~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1bb633a210d90ea0d84bf79ae371db2703ac68fa;p=sudo Check whether getdomainname(), innetgr(), setresuid() and setresgid() are declared and add prototypes in sudo_compat.h as needed. --- diff --git a/config.h.in b/config.h.in index 5035ffb2f..809c34aa5 100644 --- a/config.h.in +++ b/config.h.in @@ -89,6 +89,10 @@ */ #undef HAVE_DECL_ERRNO +/* Define to 1 if you have the declaration of `getdomainname', and to 0 if you + don't. */ +#undef HAVE_DECL_GETDOMAINNAME + /* Define to 1 if you have the declaration of `HOST_NAME_MAX', and to 0 if you don't. */ #undef HAVE_DECL_HOST_NAME_MAX @@ -97,6 +101,10 @@ don't. */ #undef HAVE_DECL_H_ERRNO +/* Define to 1 if you have the declaration of `innetgr', and to 0 if you + don't. */ +#undef HAVE_DECL_INNETGR + /* Define to 1 if you have the declaration of `LLONG_MAX', and to 0 if you don't. */ #undef HAVE_DECL_LLONG_MAX @@ -125,6 +133,10 @@ don't. */ #undef HAVE_DECL_SETAUTHDB +/* Define to 1 if you have the declaration of `setresuid', and to 0 if you + don't. */ +#undef HAVE_DECL_SETRESUID + /* Define to 1 if you have the declaration of `SIZE_MAX', and to 0 if you don't. */ #undef HAVE_DECL_SIZE_MAX @@ -157,6 +169,10 @@ don't. */ #undef HAVE_DECL_USRINFO +/* Define to 1 if you have the declaration of `_innetgr', and to 0 if you + don't. */ +#undef HAVE_DECL__INNETGR + /* Define to 1 if you have the declaration of `_POSIX_HOST_NAME_MAX', and to 0 if you don't. */ #undef HAVE_DECL__POSIX_HOST_NAME_MAX diff --git a/configure b/configure index 39e1ea2a7..fd1c53844 100755 --- a/configure +++ b/configure @@ -18610,6 +18610,17 @@ if test "x$ac_cv_func_setresuid" = xyes; then : _ACEOF SKIP_SETREUID=yes + ac_fn_c_check_decl "$LINENO" "setresuid" "ac_cv_have_decl_setresuid" "$ac_includes_default" +if test "x$ac_cv_have_decl_setresuid" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_SETRESUID $ac_have_decl +_ACEOF + for ac_func in getresuid do : ac_fn_c_check_func "$LINENO" "getresuid" "ac_cv_func_getresuid" @@ -18677,15 +18688,67 @@ _ACEOF fi done -for ac_func in innetgr _innetgr +for ac_func in innetgr do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + ac_fn_c_check_func "$LINENO" "innetgr" "ac_cv_func_innetgr" +if test "x$ac_cv_func_innetgr" = xyes; then : cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define HAVE_INNETGR 1 _ACEOF - break + + ac_fn_c_check_decl "$LINENO" "innetgr" "ac_cv_have_decl_innetgr" " +$ac_includes_default +#ifdef HAVE_NETGROUP_H +# include +#else +# include +#endif /* HAVE_NETGROUP_H */ + +" +if test "x$ac_cv_have_decl_innetgr" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_INNETGR $ac_have_decl +_ACEOF + +else + + for ac_func in _innetgr +do : + ac_fn_c_check_func "$LINENO" "_innetgr" "ac_cv_func__innetgr" +if test "x$ac_cv_func__innetgr" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE__INNETGR 1 +_ACEOF + + ac_fn_c_check_decl "$LINENO" "_innetgr" "ac_cv_have_decl__innetgr" " +$ac_includes_default +#ifdef HAVE_NETGROUP_H +# include +#else +# include +#endif /* HAVE_NETGROUP_H */ + +" +if test "x$ac_cv_have_decl__innetgr" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL__INNETGR $ac_have_decl +_ACEOF + + +fi +done + + fi done @@ -18697,6 +18760,18 @@ if test "x$ac_cv_func_getdomainname" = xyes; then : #define HAVE_GETDOMAINNAME 1 _ACEOF + ac_fn_c_check_decl "$LINENO" "getdomainname" "ac_cv_have_decl_getdomainname" "$ac_includes_default" +if test "x$ac_cv_have_decl_getdomainname" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_GETDOMAINNAME $ac_have_decl +_ACEOF + + else for ac_func in sysinfo diff --git a/configure.ac b/configure.ac index c574276ac..1fedd0763 100644 --- a/configure.ac +++ b/configure.ac @@ -2451,6 +2451,7 @@ SUDO_FUNC_PUTENV_CONST if test -z "$SKIP_SETRESUID"; then AC_CHECK_FUNCS([setresuid], [ SKIP_SETREUID=yes + AC_CHECK_DECLS([setresuid]) AC_CHECK_FUNCS([getresuid]) ]) fi @@ -2462,8 +2463,29 @@ if test X"$with_interfaces" != X"no"; then AC_CHECK_FUNCS([getifaddrs], [AC_CHECK_FUNCS([freeifaddrs])]) fi AC_CHECK_FUNCS([lockf flock], [break]) -AC_CHECK_FUNCS([innetgr _innetgr], [break]) -AC_CHECK_FUNCS([getdomainname], [], [ +AC_CHECK_FUNCS([innetgr], [ + AC_CHECK_DECLS([innetgr], [], [], [ +AC_INCLUDES_DEFAULT +#ifdef HAVE_NETGROUP_H +# include +#else +# include +#endif /* HAVE_NETGROUP_H */ +])], [ + AC_CHECK_FUNCS([_innetgr], [ + AC_CHECK_DECLS([_innetgr], [], [], [ +AC_INCLUDES_DEFAULT +#ifdef HAVE_NETGROUP_H +# include +#else +# include +#endif /* HAVE_NETGROUP_H */ + ]) + ]) +]) +AC_CHECK_FUNCS([getdomainname], [ + AC_CHECK_DECLS([getdomainname]) +], [ AC_CHECK_FUNCS([sysinfo], [AC_CHECK_HEADERS([sys/systeminfo.h])]) ]) AC_CHECK_FUNCS([utimes], [ diff --git a/include/sudo_compat.h b/include/sudo_compat.h index 2af220ad9..c79777cbe 100644 --- a/include/sudo_compat.h +++ b/include/sudo_compat.h @@ -339,14 +339,25 @@ extern int errno; # endif #endif /* HAVE_SETEUID */ +/* + * Older HP-UX does not declare setresuid() or setresgid(). + */ +#if defined(HAVE_DECL_SETRESUID) && !HAVE_DECL_SETRESUID +int setresuid(uid_t ruid, uid_t euid, uid_t suid); +int setresgid(gid_t rgid, gid_t egid, gid_t sgid); +#endif + /* * HP-UX does not declare innetgr() or getdomainname(). * Solaris does not declare getdomainname(). */ -#if defined(__hpux) +#if defined(HAVE_DECL_INNETGR) && !HAVE_DECL_INNETGR int innetgr(const char *, const char *, const char *, const char *); #endif -#if defined(__hpux) || defined(__sun) +#if defined(HAVE_DECL__INNETGR) && !HAVE_DECL__INNETGR +int _innetgr(const char *, const char *, const char *, const char *); +#endif +#if defined(HAVE_DECL_GETDOMAINNAME) && !HAVE_DECL_GETDOMAINNAME int getdomainname(char *, size_t); #endif