Commit Graph

9930 Commits

Author SHA1 Message Date
Todd C. Miller
db17cadaf6 Add an approval plugin type that runs after the policy plugin.
The basic idea is that the approval plugin adds an additional
layer of policy.  There can be multiple approval plugins.
2020-02-06 12:49:11 -07:00
Todd C. Miller
084cad2120 plugin documentation fixes:
o whitespace cleanup
 o show_version doesn't have an errstr argument
 o document runas_user and runas_group in command_info[]
 o add missing .El at before start of audit section
2020-02-06 12:18:09 -07:00
Todd C. Miller
404b28c4d0 Exported symbol is audit_json 2020-02-05 21:12:49 -07:00
Todd C. Miller
ea377e432b Silence lint warning. 2020-02-05 17:57:24 -07:00
Todd C. Miller
c2faa9e6ef Add runas_user and runas_group (if set) to command_info for audit plugin.
Otherwise, the audit plugin has to look up the runas name and group
by user or group ID.
2020-02-05 10:53:50 -07:00
Todd C. Miller
d219c64635 Only enable pwfeedback when reading password from /dev/tty.
This effectively disables pwfeedback when the -S or -A options are used.
2020-02-05 10:53:49 -07:00
Laszlo Orban
0ca2d1427b fixed compiler error when sudo is configured without --enable-openssl 2020-02-03 06:09:47 -07:00
Todd C. Miller
cec6b1708a Regenerate .man.in files from .mdoc.in 2020-02-02 16:13:05 -07:00
Todd C. Miller
b35cc96f0e Update documentation for setbase when the given base is NULL. 2020-02-02 16:12:39 -07:00
Todd C. Miller
658702b6d4 For plugin events, set the sudo event base for setbase(NULL).
This makes it possible for a plugin to change the event base
to a local one and then reset it back to its original value.
2020-02-02 12:37:11 -07:00
Todd C. Miller
49e7e4ecd5 Don't display "error in event loop" on loop break reading ServerHello.
We should already have displayed a more useful error message.
Otherwise, we can get two "error in event loop" warnings if
the TLS handshake fails (in addition to other error messages).
2020-02-01 08:32:27 -07:00
Todd C. Miller
b9bea25592 Read ServerHello message synchronously before the command is executed.
Otherwise, the command could be run before the TLS handshake completes.
2020-01-31 19:48:27 -07:00
Laszlo Orban
1e5562df93 Refactor sudo_sendlog in order to be able to send one I/O log multiple times in parallel (for testing purposes) 2020-01-31 13:45:13 -07:00
Todd C. Miller
790f8bb629 Document audit plugin in the sudo_plugin manual. 2020-01-30 20:57:40 -07:00
Todd C. Miller
1b7dc82fee Change audit close arguments to a type and value.
That way we can distinguish between different error types.
2020-01-30 17:05:27 -07:00
Todd C. Miller
bf85ea2bf7 Example audit plugin that writes JSON output to a log file. 2020-01-30 13:25:52 -07:00
Todd C. Miller
a88a05c1eb Adapt python plugin to new plugin API changes 2020-01-30 13:25:38 -07:00
Todd C. Miller
45e589d443 Pass back a failure or error string to the front end.
The audit_failure() function now stores the failure string.
This will allow an audit plugin to log the reason if the user's
request is a rejected.
2020-01-30 13:25:36 -07:00
Todd C. Miller
22105009d8 Define a new plugin type that receives accept and reject messages.
This can be used to implement logging-only plugins.
The plugin functions now take an errstr argument that can be used
to return an error string to be logged on failure or error.
2020-01-30 13:25:34 -07:00
Todd C. Miller
88f9f2ba9a Add a simple API for writing JSON records.
To be used by the upcoming JSON audit module.
2020-01-30 13:12:25 -07:00
Todd C. Miller
ed294b8283 Add code to generate universally unique identifiers.
We create type 4, variant 1 uuids (random).
2020-01-30 13:12:25 -07:00
Todd C. Miller
dc45c4d4ea Add tests for arc4random_buf() and an implementation for those without. 2020-01-30 13:12:25 -07:00
Todd C. Miller
df2e3f7c7f Sudo 1.8.31 changes. 2020-01-29 20:26:32 -07:00
Todd C. Miller
fa8ffeb175 Fix a buffer overflow when pwfeedback is enabled and input is a not a tty.
In getln() if the user enters ^U (erase line) and the write(2) fails,
the remaining buffer size is reset but the current pointer is not.
While here, fix an incorrect break for erase when write(2) fails.
Also disable pwfeedback when input is not a tty as it cannot work.
CVE-2019-18634
Credit: Joe Vennix from Apple Information Security.
2020-01-29 20:15:21 -07:00
Todd C. Miller
0fcb647160 Check for presence of fseeko() regardless of utmp type. 2020-01-28 13:00:54 -07:00
Todd C. Miller
604945f93e Fix warning about unresolved host name with "sudo -l -h hostname".
The resolve_host() function returns 0 on success, not bool.
2020-01-28 13:00:54 -07:00
Todd C. Miller
4e87e1a97b Fix typo in a test: python_policy->close not python_io->close 2020-01-28 13:00:33 -07:00
Robert Manner
f268e851d7 plugins/sudo_python_module: Fix double free in sudo.options_as_dict function
PyArg_ParseTuple sets the py_config_tuple pointer, but it does not
increment the reference count, so by decrementing, we end up freeing
the argument passed in.
2020-01-28 07:20:44 -07:00
Todd C. Miller
9d69c4a022 Allow getentropy.c to compile when MAP_ANON is unavailable. 2020-01-28 06:59:16 -07:00
Todd C. Miller
13cc65038f Remove multi-thread support from arc4random.
Sudo is not multi-threaded so we don't need the added complexity.
2020-01-28 06:41:42 -07:00
Todd C. Miller
aa7ea419f0 Backed out changeset 9dce3ebb2c37
MAP_SGI_ANYADDR cannot be used in place of MAP_ANON
2020-01-28 05:49:41 -07:00
Todd C. Miller
1fd82e1499 Fix compilation on IRIX; Bug #915
IRIX lacks MAP_ANON (and MAP_ANONYMOUS) but we can use the IRIX-specific
flag MAP_SGI_ANYADDR instead.  From Kazuo Kuroi
2020-01-27 16:14:57 -07:00
Robert Manner
22c64f58c0 plugins/python: use separate python interpreter for each plugin
On each plugin initialization we create a separate python interpreter
which gets stored in the plugin_ctx. The main interpreter is
stored in py_ctx and is used for creating more interpreters (if more plugins
get loaded) and final python deinitialization.

The "traceback" module import and the ImportBlocker initialization was
moved, because it has to happen inside the plugin specific interpreters.
2020-01-24 12:25:15 -07:00
Robert Manner
99f8394182 plugins/python/regress: add a failing textcase about python plugins affect each other
Since python plugins are run inside the same interpreter, they affect
each other's state, which would be better to avoid.
2020-01-24 12:25:15 -07:00
Todd C. Miller
5472b17516 Fix crash in sudo 1.8.30 when suspending sudo at the password prompt.
The closure pointer in sudo_conv_callback was being filled in with
a struct getpass_closure ** instead of a struct getpass_closure *.
The bug was introduced in the fix for Bug #910; previously the
closure variable was a struct getpass_closure, not a pointer.
Fix from Michael Norton; Bug #914.
2020-01-24 11:13:55 -07:00
Robert Manner
9294108cd6 doc/sudo_plugin_python: update doc about the multiple I/O plugin loading 2020-01-23 12:46:14 -07:00
Robert Manner
d3d3a59e08 plugins/python/Makefile.in: update autogenerated header dependencies 2020-01-23 12:46:14 -07:00
Robert Manner
d67c64bb37 plugins/python/pyhelpers: have a default sudo_printf function
Adapted the default sudo_printf from sudoers plugin to be able to print
errors before plugin open() gets called. (This is used by the multiple io
plugin loading to display error for too much plugin load.)

Since this makes us always have a sudo_log, I have removed the logic about
whether it is available or not.
2020-01-23 12:46:14 -07:00
Robert Manner
74f559155a src/load_plugins.c: plugins can supply a clone function
if they want to support getting loaded multiple times.
2020-01-23 12:46:14 -07:00
Robert Manner
2eeda38f95 plugins/python/regress: add a testcase for multiple io plugin loading
to verify 2 python plugins can work next to each other.
2020-01-23 12:46:14 -07:00
Robert Manner
3128cc97ca plugins/python: fix return value typo for the error case 2020-01-23 12:46:14 -07:00
Robert Manner
304a7fdc1f plugins/python/plugin_io: enable loading of multiple io plugins
Separate sudo io plugin symbols are created which stores wrapper
functions adding the context of which python plugin the callback is
about.

These sudo io plugin "slots" get generated with macros by the preprocessor.

This makes sudo support loading multiple python IO plugins like this:
(note the differences in the symbol names)

Plugin python_io python_plugin.so ModulePath=... ClassName=SudoIOPlugin1
Plugin python_io1 python_plugin.so ModulePath=... ClassName=SudoIOPlugin2
Plugin python_io2 python_plugin.so ModulePath=... ClassName=SudoIOPlugin3
2020-01-23 12:46:14 -07:00
Robert Manner
edd7356f2a plugins/python/Makefile.in: remove path prefix from examples to make install target work 2020-01-23 12:46:14 -07:00
Todd C. Miller
f4716a75e4 Document new tls_verify setting. 2020-01-23 11:42:08 -07:00
Laszlo Orban
24c9438486 logserver option to disable certificate verification on server side and server authentication on client side 2020-01-23 10:12:12 -07:00
Laszlo Orban
9935a7e2ff Rename tls_checkpeer to tls_reqcert in ServerHello message 2020-01-23 10:12:12 -07:00
Todd C. Miller
c9b68ccb34 Use AC_CHECK_DECLS when checking for SSL_CTX_set_min_proto_version
Also use AC_CHECK_FUNCS to check for the other OpenSSL functions
2020-01-23 09:38:09 -07:00
Todd C. Miller
fb5fc9876a Refactor code to allocate and fill struct plugin_container.
This will help avoid duplicate code in the audit and approval plugins.
2020-01-22 12:35:44 -07:00
Todd C. Miller
07a2965bab Document TCP keepalive options in the manual pages. 2020-01-22 11:07:01 -07:00
Laszlo Orban
6f3f45aa24 sudoers: disable SO_KEEPALIVE socket option based on log_server_disable_keepalive flag in sudoers 2020-01-22 10:52:18 -07:00