Commit Graph

12802 Commits

Author SHA1 Message Date
Todd C. Miller
392f0d61cb Make path_plugin_dir private to policy.c and add getter. 2023-08-13 17:05:00 -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
d148e7d8f9 fd_matches_tty: only zero out fd_sb if fstat(2) fails.
We need to preserve the contents of the struct stat if the fd is
some other type so the check for piped output works correctly.
Bug #1057
2023-08-12 10:39:33 -06:00
Todd C. Miller
6f659e2deb Leave the I/O log callbacks in iolog.c
Otherwise, check_iolog_plugin will not link.
2023-08-10 16:20:18 -06:00
Todd C. Miller
603148e7f2 Move sudoers parser callbacks to callbacks.c. 2023-08-10 15:49:30 -06:00
Todd C. Miller
cc15f847ac Bump info_msgs_size to make room for the source. 2023-08-09 16:14:52 -06:00
Todd C. Miller
ee5cab977f Update Xcode version from 13.2.1 to 13.4.1. 2023-08-09 13:54:16 -06:00
Todd C. Miller
811051d32a Use int, not short for events in the event API.
This fixes some -Wconversion warnings and fixes an inconsistency
between the libsudo_util event API and the plugin event API.  The
actual struct internals still use shorts to avoid changing the ABI.
2023-08-09 13:22:12 -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
6842dd1bfd Document "sudo -ll command" output. 2023-08-09 10:57:16 -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
f6291bf83e Move code to display a cmndspec in long form to display_cmndspec_long(). 2023-08-09 09:58:24 -06:00
Todd C. Miller
5a1a3ff74b sudo -ll: display the sudoers file the rule came from. 2023-08-09 08:50:56 -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
0b03511b85 Log source in JSON logs
This makes it possible to tell which rule resulted in a match.
2023-08-08 09:56:19 -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
1e6c5f3e79 Fix checking of SSL_{read,write}_ex() return value.
These have a boolean-style return value.  However, our emulated
versions can return -1 on error, which we need to preserve for older
versions of SSL_get_error() which expect it.
2023-08-08 10:18:57 -06:00
Todd C. Miller
5f2a0a70e5 Fix printf format string mismatch now that 'i' is size_t. 2023-08-07 11:31:04 -06:00
Todd C. Miller
77f94f291a sudo_digest_getlen: return size_t, and 0 on error instead of -1
This is an API change, sudo_digest_getlen_v1 remains for binary
compatibility.
2023-08-07 08:43:13 -06:00
Todd C. Miller
184e03b4a9 ERR_get_error() returns unsigned long, not int. 2023-08-07 08:05:00 -06:00
Todd C. Miller
861ed2b7d4 We now must pass "err" SSL_get_error(), not "nread". 2023-08-07 07:59:58 -06:00
Todd C. Miller
e5f2354c85 Move compat definition of ASN1_STRING_get0_data to hostcheck.c.
It is not used anywhere else.
2023-08-06 14:26:24 -06:00
Todd C. Miller
fc7bfd5046 Move OpenSSL compat defines to sudo_ssl_compat.h 2023-08-05 14:16:39 -06:00
Todd C. Miller
d6d467b92e Add implementation of SSL_read_ex/SSL_write_ex for those without. 2023-08-05 10:38:02 -06:00
Todd C. Miller
e6d14c95b6 Use SSL_read_ex() and SSL_write_ex() instead of SSL_read() and SSL_write(). 2023-08-05 10:38:01 -06:00
Todd C. Miller
d404f544fc Don't use sudo when building AIX packages
PolyPkg uses "sudo installp -l" to list the built package by default
but we may not have sudo privileges on the build host.
2023-08-01 11:20:54 -06:00
Todd C. Miller
002e22f846 Add --configure-only option to quit after the configure run.
This will be used to avoid building the entire package when we just
want the 32 or 64 bit sudo_intercept.so and sudo_noexec.so.
2023-08-01 11:05:59 -06:00
Todd C. Miller
8e22ede2a6 Parse --disable-python in mkpkg and don't override -m32 for Solaris.
We want to be able to build without python and to specify the memory
model when building 32-bit .so's for Solaris.
2023-08-01 09:36:39 -06:00
Todd C. Miller
0a181849a1 Add --enable-postinstall, an optional phase when building packages.
This makes it possible to run an arbitrary script between "make
install" and the polypkg run.  This will be used to copy different
word size versions of sudo_intercept.so and sudo_noexec.so.
2023-07-31 19:46:00 -06:00
Todd C. Miller
980e0216ac Add basic support for 32-bit and 64-bit LD_PRELOAD equivalents.
The noexec and intercept DSO settings may now include both a 32-bit
DSO and a 64-bit DSO specified by a colon.  For example:
/usr/libexec/sudo/sudo_intercept.so:/usr/libexec/sudo/sudo_intercept_64.so.
2023-07-31 13:46:57 -06:00
Todd C. Miller
7cb1f7f3a9 Cast TIOCSWINSZ to int to avoid overflow warning on 64-bit AIX. 2023-07-31 09:58:13 -06:00
Todd C. Miller
961f23af94 Read path section of sudo.conf for sudo_conf_intercept_path(). 2023-07-28 19:31:19 -06:00
Todd C. Miller
bdde6dfa11 visudo: document that a new file is only created if the editor writes it.
If visudo is used to create a new file, the file will only be created
if the user writes to the file via the editor.  Simply running
visudo and exiting the editor will no longer cause the file to be
created.  There is an exception for file created due to the addition
of a @include directive, which need to be present for the sudoers
file to parse properly.  GitHub issue #294.
2023-07-27 11:32:56 -06:00
Todd C. Miller
4f3786f70f visudo: do not create a new file if the user made no changes
This prevents visudo from creating a new zero-length sudoers file
if the user exited the editor without making any changes.  Files
created via a @include directive are preserved, even if empty, to
avoid a parse error.  GitHub issue #294.
2023-07-27 11:23:25 -06:00
Todd C. Miller
50fde5d815 Make the sections on bug reporting consistent with each other.
GitHub issue #292
2023-07-27 09:51:57 -06:00
Todd C. Miller
857653f9f5 Remove unused variable introduced in last commit. 2023-07-26 19:49:25 -06:00
Todd C. Miller
760c9c1107 Don't assume that if std{in,out,err} is a tty, it is the user's tty.
Previously, sudo only checked that the fd was a terminal, not that
it matched sudo's idea of the user's terminal.  This matters when
input or output is redirected to a different terminal.  In that
case we want to interpose the fd with a pipe even if it refers to
a terminal.  Bug #1056.
2023-07-26 19:43:49 -06:00
Todd C. Miller
14f1a12e2d testsudoers: add -L, -l and -v tests 2023-07-26 13:59:33 -06:00
Todd C. Miller
d62d704e55 testsudoers: display when a password is required 2023-07-26 11:14:45 -06:00
Todd C. Miller
75256516bd testsudoers: add -L, -l and -v options.
This makes it possible to test "sudo -l" and "sudo -v" using
testsudoers.
2023-07-26 10:37:52 -06:00
Todd C. Miller
538be58ac0 sudoers_lookup_pseudo: sync with sudoers_lookup_check
This makes sudoers_lookup_pseudo(), which is used for pseudo-command
like "list" and "validate" a bit more like sudoers_lookup_check().
Time of day checks are performed, and callbacks are supported.  We
cannot use the same code for regular commands and pseudo-commands
due to the "pwcheck == all" case.
2023-07-25 15:57:20 -06:00
Todd C. Miller
d486db46cf Fix user warning message for "sudo -l command" when not allowed.
Reported by the sudo-rs project.

There was a missing space between "list" and the actual command.
This also changes the output to include the command as specified
by the user, not the path found in the path.  Previously, if the
command did not exist it would not be included in the message.
2023-07-25 13:56:08 -06:00
Todd C. Miller
1a00423afd Add free function for sudo Python module.
This reduces the amount of memory leaked on unload.
2023-07-25 09:33:03 -06:00
Todd C. Miller
e59c487434 Document bug fixes in 1.9.14p3. 2023-07-24 14:24:18 -06:00
Todd C. Miller
09b9632699 Merge sudo_module_register_loghandler and sudo_module_set_default_loghandler.
We now create the LogHandler class for each interpreter in
python_plugin_init() instead of just once in sudo_module_init().
This fixes the crash seen in Py_EndInterpreter() with Python 3.12
and significantly reduces the number of leaked objects tracked by
MemorySanitizer.
2023-07-24 11:07:45 -06:00