From: Todd C. Miller Date: Thu, 5 Jul 2007 19:46:23 +0000 (+0000) Subject: Less hacky way of testing whether the domain was set. X-Git-Tag: SUDO_1_7_0~512 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6a8fb711542fc6352ade4f9c373e3a57402638c9;p=sudo Less hacky way of testing whether the domain was set. --- diff --git a/match.c b/match.c index ec5218dc6..ea52824af 100644 --- a/match.c +++ b/match.c @@ -563,11 +563,10 @@ netgr_matches(netgr, lhost, shost, user) char *shost; char *user; { + static char *domain; #ifdef HAVE_GETDOMAINNAME - static char *domain = (char *) -1; -#else - static char *domain = NULL; -#endif /* HAVE_GETDOMAINNAME */ + static int initialized; +#endif /* make sure we have a valid netgroup, sudo style */ if (*netgr++ != '+') @@ -575,12 +574,13 @@ netgr_matches(netgr, lhost, shost, user) #ifdef HAVE_GETDOMAINNAME /* get the domain name (if any) */ - if (domain == (char *) -1) { + if (!initialized) { domain = (char *) emalloc(MAXHOSTNAMELEN); if (getdomainname(domain, MAXHOSTNAMELEN) == -1 || *domain == '\0') { efree(domain); domain = NULL; } + initialized = 1; } #endif /* HAVE_GETDOMAINNAME */