mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-31 14:25:15 +00:00
Add new check_defaults() function to check (but not update) the
Defaults entries. Visudo can now use this instead of update_defaults to check all the defaults regardless instead of just the global Defaults entries.
This commit is contained in:
@@ -485,7 +485,7 @@ init_defaults(void)
|
||||
* Update the defaults based on what was set by sudoers.
|
||||
* Pass in an OR'd list of which default types to update.
|
||||
*/
|
||||
int
|
||||
bool
|
||||
update_defaults(int what)
|
||||
{
|
||||
struct defaults *def;
|
||||
@@ -528,6 +528,54 @@ update_defaults(int what)
|
||||
debug_return_bool(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check the defaults entries without actually setting them.
|
||||
* Pass in an OR'd list of which default types to check.
|
||||
*/
|
||||
bool
|
||||
check_defaults(int what, bool quiet)
|
||||
{
|
||||
struct sudo_defs_types *cur;
|
||||
struct defaults *def;
|
||||
bool rc = true;
|
||||
debug_decl(check_defaults, SUDO_DEBUG_DEFAULTS)
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
debug_return_bool(rc);
|
||||
}
|
||||
|
||||
static bool
|
||||
store_int(char *val, struct sudo_defs_types *def, int op)
|
||||
{
|
||||
|
Reference in New Issue
Block a user