]> granicus.if.org Git - sudo/commitdiff
Check whether getdomainname(), innetgr(), setresuid() and setresgid()
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 5 Feb 2015 18:08:55 +0000 (11:08 -0700)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 5 Feb 2015 18:08:55 +0000 (11:08 -0700)
are declared and add prototypes in sudo_compat.h as needed.

config.h.in
configure
configure.ac
include/sudo_compat.h

index 5035ffb2fac7aa7b77357374f041824d86876407..809c34aa514543aefd932fd3441e4f85b76934c2 100644 (file)
    */
 #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
    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
    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
    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
index 39e1ea2a72a3db93e6fc4578590238e2dee60afd..fd1c53844aa2092963cf55a6a27d4127cc76e574 100755 (executable)
--- 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 <netgroup.h>
+#else
+# include <netdb.h>
+#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 <netgroup.h>
+#else
+# include <netdb.h>
+#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
index c574276ac4411079a91c9b688944b3e47a6108a6..1fedd076318f584d99076c7a11b9e130ccd13a74 100644 (file)
@@ -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 <netgroup.h>
+#else
+# include <netdb.h>
+#endif /* HAVE_NETGROUP_H */
+])], [
+    AC_CHECK_FUNCS([_innetgr], [
+       AC_CHECK_DECLS([_innetgr], [], [], [
+AC_INCLUDES_DEFAULT
+#ifdef HAVE_NETGROUP_H
+# include <netgroup.h>
+#else
+# include <netdb.h>
+#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], [
index 2af220ad95f78291caccae6650c0b624a9db6790..c79777cbe705613189dc8ae7b4acc2d96f83a3f6 100644 (file)
@@ -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