Todd C. Miller
2d2529a15e
Add a sudoers_context struct that embeds the user and runas structs.
2023-08-20 16:27:08 -06:00
Todd C. Miller
08afb5183f
Move RUNAS_{USER,GROUP}_SPECIFIED flags into struct sudoers_runas_context.
2023-08-14 09:01:39 -06:00
Todd C. Miller
217b7b46f3
Move list_pw global into struct runas_context.
2023-08-13 09:34:57 -06:00
Todd C. Miller
a321e6cedf
Add struct sudoers_runas_context and move runas-specific bits into it.
2023-08-12 14:20:30 -06:00
Todd C. Miller
d8b28dad97
Expand the user_* (and more) macros to user_ctx.foo.
2023-08-12 10:39:59 -06:00
Todd C. Miller
bd8cccb5dd
Rename struct sudo_user -> struct sudo_user_context.
...
Also rename the sudo_user global to user_ctx.
2023-08-12 10:39:47 -06:00
Todd C. Miller
f6a9bb2e23
Use a single callback for sudoers_lookup() and add a closure pointer.
...
The single callback now receives all the match info (or UNSPEC if
no match was attempted). This makes it possible to use the callback
for more than just printing testsudoers output.
2023-08-07 15:06:19 -06:00
Todd C. Miller
cbcb1d2506
sudoers plugin: make more bit flags unsigned.
2023-07-10 11:06:23 -06:00
Rose
5d758264ab
Give every printf-like function restrict qualifiers
...
The format value has to be a string literal, every time.
Otherwise, you are not using these functions correctly. To reinforce this fact, I putrestrict over every non-contrib example of this I could find.
2023-07-07 20:23:20 -04:00
Todd C. Miller
e025cca440
Add callbacks to sudoers_lookup() so we can use it in testsudoers.
...
Also pass in the time to be used for NOTBEFORE/NOTAFTER checks.
2023-06-29 17:30:39 -06:00
Todd C. Miller
8cbd5462a6
Move sudoers search path to struct sudoers_parser_config.
...
That way we can avoid passing it to init_parser() directly.
We still need sudoers_search_path to be shared between the lexer
and the parser.
2023-05-08 17:04:38 -06:00
Todd C. Miller
9d7c30c5a8
Add struct sudoers_parser_config and pass it to init_parser().
...
This struct contains parser configuration such as the sudoers file
uid/gid/mode and parse flags such as verbose, strict and recovery.
2023-05-08 17:03:31 -06:00
Todd C. Miller
bbbaea5b2f
Rename init_parser_ext() to init_parser() and remove old wrapper.
...
There was only one consumer of the init_parser() wrapper now that
reset_parser() has been introduced.
2023-05-02 13:29:49 -06:00
Todd C. Miller
f258a15df5
Add reset_parser() and use in place of init_parser(NULL).
2023-05-02 13:27:17 -06:00
Todd C. Miller
5446b009e3
Support adminconfdir for relative include paths in sudoers.
2023-05-02 10:47:11 -06:00
Todd C. Miller
f17b35471f
Support sudoers_file being a colon-separated path of files.
...
The first file found is used.
2023-05-02 10:37:38 -06:00
Todd C. Miller
8049e4e32f
Replace sudoers_warnings with sudoers_verbose.
...
This is now an int, with values > 1 reserved for visudo.
2023-03-20 18:27:27 -06:00
Todd C. Miller
4b563ea44f
Pass around const struct sudo_nss pointers where possible.
2023-03-17 13:41:38 -06:00
Todd C. Miller
0aad96bba1
Add per-source innetgr function pointer and use it in netgr_matches().
...
This will be used to implement LDAP-specific netgroup lookups when
netgroup_base is set in ldap.conf.
2023-03-08 13:44:22 -07:00
Todd C. Miller
87ce692468
Fix potential double free for rules that include a CHROOT= option.
...
If a rule with a CHROOT= option matches the user, host and runas,
the user_cmnd variable could be freed twice.
2023-02-21 20:01:13 -07:00
Todd C. Miller
bdef2ad6d2
No longer need to define sudoers_recovery here.
2023-02-09 16:39:25 -07:00
Todd C. Miller
91d7592e8a
Use initprogname(), not setprogname() in the fuzzers.
...
This results in better coverage for progname.c.
2022-12-29 15:52:21 -07:00
Todd C. Miller
62dd5734a2
Plug a memory leak of list_cmnd in the fuzzers.
2022-12-11 14:29:14 -07:00
Todd C. Miller
ce387a6849
Split log_{input,output} into log_{stdin,ttyin} and log_{ttyout,stdout,stderr}
...
If log_input is set, log_{stdin,ttyin} will be set as well.
If log_output is set, log_{stdout,stderr,ttyout} will be set as well.
This provides more fine-grained control over I/O logging and makes it
possible to disable logging piped or redirected intput or output.
2022-09-20 14:35:12 -06:00
Todd C. Miller
13672f28df
Make sudo pass -Wwrite-strings
2022-06-28 16:33:15 -06:00
Todd C. Miller
f5ac1317c4
Make sudo pass -Wmissing-prototypes
2022-06-27 12:48:03 -06:00
Todd C. Miller
e5a50ae429
If there are multiple parse errors, send them in a single mail message.
2022-03-14 13:54:11 -06:00
Todd C. Miller
41bc52302b
Do not disable fuzzer output if SUDO_FUZZ_VERBOSE env variable is set.
2022-02-22 12:04:10 -07:00
Todd C. Miller
730ebabdba
init_parse_tree() now takes ownership of lhost and shost, if any.
...
This means that lhost and shost in struct sudoers_parse_tree
are no longer const and that free_parse_tree() will free lhost/shost.
The only consumer that passed in lho.st/shost was the SSSD back-end
which has been updated to avoid a double-free.
2021-11-19 12:29:21 -07:00
Todd C. Miller
2aa6cb13a5
Stub out sudo_printf() and avoid other use of stderr in fuzzers.
...
This makes it possible to parse sudoers without using quiet mode,
resulting in better coverage.
2021-09-29 09:03:24 -06:00
Todd C. Miller
eefb7b0d54
Use a consistent version of fuzz_conversation() with all fuzzers.
...
Also undo a change to fuzz_sudoers.c that snuck in to the last commit.
2021-09-28 20:20:28 -06:00
Todd C. Miller
7d964875df
Fuzzers should not produce output.
...
Excessive output makes the fuzzer runs much less efficient.
2021-09-28 18:53:49 -06:00
Todd C. Miller
b6561831b4
Re-enable error output for the sudoers parser.
...
It is only the alias and defaults warnings we need to suppress.
2021-09-20 12:46:37 -06:00
Todd C. Miller
77ef8baa97
fuzz_sudoers: don't warn about unknown defaults entries
...
Some fuzzing inputs cause a huge number of warnings and displaying
them all can result in the fuzz run timing out. If we disable the
warnings we can avoid the timeout.
2021-09-19 19:36:25 -06:00
Todd C. Miller
bb5843055e
Replace messages like "unknown foo: %s" with "unknown foo %s".
...
The colon really doesn't belong there; we generally use a colon to
separate a message from the warning detail.
2021-08-19 09:44:11 -06:00
Todd C. Miller
f9d3f46fa7
Add intercept_allow_setid sudoers option, disabled by default.
...
With this change, a shell in intercept mode cannot run a setuid or
setgid binary by default. On most systems, the dynamic loader will
ignore LD_PRELOAD for setuid/setgid binaries such as sudo which
would effectively disable intercept mode.
2021-08-18 15:43:26 -06:00
Todd C. Miller
a2e4f53642
Cast NULL terminator argument to char * when calling sudo_mkgrent().
...
Avoids a portability issue on systems where NULL is not a pointer.
2021-04-06 18:57:33 -06:00
Todd C. Miller
95bfd65fec
Flush stdout before successful return from LLVMFuzzerTestOneInput().
...
Fixes a problem with diag lines from libFuzzer being interspersed
with test output.
2021-03-18 13:08:30 -06:00
Todd C. Miller
963475a9bc
Fuzz with runuser and rungroup specified too.
2021-02-26 12:49:13 -07:00
Todd C. Miller
3595fd5504
Add user millert to group sudo, which is often the exempt group.
2021-02-25 19:41:31 -07:00
Todd C. Miller
e6dc13229f
Add sudoers debug register/deregister.
2021-02-25 13:35:29 -07:00
Todd C. Miller
ea341e2d34
Parse sudoers file in the C locale.
2021-02-25 13:08:12 -07:00
Todd C. Miller
f82890e5d7
No need to call check_defaults() and check_aliases() in quiet mode.
2021-02-24 19:09:16 -07:00
Todd C. Miller
39e80e47ba
Check defaults settings too.
2021-02-24 16:44:15 -07:00
Todd C. Miller
05767145b3
Add fuzzer-specific stubs source file.
2021-02-24 16:43:59 -07:00
Todd C. Miller
a3f38fac0c
Set program name in fuzzers so we get consisten warnings.
2021-02-24 15:14:58 -07:00
Todd C. Miller
cbd11c44d2
Update Defaults settings after parsing sudoers.
...
Also stub out dump_defaults when fuzzing as it is not used.
2021-02-24 12:29:34 -07:00
Todd C. Miller
9f5aed70a1
Exercise tilde expansion if used in runcwd or runchroot.
2021-02-23 19:37:19 -07:00
Todd C. Miller
2a0ba4008c
Check aliases in fuzz_sudoers if the policy parsed correctly.
2021-02-23 18:48:47 -07:00
Todd C. Miller
c71a397368
We don't need to link fuzz_sudoers with file.c.
2021-02-23 16:39:32 -07:00