Commit Graph

3505 Commits

Author SHA1 Message Date
Todd C. Miller
1bcddb9602 Stub out pivot_root() and unpivot_root() for all but the sudoers module. 2023-02-21 14:46:27 -07:00
Todd C. Miller
8b9c1b962f Fix build when SUDOERS_NAME_MATCH is defined. 2023-02-21 13:47:27 -07:00
Todd C. Miller
b52631e877 Match using canonicalized directories where possible. 2023-02-21 13:24:33 -07:00
Todd C. Miller
0ef5373678 Add canon_path(), a realpath() wrapper that performs caching.
This also adds a new user_cmnd_dir variable that stores the
canonicalized parent directory of the command to be run.
2023-02-21 13:24:33 -07:00
Todd C. Miller
78ff514358 match_command: apply runchroot if set when matching the command
Previously we would prepend runchroot to the path we were checking
but that does not properly handle symbolic links.
2023-02-21 13:24:33 -07:00
Todd C. Miller
bff4e3ce16 set_cmnd_path: apply runchroot if set when finding the command path
Previously we would prepend runchroot to the path we were checking
but that does not properly handle symbolic links.
2023-02-21 13:24:33 -07:00
Todd C. Miller
13a311bc71 Add pivot_root() and unpivot_root() to switch the root dir and restore it.
This will be used to more accurately handling command resolution and
path matching when a new root directory is specified.
2023-02-21 13:24:33 -07:00
Todd C. Miller
a72bc5e6bf get_starttime: add support for GNU Hurd using the mach task_info call.
This is currently Hurd-specific but could be made Mach-generic as
long as the equivalent of pid2task() is available.
2023-02-19 07:18:37 -07:00
Todd C. Miller
0b000aab86 Only test get_starttime() on platforms where we support it.
Fixes a test failure on systems where we have no way to determine
a process's start time.
2023-02-18 11:46:33 -07:00
Todd C. Miller
2845ceafb0 Handle "locale -a" returning both C.UTF-8 and C.utf8.
It is possible to have mutiple matches from the output of "locale
-a".  Just take the first one.  Fixes GitHub issue #241.
2023-02-15 13:49:04 -07:00
Todd C. Miller
4f50692acc Add some missing files to the clean and distclean targets. 2023-02-15 10:22:42 -07:00
Todd C. Miller
a80dcc6aca Add compiled version of the sudoers Georgian translation. 2023-02-14 09:52:06 -07:00
Todd C. Miller
f1b07aed47 Regenerate .mo files. 2023-02-14 09:44:59 -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
26385b45cf Recover from missing include file unless error_recovery is disabled.
It is still treated as an error from a logging perspective, and
mail is still sent.
2023-02-09 15:33:58 -07:00
Todd C. Miller
8960f50961 Updated translations from translationproject.org 2023-02-03 10:26:24 -07:00
Todd C. Miller
b333d16878 Add eventlog_mail() to send a log message via mail.
This is used by mail_parse_errors() to send multi-line messages.
Previously, the newlines would be escaped as control characters.
2023-02-09 11:09:24 -07:00
Todd C. Miller
1758c49d3e Get rid of sudoersdir and just use sysconfdir.
There is no need for sudoersdir when it is always just set to sysconfdir.
2023-02-02 19:29:26 -07:00
Todd C. Miller
3c9c8668c1 Avoid compilation errors if getaddrinfo() or freeaddrinfo() are macros.
If this is the case we probably can't stub out the functions but
at least the fuzzer will compile.
2023-01-31 13:33:59 -07:00
Todd C. Miller
0b2e662b2e Protect use of AF_INET6 with HAVE_STRUCT_IN6_ADDR guards.
From Tim Rice.
2023-01-31 12:22:47 -07:00
Todd C. Miller
179ad08c86 Updated translations from translationproject.org 2023-01-27 14:46:52 -07:00
Todd C. Miller
ab9b20be9e New Georgian translation from translationproject.org 2023-01-26 13:29:31 -07:00
Todd C. Miller
de021b60db Update .pot files for 1.9.13 2023-01-24 13:11:47 -07:00
Todd C. Miller
2d9c0d9034 Add eventlog_store_sudo() and use it in sudoreplay.
This replaces the custom log formatting used by "sudoreplay -l".
2023-01-22 15:27:53 -07:00
Todd C. Miller
9ddae66818 Add support for the struct kinfo_proc on Dragonfly BSD. 2023-01-19 13:22:32 -07:00
Todd C. Miller
1e0bb704c2 Restore the line that set errno to ENOENT when find_path() fails.
This was inadvertently removed when the "goto bad" was added.
2023-01-19 10:08:38 -07:00
Todd C. Miller
e3583e01b8 The sample plugin is now built by default to avoid bit rot.
GitHub issue #234.
2023-01-19 07:38:51 -07:00
Todd C. Miller
4f9da47e55 The change from sudo_printf -> sudo_plugin_printf was incomplete.
Fixes GitHub issue #234.
2023-01-19 07:38:29 -07:00
Todd C. Miller
7ff70c09fe Update expected plugin version. 2023-01-18 13:53:33 -07:00
Todd C. Miller
0865e61d9e Pass back the number of files to edit when using sudoedit.
The sudo front-end can use this to determine where the list of files
to edit begins.
2023-01-18 13:38:15 -07:00
Todd C. Miller
334daf92b3 Escape control characters in log messages and "sudoreplay -l" output.
The log message contains user-controlled strings that could include
things like terminal control characters.  Space characters in the
command path are now also escaped.

Command line arguments that contain spaces are surrounded with
single quotes and any literal single quote or backslash characters
are escaped with a backslash.  This makes it possible to distinguish
multiple command line arguments from a single argument that contains
spaces.

Issue found by Matthieu Barjole and Victor Cutillas of Synacktiv
(https://synacktiv.com).
2023-01-18 08:21:34 -07:00
Todd C. Miller
0274a4f3b4 sudoedit: do not permit editor arguments to include "--" (CVE-2023-22809)
We use "--" to separate the editor and arguments from the files to edit.
If the editor arguments include "--", sudo can be tricked into allowing
the user to edit a file not permitted by the security policy.
Thanks to Matthieu Barjole and Victor Cutillas of Synacktiv
(https://synacktiv.com) for finding this bug.
2023-01-12 15:55:27 -07:00
Todd C. Miller
3878ce8d49 env_file_next_local: change the order of the val_len check.
It makes more sense to verify that val_len > 1 before using it.
This is not a problem in practice because val[val_len - 1] is
guaranteed not to underflow but it can confuse reviewers and static
analyzers.
2023-01-09 14:26:07 -07:00
Todd C. Miller
d781ab0a89 Fix typo in check for environment variables that start with '='. 2023-01-09 14:23:50 -07:00
Todd C. Miller
1f58e5a8e0 Fix IS_IDLOG macro, it was testing the wrong byte for the NUL.
This causes the macro to evaluate to false even for valid TSIDs.
2023-01-09 13:03:55 -07:00
Todd C. Miller
8309fbb970 sudoers_trace_print: this is a no-op if not debugging 2023-01-04 10:44:58 -07:00
Todd C. Miller
e5d98da014 Move hexchar() from the sudoers plugin to lib/util. 2023-01-03 15:50:42 -07:00
Sohom
761ffb3bfe Prevent integer underflow due to environment variable
Gaurd against replacing quotes when the environment variable
val_len is 1.
2023-01-02 11:47:52 +05:30
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
3f095ff1b5 Disable sudo_debug tests when fuzzing.
The debug code is disable when fuzzing is enabled to avoid coverage
issues.
2022-12-29 12:38:00 -07:00
Todd C. Miller
8a5e9ffb43 Plug memory leak. 2022-12-29 10:35:09 -07:00
Todd C. Miller
47a211f194 Update fuzz_policy keywords to match current policy settings. 2022-12-28 16:02:25 -07:00
Todd C. Miller
a7c1b78c67 Add example users and groups to the dictionary. 2022-12-28 16:02:10 -07:00
Todd C. Miller
8eabbf8fdd parse_args: an environment variable may not start with '='.
Also check VAR=val format in validate_env_vars() and add an error
message if insert_env_vars() fails.
2022-12-28 14:07:43 -07:00
Todd C. Miller
c820599893 rebuild_env: avoid a potential NULL dereference in fuzz_policy 2022-12-28 11:05:17 -07:00
Todd C. Miller
b69ffd3479 sudoers_policy_main: plug memory leak of iolog_path on error. 2022-12-28 10:50:51 -07:00
Todd C. Miller
8e8a22b8e5 rebuild_env: avoid a potential NULL dereference in fuzz_policy 2022-12-28 09:45:01 -07:00
Todd C. Miller
bca945f074 The contents of the env_add array should not include the leading "env=" prefix.
The previous fix for this was incomplete.
2022-12-28 09:25:41 -07:00
Todd C. Miller
9c4271f737 validate_env_vars: more efficient errbuf handling
Also avoid appending to errbuf if it is already full.
2022-12-28 09:24:22 -07:00
Todd C. Miller
fa1b86fca6 Remove the Python plugin import blocker code.
The sudo.conf file is considered a trusted source of information
and these checks suffer from TOCTOU issues anyway.
2022-12-26 07:43:55 -07:00