Solaris uses sysinfo(SI_SRPC_DOMAIN) instead of getdomainname() to

get the host's NIS domain.
This commit is contained in:
Todd C. Miller
2015-02-03 07:33:24 -07:00
parent 7fdbbf16a4
commit 536c83cec3
4 changed files with 52 additions and 6 deletions

View File

@@ -741,6 +741,9 @@
/* Define to 1 if you have the `sysctl' function. */
#undef HAVE_SYSCTL
/* Define to 1 if you have the `sysinfo' function. */
#undef HAVE_SYSINFO
/* Define to 1 if you have the <sys/bsdtypes.h> header file. */
#undef HAVE_SYS_BSDTYPES_H
@@ -776,6 +779,9 @@
/* Define to 1 if you have the <sys/sysmacros.h> header file. */
#undef HAVE_SYS_SYSMACROS_H
/* Define to 1 if you have the <sys/systeminfo.h> header file. */
#undef HAVE_SYS_SYSTEMINFO_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H

30
configure vendored
View File

@@ -18653,7 +18653,11 @@ if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
for ac_func in getdomainname
break
fi
done
for ac_func in getdomainname
do :
ac_fn_c_check_func "$LINENO" "getdomainname" "ac_cv_func_getdomainname"
if test "x$ac_cv_func_getdomainname" = xyes; then :
@@ -18661,9 +18665,31 @@ if test "x$ac_cv_func_getdomainname" = xyes; then :
#define HAVE_GETDOMAINNAME 1
_ACEOF
else
for ac_func in sysinfo
do :
ac_fn_c_check_func "$LINENO" "sysinfo" "ac_cv_func_sysinfo"
if test "x$ac_cv_func_sysinfo" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SYSINFO 1
_ACEOF
for ac_header in sys/systeminfo.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "sys/systeminfo.h" "ac_cv_header_sys_systeminfo_h" "$ac_includes_default"
if test "x$ac_cv_header_sys_systeminfo_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SYS_SYSTEMINFO_H 1
_ACEOF
fi
done
fi
done
break
fi
done

View File

@@ -2452,7 +2452,10 @@ 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], [AC_CHECK_FUNCS([getdomainname]) [break]])
AC_CHECK_FUNCS([innetgr _innetgr], [break])
AC_CHECK_FUNCS([getdomainname], [], [
AC_CHECK_FUNCS([sysinfo], [AC_CHECK_HEADERS([sys/systeminfo.h])])
])
AC_CHECK_FUNCS([utimes], [
AC_CHECK_FUNCS([futimes futimesat], [break])
], [

View File

@@ -25,6 +25,9 @@
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_SYSTEMINFO_H
# include <sys/systeminfo.h>
#endif
#include <stdio.h>
#ifdef STDC_HEADERS
# include <stdlib.h>
@@ -912,12 +915,20 @@ const char *
sudo_getdomainname(void)
{
char *domain = NULL;
#ifdef HAVE_GETDOMAINNAME
#if defined(HAVE_GETDOMAINNAME) || defined(SI_SRPC_DOMAIN)
static char buf[HOST_NAME_MAX + 1];
static bool initialized;
if (!initialized) {
if (getdomainname(buf, sizeof(buf)) == 0 && buf[0] != '\0') {
int rval;
# ifdef SI_SRPC_DOMAIN
buf[0] = '\0';
rval = sysinfo(SI_SRPC_DOMAIN, buf, sizeof(buf));
# else
rval = getdomainname(buf, sizeof(buf));
# endif
if (rval != -1 && buf[0] != '\0') {
char *cp;
domain = buf;
@@ -931,7 +942,7 @@ sudo_getdomainname(void)
}
initialized = true;
}
#endif /* HAVE_GETDOMAINNAME */
#endif /* HAVE_GETDOMAINNAME || SI_SRPC_DOMAIN */
return domain;
}