]> granicus.if.org Git - sudo/commitdiff
Actually use the check for prior initialization in sudo_getdomainname().
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 2 Feb 2015 22:38:03 +0000 (15:38 -0700)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 2 Feb 2015 22:38:03 +0000 (15:38 -0700)
plugins/sudoers/match.c

index 4de9b127fae304b7b60c507f8af924d44b258607..03c9293027d17e2ced926a52a79b294d28a00e5f 100644 (file)
@@ -916,19 +916,21 @@ sudo_getdomainname(void)
     static char buf[HOST_NAME_MAX + 1];
     static bool initialized;
 
-    if (getdomainname(buf, sizeof(buf)) == 0 && buf[0] != '\0') {
-       char *cp;
-
-       domain = buf;
-       for (cp = buf; *cp != '\0'; cp++) {
-           /* Check for illegal characters, Linux may use "(none)". */
-           if (*cp == '(' || *cp == ')' || *cp == ',' || *cp == ' ') {
-               domain = NULL;
-               break;
+    if (!initialized) {
+       if (getdomainname(buf, sizeof(buf)) == 0 && buf[0] != '\0') {
+           char *cp;
+
+           domain = buf;
+           for (cp = buf; *cp != '\0'; cp++) {
+               /* Check for illegal characters, Linux may use "(none)". */
+               if (*cp == '(' || *cp == ')' || *cp == ',' || *cp == ' ') {
+                   domain = NULL;
+                   break;
+               }
            }
        }
+       initialized = true;
     }
-    initialized = true;
 #endif /* HAVE_GETDOMAINNAME */
     return domain;
 }