]> granicus.if.org Git - sudo/commitdiff
Check return value of setdefs() but don't stop setting defaults if
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 19 Jul 2010 16:39:41 +0000 (12:39 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 19 Jul 2010 16:39:41 +0000 (12:39 -0400)
we hit an unknown one.

--HG--
branch : 1.7

defaults.c
sudo.c

index 670b1a6cd086a079934354b494ee8e13044a8b8b..1bc99c7bd4f0c8c61d7bf87098e54fb61d40fe5f 100644 (file)
@@ -501,48 +501,49 @@ init_defaults()
 
 /*
  * Update the defaults based on what was set by sudoers.
- * Pass in a an OR'd list of which default types to update.
+ * Pass in an OR'd list of which default types to update.
  */
 int
 update_defaults(what)
     int what;
 {
     struct defaults *def;
+    int rc = TRUE;
 
     tq_foreach_fwd(&defaults, def) {
        switch (def->type) {
            case DEFAULTS:
                if (ISSET(what, SETDEF_GENERIC) &&
                    !set_default(def->var, def->val, def->op))
-                   return(FALSE);
+                   rc = FALSE;
                break;
            case DEFAULTS_USER:
                if (ISSET(what, SETDEF_USER) &&
                    userlist_matches(sudo_user.pw, &def->binding) == ALLOW &&
                    !set_default(def->var, def->val, def->op))
-                   return(FALSE);
+                   rc = FALSE;
                break;
            case DEFAULTS_RUNAS:
                if (ISSET(what, SETDEF_RUNAS) &&
                    runaslist_matches(&def->binding, NULL) == ALLOW &&
                    !set_default(def->var, def->val, def->op))
-                   return(FALSE);
+                   rc = FALSE;
                break;
            case DEFAULTS_HOST:
                if (ISSET(what, SETDEF_HOST) &&
                    hostlist_matches(&def->binding) == ALLOW &&
                    !set_default(def->var, def->val, def->op))
-                   return(FALSE);
+                   rc = FALSE;
                break;
            case DEFAULTS_CMND:
                if (ISSET(what, SETDEF_CMND) &&
                    cmndlist_matches(&def->binding) == ALLOW &&
                    !set_default(def->var, def->val, def->op))
-                   return(FALSE);
+                   rc = FALSE;
                break;
        }
     }
-    return(TRUE);
+    return(rc);
 }
 
 static int
diff --git a/sudo.c b/sudo.c
index ee8de96a19569b705c32e569b48bd533b83c6415..b4f584c885cb2997cf995a5eb7b3245274c63dcb 100644 (file)
--- a/sudo.c
+++ b/sudo.c
@@ -279,7 +279,8 @@ main(argc, argv, envp)
     tq_foreach_fwd(snl, nss) {
        if (nss->open(nss) == 0 && nss->parse(nss) == 0) {
            sources++;
-           nss->setdefs(nss);
+           if (nss->setdefs(nss) != 0)
+               log_error(NO_STDERR|NO_EXIT, "problem with defaults entries");
        }
     }
     if (sources == 0)