Todd C. Miller
ecbe95589a
Add missing globfree(3) in command_matches_glob() when matching a directory.
2021-02-21 13:35:00 -07:00
Todd C. Miller
14c71eaa86
Add clean rules to .PHONY target.
2021-02-19 08:54:04 -07:00
Todd C. Miller
9f1e016cde
Add install-fuzz Makefile target to install the fuzzers and seed corpus.
...
The FUZZ_DESTDIR make variable needs to be set in the environment
or on the command line.
2021-02-18 19:38:54 -07:00
Todd C. Miller
5ea2acc4c2
Only display fuzz_policy output if the fuzzer exits with an error.
2021-02-18 15:12:42 -07:00
Todd C. Miller
d02cc9c3ac
Call list, validate and invalidate entry points too.
...
We need a separate open/close for each one.
2021-02-18 15:09:26 -07:00
Todd C. Miller
f76c59fc8f
Restore the check for sudoers_policy.close == NULL.
...
The fuzzers run as part of "make check" too in which case NO_LEAKS
won't be defined and the close function will be set to NULL.
2021-02-18 07:58:34 -07:00
Todd C. Miller
5813358b2b
Don't print a NULL as a string if role/type/privs/limitprivs is not set.
...
We can't rely on printf("%s", NULL) not crashing.
2021-02-18 06:09:08 -07:00
Todd C. Miller
aaf3d5643b
Fix compilation error on Solaris introduced with sudo_user_free().
2021-02-18 05:41:20 -07:00
Todd C. Miller
9937d08031
Distinguish between EOF and error using feof(3), not ferror(3).
...
Our getdelim(3) emulation won't set the error flag if the error is
due to an allocation failure. This explains the premature EOF
without error seen in Bug #960 .
2021-02-17 18:57:21 -07:00
Todd C. Miller
abdef93f72
Remove duplicated MALLOC_OPTIONS and MALLOC_CONF env variables.
2021-02-17 13:06:35 -07:00
Todd C. Miller
79a18cb419
regen
2021-02-17 09:57:36 -07:00
Todd C. Miller
a5504148a5
Add admin_flag sudoers option and make --enable-admin-flag take a path.
...
It is now possible to disable the Ubuntu admin flag in sudoers
or change its location.
GitHub issue #56
2021-02-16 13:20:02 -07:00
Todd C. Miller
5ec59cddc2
Fix tilde expansion of paths with no user like ~/foo.
...
The '/' separator was missing in the resulting path.
2021-02-16 13:19:58 -07:00
Todd C. Miller
a18b2a9ddf
Limit max_groups in sudo.conf to 1024.
...
The max_groups setting should no longer be needed anyway.
2021-02-16 12:37:23 -07:00
Todd C. Miller
df91e15b82
In sudoers_policy_close() call sudoers_cleanup() instead of sudo_user_free().
...
If we didn't call sudoers_policy_main() due to an early error there
may be more things to clean up.
2021-02-16 10:37:04 -07:00
Todd C. Miller
ecdf732adc
Check for invalid flag combinations from front-end for all cases.
...
The checks are now performed in the check_policy, list, validate
and invalidate functions instead of as part of the open function.
We can't perform the checks in open because we don't yet know what
operation is going to be performed.
2021-02-16 09:33:39 -07:00
Todd C. Miller
ae3a098d2f
Always dynamically allocate user_cmnd, it is freed in sudo_user_free().
...
Instead of setting user_cmnd in the policy functions, always set argv.
Calling sudoers_policy_main() with argc of 0 is no longer allowed.
2021-02-16 09:32:34 -07:00
Todd C. Miller
c09169e812
No need for sudoers_cleanup() in sudoers_policy_invalidate().
...
The sudoers close() function is now called even for "sudo -k".
Also no need to set user_cmnd, it is not used in this code path.
2021-02-16 08:26:49 -07:00
Todd C. Miller
de2a47f273
Set MALLOC_OPTIONS and MALLOC_CONF for all regress targets.
2021-02-15 13:17:46 -07:00
Todd C. Miller
52e3fcc795
Free struct sudo_user in sudoers_policy_close() and sudoers_cleanup().
...
Also, do not NULL out the close function if NO_LEAKS is defined.
2021-02-15 08:29:47 -07:00
Todd C. Miller
ea7a70e85d
For "make fuzz" only fuzz the seed corpus.
...
This way we avoid files generated by the fuzzer itself.
2021-02-15 07:35:19 -07:00
Todd C. Miller
7f3c670a13
Fix sudoers garbage collection and run it in policy fuzzer.
2021-02-14 14:01:31 -07:00
Todd C. Miller
7f0b269238
Do not include errno string for invalid params from front-end.
2021-02-14 07:48:58 -07:00
Todd C. Miller
561740cd54
Always dynamically allocate user_role, user_type, user_privs, user_limitprivs
2021-02-14 07:47:48 -07:00
Todd C. Miller
5c0454495c
Remove dead code, front-end does not set runas_privs or runas_limitprivs
2021-02-14 07:39:41 -07:00
Todd C. Miller
d1969b4f0b
Plug memory leak if there are duplicate user_info or command_info entries.
2021-02-14 07:21:00 -07:00
Todd C. Miller
776c57a81e
Move create_admin_success_flag() to timestamp.c.
2021-02-13 15:48:21 -07:00
Todd C. Miller
651a225a4a
The push() function was not updating the size after reallocating.
2021-02-13 12:54:22 -07:00
Todd C. Miller
41eae91206
If sudo_getgrouplist2() returns -1, clamp ngroups based on max_groups.
...
The ngroups parameter is an out parameter that is filled in with
the actual number of groups, which may be less than the static
number allocated when max_groups is set in sudo.conf.
Fixes a potential out of bounds read found by LLVM libFuzzer.
2021-02-13 11:54:21 -07:00
Todd C. Miller
e89a8133ac
Reset sudoers path, owner and mode before parsing plugin arguments.
...
This is only needed when calling sudoers_policy_deserialize_info()
more than once, which is true for the policy fuzzer.
2021-02-12 21:15:36 -07:00
Todd C. Miller
197d6600fa
Cleanup sudoers sources on denial and error too.
2021-02-12 19:52:11 -07:00
Todd C. Miller
520db741b5
Fix sudo_getgrgid reference count bug when gid doesn't exist.
...
This one was missed when the other user/group lookup functions
were fixed.
2021-02-12 19:27:47 -07:00
Todd C. Miller
df2931588a
Fuzz sudoers policy module API.
...
Includes a test case to reproduce CVE-2021-3156.
2021-02-12 15:36:18 -07:00
Todd C. Miller
ed79627699
Plug memory leak if there are duplicate user_info entries.
2021-02-12 19:04:37 -07:00
Todd C. Miller
eedc72d7b9
Make fuzz targets depend on fuzzer stub library.
...
We really want a dependency on $(LIB_FUZZING_ENGINE) but that could
be a flag like "-fsanitize=fuzzer" instead of a path.
2021-02-12 15:35:18 -07:00
Todd C. Miller
1f97ef92b7
Move audit.c from libparsesudoers to the sudoers module itself.
...
Now that audit.c contains the audit module it doesn't belong in
libparsesudoers.
2021-02-12 11:13:52 -07:00
Todd C. Miller
53e3dca7a6
Fix up some .la file library dependencies.
...
libsudo_iolog.la already depends on libsudo_util.la and libsudo_eventlog.la
so we don't need to list those explicitly when libsudo_iolog.la is listed.
2021-02-10 16:47:38 -07:00
Todd C. Miller
0663ffbc3f
Use sudo_basename() instead of doing the equivalent manually.
2021-02-10 15:14:08 -07:00
Todd C. Miller
cbf73e19bb
Portable workaround for getdelim(3) implementations modify buf on EOF.
...
We should assume that the contents of buf are undefined when getdelim(3)
returns -1. We now peek ahead one char and skip the getdelim(3) call if
EOF is detected. This will preserve the original value of the last line.
2021-02-09 18:23:23 -07:00
Todd C. Miller
cf18011466
Some getdelim(3) implementations write a NUL to the buffer on EOF.
...
AIX and Illumos appear to have this behavior. We now preserve the
first character of the buffer on EOF to work around this.
Fixes reporting of syntax errors on the last line of a file.
2021-02-09 09:06:17 -07:00
Todd C. Miller
1412695a4a
Fuzz the example sudoers file, not the default one.
...
The default sudoers uses @includedir which can result in different
output, depending on the permissions of /etc/sudoers.d.
2021-02-09 09:04:05 -07:00
Todd C. Miller
3d55bca8ac
Silence a clang analyzer false positive.
2021-02-08 16:06:08 -07:00
Todd C. Miller
aae168c485
Make open_sudoers() always return NULL like fuzz_sudoers.c
2021-02-08 14:20:40 -07:00
Todd C. Miller
19d8d4a549
Update *.toke.ok now that lexer doesn't call sudoerserror() itself.
2021-02-08 13:46:33 -07:00
Todd C. Miller
04de04f544
The lexer now sets an error string before returning ERROR.
...
The parser will use that when reporting on an ERROR state. This
prevents the lexer from reporting errors about tokens that are not
actually consumed by the parser and we don't have to worry about
both the lexer and the parser reporting errors. It also means we
only get one error per sudoers line.
2021-02-08 13:43:49 -07:00
Todd C. Miller
9325a342b5
Go back to storing the last error file/line in sudoerserrorf().
...
This is still the best way to avoid displaying more than one error
per line.
2021-02-08 08:00:04 -07:00
Todd C. Miller
63a3f62547
Add fuzz Makefile target and run fuzzer corpus in make check.
2021-02-08 04:56:17 -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
c19cb388bc
Add missing return statement when NO_LEAKS is not defined.
2021-02-07 13:37:21 -07:00