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
Todd C. Miller
e0761b9e3b
Also free safe_cmnd so it doesn't leak.
2021-02-22 20:18:49 -07:00
Todd C. Miller
f92080be62
Prime user/group cached and set the interface list.
...
Also match parsed policy against multiple users.
2021-02-22 10:59:58 -07:00
Todd C. Miller
df42c0c1d2
Perform matching in fuzz_sudoers for inputs that parse correctly.
...
The fuzzer now exercised the normal match code as well as the
pseudo-command (list, validate, etc) match code.
Privileges are also listed for well-formed sudoers file.
2021-02-21 14:59:29 -07:00
Todd C. Miller
30d9497eb6
Add stub library that just feeds files to the fuzzing target.
...
This will allow the fuzzers to be run as part of "make check".
2021-02-07 15:43:51 -07:00
Todd C. Miller
a72d743ec8
Fall back to a temp file if fmemopen() is not available().
2021-02-07 13:56:15 -07:00
Todd C. Miller
4480e26972
Build (but don't run) fuzzers as part of "make check".
...
Uses a stub to make it possible to link w/o libfuzzer.
The goal is to ensure the fuzzers are always buildable and avoid bit rot.
2021-02-06 08:38:38 -07:00
Todd C. Miller
e675f4c078
Don't allow the sudoers fuzzer to open include files.
...
If we allow the fuzzer to choose include paths it will include
random files in the file system. This leads to bug reports that
cannot be reproduced.
2021-02-03 15:20:54 -07:00
Todd C. Miller
3237a18ee3
Use sudoersrestart() in fuzz_sudoers.c
...
Since we run the parser multiple times we need to restart it each time.
2021-02-03 12:52:15 -07:00
Todd C. Miller
e66b132d76
Parser needs user_shost for the %h escape in @include expansion.
...
Fixes oss-fuzz issue #30238
2021-02-03 08:56:32 -07:00
Todd C. Miller
8f2254594f
close sudoersin, not fp, and reset it to be safe
2021-02-02 14:12:43 -07:00
Todd C. Miller
20b3904f4f
Add missing fclose(3) of fmemopen(3) stream; it does not modify the data.
2021-02-02 13:58:31 -07:00
Todd C. Miller
d3735b98e9
Call init_parser() after parsing to clean up completely.
2021-02-01 20:37:59 -07:00
Todd C. Miller
1e3cecc608
Add initial fuzzers to be used by oss-fuzz.
...
These are not yet hooked up to the sudo build.
2021-02-01 15:17:57 -07:00