/* Define to 1 if you use the FWTK authsrv daemon. */
#undef HAVE_FWTK
+/* Define to 1 if you have the `getaddrinfo' function. */
+#undef HAVE_GETADDRINFO
+
/* Define to 1 if you have the `getauthuid' function. (ULTRIX 4.x shadow
passwords) */
#undef HAVE_GETAUTHUID
+
for ac_func in strchr strrchr memchr memcpy memset sysconf tzset \
strftime setrlimit initgroups getgroups fstat gettimeofday \
- setlocale
+ setlocale getaddrinfo
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
dnl
AC_CHECK_FUNCS(strchr strrchr memchr memcpy memset sysconf tzset \
strftime setrlimit initgroups getgroups fstat gettimeofday \
- setlocale)
+ setlocale getaddrinfo)
if test -z "$SKIP_SETRESUID"; then
AC_CHECK_FUNCS(setresuid, [SKIP_SETREUID=yes])
fi
void
set_fqdn()
{
+#ifdef HAVE_GETADDRINFO
+ struct addrinfo *res0, hint;
+#else
struct hostent *hp;
+#endif
char *p;
+#ifdef HAVE_GETADDRINFO
+ memset(&hint, 0, sizeof(hint));
+ hint.ai_family = PF_UNSPEC;
+ hint.ai_flags = AI_CANONNAME;
+ if (getaddrinfo(user_host, NULL, &hint, &res0) != 0) {
+#else
if (!(hp = gethostbyname(user_host))) {
+#endif
log_error(MSG_ONLY|NO_EXIT,
- "unable to lookup %s via gethostbyname()", user_host);
+ "unable to resolve host %s", user_host);
} else {
if (user_shost != user_host)
efree(user_shost);
efree(user_host);
+#ifdef HAVE_GETADDRINFO
+ user_host = estrdup(res0->ai_canonname);
+ freeaddrinfo(res0);
+#else
user_host = estrdup(hp->h_name);
+#endif
}
if ((p = strchr(user_host, '.'))) {
*p = '\0';