Todd C. Miller
b6175b78ad
Remove EVLOG_JSON, callers must use EVLOG_JSON_COMPACT or EVLOG_JSON_PRETTY
2024-03-09 11:42:07 -07:00
Todd C. Miller
46e31a74d7
Add "json_pretty" log format, currently the same as "json".
...
In a future version, "json" will be an alias for "json_compact"
instead. GitHub issue #357 .
2024-03-09 10:59:54 -07:00
THE-Spellchecker
5eba4b48cf
Typographical and Grammatical fixes
2023-11-28 15:00:04 -07:00
Todd C. Miller
886f1414eb
Move the check for running setid commands in intercept mode to later.
...
Checking for setid commands in intercept mode after command matching
allows us to log a proper error message. Previously, we simply
ignored setid commands when matching and the only indication of why
was in the debug logs.
2023-11-02 13:44:17 -06:00
Todd C. Miller
392ae0f030
Avoid a double-free in fuzz_policy caused by the early env_init(NULL).
...
This adds an env_free() function to explicitly free both the old
and new copies of the environment. It is really only needed by
fuzz_policy, which calls the policy module multiple times.
2023-10-22 09:56:16 -06:00
Todd C. Miller
726b646b48
struct eventlog: rename argv/env to runargv/runenv.
...
This matches the JSON logs.
2023-10-21 19:15:46 -06:00
Todd C. Miller
c7a61a9438
struct sudoers_user_context: rename env_vars to env_add
2023-10-21 19:15:45 -06:00
Todd C. Miller
077826292c
Free the private copy of the environment in sudoers_check_cmnd().
...
This reverts 5118eb5797fb, which had the side-effect of the PAM
session code running with the run environment instead of the invoking
user's environment. Issue #318
2023-10-21 19:15:42 -06:00
Todd C. Miller
e343e07543
Use #include <foo.h> instead of #include "foo.h" in most cases.
...
We rely on the include path to find many of these headers. It
especially doesn't make sense to use #include "foo.h" for headers
in the top-level include directory.
2023-09-25 10:13:28 -06:00
Todd C. Miller
f2d267bfb4
Only define _PATH_ENVIRONMENT on systems where we use /etc/environment.
2023-09-20 16:49:27 -06:00
Todd C. Miller
6e75f2311d
Add resolve_cmnd(), a wrapper around find_path().
...
This is a convenience function that sets PERM_RUNAS and calls
find_path(). If the command is not found it will retry with PERM_USER
instead.
2023-09-18 12:42:51 -06:00
Todd C. Miller
51d6b0f425
Promote verbose flag to int for display_privs and display_cmnd.
...
A negative verbosity will prevent non-error output from being
displayed.
2023-09-15 10:01:35 -06:00
Todd C. Miller
34990c0e08
Use struct sudoers_pivot instead of defining sudoers_pivot_t.
...
We want to pass around a pointer, not the struct itself.
2023-09-13 08:36:07 -06:00
Todd C. Miller
0b52ffd1a2
Don't expose the implementation of the pivot_root state.
2023-09-11 16:15:41 -06:00
Todd C. Miller
c54bdd799b
Return AUTH_* flags from check_user() instead of 1/0/-1.
2023-09-09 14:59:46 -06:00
Todd C. Miller
d18ee8e0e7
Move check_user_shell() to pwutil.c as user_shell_valid()
...
This will make it possible to support a different backend which may
be used by testsudoers in the future.
2023-09-09 14:07:28 -06:00
Todd C. Miller
d898d073bf
Only print "no valid sudoers sources found, quitting" for multiple sources.
...
If there is only a single source (usually the sudoers file), the
open function provide enough of an error message. Printing two
error messages is just confusing.
2023-08-31 14:05:08 -06:00
Todd C. Miller
75209e2718
Rename check.h -> timestamp.h and add remaining timestamp.c prototypes.
2023-08-29 11:16:23 -06:00
Todd C. Miller
3c05e748a4
Add ignore_perms plugin argument to skip the sudoers file security checks.
...
This is not intended to be used in a production environment.
2023-08-29 09:55:09 -06:00
Todd C. Miller
30fc288291
Move tty_present() into policy.c as sudoers_tty_present().
...
This function is policy-dependent. For the modern sudo front-end
it will simply check tcpgid and/or ttypath.
2023-08-25 11:19:42 -06:00
Todd C. Miller
522ac12f21
No need to inclue auth/sudo_auth.h
2023-08-23 14:27:19 -06:00
Todd C. Miller
c7157ce0b1
Move a few fields from sudoers_user_contect to sudoers_context.
...
They are not really specific to the user or user-specified.
2023-08-21 15:30:12 -06:00
Todd C. Miller
ff5914d7f7
Move sudoedit_nfiles into struct sudoers_context.
2023-08-21 10:47:25 -06:00
Todd C. Miller
3473bf9360
Move sudo_mode into struct sudoers_context.
2023-08-21 10:47:23 -06:00
Todd C. Miller
837da1bef0
Move NewArgv, NewArgc and saved_argv into struct sudoers_context.
2023-08-21 09:22:24 -06:00
Todd C. Miller
87571dab0a
Add struct sudoers_conf to struct sudoers_plugin_context.
...
There's now no need to pass this directly to init_parser() since we
already pass in a pointer to a sudoers_context struct.
2023-08-21 09:21:54 -06:00
Todd C. Miller
9e53d903ea
Store policy paths in struct sudoers_context.
...
This removes the need for the getters in policy.c.
2023-08-21 09:21:53 -06:00
Todd C. Miller
bbaf293912
Add sudoers_ctx_free() and use it for freeing struct sudoers context.
...
This replaces sudoers_user_ctx_free() and sudoers_runas_ctx_free().
2023-08-21 09:21:52 -06:00
Todd C. Miller
2440174954
Make struct sudoers_context private to sudoers.c.
...
We now pass a pointer to the context where necessary. There are a
few cases where we need to request the context from sudoers via
sudoers_get_context() for the plugin API functions. If the plugin
API was able to pass around a closure pointer this would not be
necessary.
2023-08-21 09:21:49 -06:00
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
737354390c
Pass in directory to check_user_runchroot() and check_user_runcwd().
...
This way we do not rely on the runas_ctx global.
2023-08-14 13:25:13 -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
930ca00252
Pass explicit struct passwd * to create_admin_success_flag().
2023-08-12 10:39:49 -06:00
Todd C. Miller
30c49288f7
Make sudoers_user_ctx_free() private to sudoers.c
2023-08-12 10:39:48 -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
603148e7f2
Move sudoers parser callbacks to callbacks.c.
2023-08-10 15:49:30 -06:00
Todd C. Miller
0f2e5dae90
Use const pointers where possible in the display code.
2023-08-09 11:19:17 -06:00
Todd C. Miller
60eef27e6d
Add verbose version of "sudo -l command" by using an extra -l.
...
The output of "sudo -ll command" consists of the matching sudoers
rule (in long form) with the addition of a "Matched" entry that
shows the fully-qualfied path along with any arguments.
2023-08-09 10:16:10 -06:00
Todd C. Miller
e178b85821
Store the source of the matching rule and store in the event log.
...
The JSON logs will store the matching rule source.
2023-08-08 09:57:09 -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
fa66c16689
sudoers_check_common: MODE_PRESERVE_ENV is not valid with MODE_CHECK.
...
We should only check for MODE_PRESERVE_ENV when running a command.
2023-07-17 10:52:23 -06:00
Todd C. Miller
cbcb1d2506
sudoers plugin: make more bit flags unsigned.
2023-07-10 11:06:23 -06:00
Todd C. Miller
a38b714667
sudoers plugin: silence most -Wconversion warnings.
2023-07-07 15:07:04 -06:00
Todd C. Miller
0205f6fc75
sudoers_check_common: remove extraneous return statement.
2023-07-07 14:54:10 -06:00
Todd C. Miller
01ad570e24
Move check_user_* functions to check_util.c so testsudoers can use them.
2023-06-30 10:43:18 -06: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
1c7a20d744
check_user_runcwd: only allow sudo's -D option if sudoers specifies a runcwd.
...
Previously, the user could specify the runas user's home dir for
"sudo -i" or the user's existing cwd when -i is not specified.
This behavior was never documented and is inconsistent with how
the -R option is handled.
2023-06-29 11:24:04 -06:00
Todd C. Miller
e7d4c05ace
check_user_runcwd: allow -D option if it matches the cwd in sudoers
...
Previously, check_user_runcwd() would return true if the runcwd
matched the user's cwd, even if sudoers specified a different one.
The user-specified runcwd was ignored but it is better to error out
in this case. It is now also possible to use "sudo -D" with the
directory specified in sudoers.
2023-06-28 09:59:33 -06:00