]> granicus.if.org Git - sudo/commitdiff
Less hacky way of testing whether the domain was set.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 5 Jul 2007 19:46:23 +0000 (19:46 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 5 Jul 2007 19:46:23 +0000 (19:46 +0000)
match.c

diff --git a/match.c b/match.c
index ec5218dc6da38ee8ccca3daca8925018e7122c0c..ea52824afa3c0fef0d0514712472e70f2951ad17 100644 (file)
--- 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 */