Commit Graph

2553 Commits

Author SHA1 Message Date
Robert Manner
383ca80333 plugins/python/regress/testdata: generated data for the pyplugin tests 2020-01-20 06:30:20 -07:00
Robert Manner
5da7bd562c plugins/python/regress: adds tests for python plugin feature and examples 2020-01-20 06:30:20 -07:00
Robert Manner
0b2d0334b7 plugins/python/example_policy_plugin.py: extend user env changing example
Make the demonstration extend the environment with a new variable.
Easier to read, and makes the testing able to check for that it is working.
2020-01-20 06:30:20 -07:00
Robert Manner
185471f263 plugins/python/python_plugin_policy: fix validate() call
When calling validate() python function, TypeError exception was thrown
("argument list must be a tuple"), because the call does not have
arguments, and python does not accept empty tuple for execution. NULL
must be used instead, which was handled as argument construction failure
previously.
2020-01-20 06:30:20 -07:00
Robert Manner
35c85596d7 plugins/python/example_policy_plugin.py: make allowed_commands ordered
Storing them as "tuple" instead of "set", so they have a fix order.
This makes the output of the list() example stable. ("set" is printed out
in random order)
2020-01-20 06:30:20 -07:00
Robert Manner
2ee1dd3ec3 plugins/python: fix confusing version display
IO/Group/Policy Python API version is displayed instead of sudo version,
because that is not very meaningful in this context.

They are only displayed in verbose mode.

Example plugins express it more concrete that they are displaying their
version, not the API version.
2020-01-20 06:30:20 -07:00
Robert Manner
87d76f4bbc plugins/python/example_conversation.py: make log path configurable
Similarly to IO plugin example. (It is easier to test it this way.)
2020-01-20 06:30:20 -07:00
Robert Manner
591d57ad28 plugins/python/example_io_plugin.py: fix backtrace during destructor
If the plugin fails to open the file for writing, constructor will raise
an exception and exit before creating the "_log" member variable.
So the destructor will also raise a backtrace. (Which python ignores, but
dumps out to stderr.)
2020-01-20 06:30:20 -07:00
Robert Manner
5be81eb25b plugins/python/python_plugin_common: raise debug level for module import 2020-01-20 06:30:20 -07:00
Robert Manner
8eab169098 plugins/python/example_debugging: fix typo in comment 2020-01-20 06:30:20 -07:00
Todd C. Miller
47d9504716 Add debugging statements to certificate checks. 2020-01-18 12:57:24 -07:00
Todd C. Miller
5a86073bd0 Portability fixes and correct path to hostcheck.h in MANIFEST.
Include sys/socket.h for getpeername().
Link with -lnsl on Solaris to get inet_pton().
2020-01-18 11:32:45 -07:00
Todd C. Miller
d2b7148b6c Using "libtool --clean" to remove regular files is slow.
We only need to use libtool's clean mode to remove files created by libtool.
2020-01-18 05:53:55 -07:00
Laszlo Orban
a6916c2199 do server identity validation in iolog plugin 2020-01-18 05:49:54 -07:00
Laszlo Orban
de02745a3f save a pointer to the currently connected audit server in the closure object 2020-01-18 05:49:54 -07:00
Todd C. Miller
36b3362b99 Fix TLS connect when SSL_connect returns SSL_ERROR_WANT_READ.
We need to switch from SUDO_EV_WRITE to SUDO_EV_READ for this case.
Also make the tls connect events private to tls_timed_connect()
with their own closure.  There is no need to store them in the
client closure.
2020-01-16 17:37:45 -07:00
Todd C. Miller
161750fc56 Really fix flushing of data in client_close().
Now that we call fmt_exit_message() from client_close() we do not
need to try to determine whether the read or write events were
pending in the old base.

We can't tell anyway because the active flag in the event was cleared
when the old sudo event base was destroyed.  It is correct to enable
both the read and write events after formatting the ExitMessage.
2020-01-15 14:47:42 -07:00
Todd C. Miller
bbb9520c3a Use SUDOERS_DEBUG_* not SUDO_DEBUG_* in debug_decl() for the sudoers plugin. 2020-01-15 14:11:18 -07:00
Todd C. Miller
e7eef9c3a5 Fix reference counting when both sudoers policy and I/O log are loaded.
If both sudoers policy and I/O log plugins are loaded, debug_files
will be empty when the I/O plugin is initialized.  This changes the
logic to always increase the reference count if the instance is valid.
2020-01-14 17:50:40 -07:00
Todd C. Miller
3fddfedb53 Remove MAXSYSLOGTRIES, it is no longer used. 2020-01-09 13:59:51 -07:00
Todd C. Miller
586b418ad8 Sanity check size when converting the first record to TS_LOCKEXCL
Coverity CID 206591
2020-01-05 09:37:09 -07:00
Todd C. Miller
3e0dcae6c9 Use canonical pattern when freeing a tail queue.
Avoids some coverity false positives when using TAILQ_FOREACH_SAFE
to free the tail queue.
2020-01-05 07:48:46 -07:00
Todd C. Miller
b3c5efd48e Avoid potential NULL deref in tls_timed_connect() error path.
Coverity CID 206396
2020-01-03 04:52:58 -07:00
Robert Manner
972ea1448e plugins/sudoers/sudoers_debug.c: fix harmless debug deregistration warning
If the debug sudoers subsystem is not registered, because it does not
get any file names to deal with (TAILQ_EMPTY(debug_files)), deregistration
of the subsystem outputs a warning:

  sudo: sudo_debug_deregister_v1: invalid instance ID -1, max -1

This patch prevents that by only increasing the refcount if the
debug_instance was registered successfully.
2020-01-02 11:53:08 -05:00
Robert Manner
3e9d15a4da plugins/python/Makefile.in: fix the install path of examples
Examples are installed by default to "docdir", which refers to
PACKAGE_TARNAME variable which was empty for the python plugin Makefile.in

So the examples were installed to '.../share/doc/examples' instead
of '.../share/doc/sudo/examples'. This also made them be skipped from the
package.

Also the install target now depends on install-doc so the examples
gets installed also (similarly as other examples).
2020-01-02 11:53:08 -05:00
Todd C. Miller
047f37ade3 Restore check for readable /etc/sudoers in pre-install target.
If there is no installed sudoers there is nothing to check...
2019-12-25 12:15:03 -07:00
Todd C. Miller
58d50f44cd Support systems that have nl_langinfo(3) but not the CODESET define.
Fixes compilation on old NetBSD versions.
2019-12-25 11:14:18 -07:00
Todd C. Miller
8b571c59a5 Fix a typo; HAVE_KINFO_PROC2_NETBSD not HAVE_KINFO_PROC2_NETBSD2 2019-12-25 11:12:21 -07:00
Todd C. Miller
486ee2b71f debug_decl and debug_decl_vars now require a semicolon at the end. 2019-12-22 08:48:16 -07:00
Todd C. Miller
4392b5726e Output the name of the limit when warning about setrlimit or getrlimit.
From Kimmo Suominen.
2019-12-18 09:42:14 -07:00
Robert Manner
4ad362dd8f plugins/python: example plugin demonstrating conversation and debug API 2019-12-14 12:55:42 -07:00
Robert Manner
523bcbedb6 plugins/python: add example python group plugin 2019-12-14 12:55:42 -07:00
Robert Manner
d8432fca34 plugins/python: add example python policy plugin 2019-12-14 12:55:42 -07:00
Robert Manner
ee856cc4ba plugins/python: add example io python plugin 2019-12-14 12:55:42 -07:00
Robert Manner
91e6bf8ccd Makefile.in, configure.ac: add python plugin build 2019-12-14 12:55:42 -07:00
Robert Manner
d888d44594 plugins/python: make group plugin able to debug
It does not get the debug settings, so it looks them up through
sudo_conf.
2019-12-14 12:55:42 -07:00
Robert Manner
9b49d44e84 plugins/python: add a sudo python module 2019-12-14 12:55:42 -07:00
Robert Manner
a6bac23bab plugins/python: add ImportBlocker which forbids loading unsafe python modules
If non root can alter any imported python modules, he is able to run
anything he would like to as root user.
This class is a helper to avoid such situation.

This feature can be disabled with 'DeveloperMode=1' plugin option.
2019-12-14 12:55:42 -07:00
Robert Manner
babdcbd031 plugins/python: a plugin which can load policy/io plugin written in python 2019-12-14 12:55:42 -07:00
Robert Manner
311cf122e2 plugins/python: add sudo debug helpers 2019-12-14 12:55:42 -07:00
Robert Manner
c0d53d75eb src/load_plugins, plugins/sudoers: added developer_mode sudo.conf option
It can be used to disable the enforcement that a plugin (shared object or
an imported python module) must be owned by root and not modifiable by
others.
This can make plugin development easier.
2019-12-14 12:55:42 -07:00
Todd C. Miller
3ec23ad5e1 Minor style cleanups.
Remove extraneous break after return statement.
Convert two old K&R function declarations.
2019-12-13 19:27:38 -07:00
Todd C. Miller
b14d633ec6 Add runas_check_shell flag to require a runas user to have a valid shell.
Not enabled by default.
2019-12-09 19:29:45 -07:00
Todd C. Miller
df8f06609c Add a new flag "allow_unknown_runas_id" to control matching of unknown IDs.
Previous, sudo would always allow unknown user or group IDs if the
sudoers entry permitted it.  This included the "ALL" alias.
With this change, the admin must explicitly enable support for unknown IDs.
2019-12-09 17:14:06 -07:00
Todd C. Miller
9d737441f4 Fix event loop called via I/O log close function.
We need to set events that were pending in the old base in the new one.
Fixes sending the final I/O log data and the ExitMessage to the server.
2019-12-07 08:42:12 -07:00
Todd C. Miller
bf3b93f080 Use sudo_ev_pending() instead of the deprecated sudo_ev_timeleft(). 2019-12-07 08:42:09 -07:00
Todd C. Miller
9314072848 Add TLS libs when linking check_iolog_plugin 2019-12-07 08:38:08 -07:00
Todd C. Miller
5711c1b497 Remove extraneous newlines in some sudo_warnx() calls. 2019-12-06 13:37:22 -07:00
Todd C. Miller
4b6de608c2 Only update the time stamp entry after the approval function has succeeded.
Bug #910
2019-12-04 12:38:22 -07:00
Todd C. Miller
7c782edf53 Only deregister the sudoers debug instance on last close.
Reference count calls to sudoers_debug_register and only deregister
sudoers_debug_instance when refcnt reaches 0.
Fixes a problem where the debug system was deregistered when the
sudoers policy is closed even though the iolog plugin is active.
2019-12-03 20:03:07 -07:00