2 * Copyright (c) 1999-2005, 2008-2018
3 * Todd C. Miller <Todd.Miller@sudo.ws>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 * Sponsored in part by the Defense Advanced Research Projects
18 * Agency (DARPA) and Air Force Research Laboratory, Air Force
19 * Materiel Command, USAF, under agreement number F39502-99-1-0512.
22 #ifndef SUDOERS_DEFAULTS_H
23 #define SUDOERS_DEFAULTS_H
27 #include "sudo_queue.h"
30 SLIST_ENTRY(list_member) entries;
34 SLIST_HEAD(list_members, list_member);
42 /* Mapping of tuple string value to enum def_tuple. */
44 char *sval; /* string value */
45 enum def_tuple nval;/* numeric value */
55 struct timespec tspec;
56 struct list_members list;
60 * Structure describing compile-time and run-time options.
62 struct sudo_defs_types {
66 struct def_values *values;
67 bool (*callback)(const union sudo_defs_val *);
68 union sudo_defs_val sd_un;
72 * Defaults values to apply before others.
74 struct early_default {
80 * Four types of defaults: strings, integers, and flags.
81 * Also, T_INT, T_TIMESPEC or T_STR may be ANDed with T_BOOL to indicate that
82 * a value is not required. Flags are boolean by nature...
97 #define T_LOGFAC 0x007
99 #define T_LOGPRI 0x008
101 #define T_TUPLE 0x009
103 #define T_TIMESPEC 0x010
105 #define T_TIMEOUT 0x020
114 * Argument to update_defaults()
116 #define SETDEF_GENERIC 0x01
117 #define SETDEF_HOST 0x02
118 #define SETDEF_USER 0x04
119 #define SETDEF_RUNAS 0x08
120 #define SETDEF_CMND 0x10
121 #define SETDEF_ALL (SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER|SETDEF_RUNAS|SETDEF_CMND)
126 struct defaults_list;
127 struct sudoers_parse_tree;
128 void dump_default(void);
129 bool init_defaults(void);
130 struct early_default *is_early_default(const char *name);
131 bool run_early_defaults(void);
132 bool set_early_default(const char *var, const char *val, int op, const char *file, int lineno, bool quiet, struct early_default *early);
133 bool set_default(const char *var, const char *val, int op, const char *file, int lineno, bool quiet);
134 bool update_defaults(struct sudoers_parse_tree *parse_tree, struct defaults_list *defs, int what, bool quiet);
135 bool check_defaults(struct sudoers_parse_tree *parse_tree, bool quiet);
137 extern struct sudo_defs_types sudo_defs_table[];
139 #endif /* SUDOERS_DEFAULTS_H */