return rc;
}
+/*
+ * Check the defaults entries without actually setting them.
+ * Pass in an OR'd list of which default types to check.
+ */
+int
+check_defaults(what, quiet)
+ int what;
+ int quiet;
+{
+ struct sudo_defs_types *cur;
+ struct defaults *def;
+ int rc = TRUE;
+
+ tq_foreach_fwd(&defaults, def) {
+ switch (def->type) {
+ case DEFAULTS:
+ if (!ISSET(what, SETDEF_GENERIC))
+ continue;
+ break;
+ case DEFAULTS_USER:
+ if (!ISSET(what, SETDEF_USER))
+ continue;
+ break;
+ case DEFAULTS_RUNAS:
+ if (!ISSET(what, SETDEF_RUNAS))
+ continue;
+ break;
+ case DEFAULTS_HOST:
+ if (!ISSET(what, SETDEF_HOST))
+ continue;
+ break;
+ case DEFAULTS_CMND:
+ if (!ISSET(what, SETDEF_CMND))
+ continue;
+ break;
+ }
+ for (cur = sudo_defs_table; cur->name != NULL; cur++) {
+ if (strcmp(def->var, cur->name) == 0)
+ break;
+ }
+ if (cur->name == NULL) {
+ if (!quiet)
+ warningx("unknown defaults entry `%s'", def->var);
+ rc = FALSE;
+ }
+ }
+ return rc;
+}
+
static int
store_int(val, def, op)
char *val;
#define T_PATH 0x200
/*
- * Argument to update_defaults()
+ * Argument to update_defaults() and check_defaults()
*/
#define SETDEF_GENERIC 0x01
#define SETDEF_HOST 0x02
*/
int set_default __P((char *, char *, int));
int update_defaults __P((int));
+int check_defaults __P((int, int));
void dump_default __P((void));
void dump_defaults __P((void));
void init_defaults __P((void));
}
fclose(yyin);
if (!parse_error) {
- if (!update_defaults(SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER) ||
+ if (!check_defaults(SETDEF_ALL, quiet) ||
check_aliases(strict, quiet) != 0) {
parse_error = TRUE;
- errorfile = sp->path;
+ errorfile = NULL;
}
}
tq_foreach_fwd(&sudoerslist, sp) {
if (errorfile == NULL || strcmp(sp->path, errorfile) == 0) {
edit_sudoers(sp, editor, args, errorlineno);
- break;
+ if (errorfile != NULL)
+ break;
}
}
- if (sp == NULL)
+ if (errorfile != NULL && sp == NULL)
errorx(1, "internal error, can't find %s in list!", sudoers);
}
parse_error = TRUE;
errorfile = sudoers_path;
}
- if (!parse_error && check_aliases(strict, quiet) != 0) {
- parse_error = TRUE;
- errorfile = sudoers_path;
+ if (!parse_error) {
+ if (!check_defaults(SETDEF_ALL, quiet) ||
+ check_aliases(strict, quiet) != 0) {
+ parse_error = TRUE;
+ errorfile = NULL;
+ }
}
error = parse_error;
if (!quiet) {