From 98d9bc958bce7541af94091295991ebf14f3e87d Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 17 Aug 2012 10:30:26 -0400 Subject: [PATCH] Use AI_FQDN instead of AI_CANONNAME if available since "canonical" is not always the same as "fully qualified". --HG-- branch : 1.7 --- sudo.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sudo.c b/sudo.c index 6ccd0bb74..e2739fccd 100644 --- a/sudo.c +++ b/sudo.c @@ -1216,6 +1216,10 @@ set_loginclass(pw) } #endif /* HAVE_LOGIN_CAP_H */ +#ifndef AI_FQDN +# define AI_FQDN AI_CANONNAME +#endif + /* * Look up the fully qualified domain name and set user_host and user_shost. */ @@ -1232,7 +1236,7 @@ set_fqdn() #ifdef HAVE_GETADDRINFO zero_bytes(&hint, sizeof(hint)); hint.ai_family = PF_UNSPEC; - hint.ai_flags = AI_CANONNAME; + hint.ai_flags = AI_FQDN; if (getaddrinfo(user_host, NULL, &hint, &res0) != 0) { #else if (!(hp = gethostbyname(user_host))) { @@ -1248,13 +1252,13 @@ set_fqdn() #else user_host = estrdup(hp->h_name); #endif - } - if ((p = strchr(user_host, '.'))) { - *p = '\0'; - user_shost = estrdup(user_host); - *p = '.'; - } else { - user_shost = user_host; + if ((p = strchr(user_host, '.'))) { + *p = '\0'; + user_shost = estrdup(user_host); + *p = '.'; + } else { + user_shost = user_host; + } } } -- 2.40.0