Commit Graph

10143 Commits

Author SHA1 Message Date
Todd C. Miller
a3e94aefa3 Bug #922 and Bug #923 2020-05-05 13:36:05 -06:00
Todd C. Miller
6901fc97ac Add a ClientHello message that client sends to the server.
This makes it easier to detect a plaintext client sending to a
TLS port.  Without this, the TLS server will be silent as it
waits for the client to initiate the TLS connection.
2020-05-05 13:23:26 -06:00
Todd C. Miller
1e765e1caf Better error messages when there is a problem with the TLS connection.
If SSL_read, SSL_write or SSL_connect fails we can use the reason
string to let the user know what the problem is.
2020-05-05 13:23:26 -06:00
Todd C. Miller
1f8da42f9a Warn about tls errors during startup so the user has a clue.
We write messages to stderr until we become a daemon.
2020-05-05 13:23:26 -06:00
Todd C. Miller
e5f8214c0a Remove the tls parameter from the ServerHello message.
The TLS connection is now initiated before ServerHello is received.
2020-05-05 13:23:26 -06:00
Todd C. Miller
8186b98208 Adapt sudoers iolog client to log server dual port changes.
The TLS handshake now occurs before the ServerHello message is read.
This fixes potential man-in-the-middle attacks and works better with
TLS 1.3.
2020-05-05 13:23:26 -06:00
Todd C. Miller
1659d96c55 Use port 30343 for plaintext and port 30344 for TLS.
For TLS connections we now do the TLS handshake immediately before
the ServerHello message.  This lets the client recieve an alert
from the server is there is a handshake error after the TLS connect
has succeeded.  It also means that the contents of the ServerHello
are protected from a man-in-the-middle attack.
2020-05-05 13:23:26 -06:00
Todd C. Miller
b5a317aeb9 Add support for a tls flag in sudo_parse_host_port().
If the string "(tls)" appears at the end, the tls flag is set to true
and the default tls port is used if necessary.
2020-05-05 13:23:26 -06:00
Todd C. Miller
82bc05d998 Fix Debian ldap dependency broken in last commit. 2020-05-04 13:03:51 -06:00
Todd C. Miller
3b078b7a9c Fix "make package" on Debian when linux_audit is not set. 2020-05-04 12:36:35 -06:00
Todd C. Miller
42df431ce2 Make the default certificate and key paths match the example file. 2020-05-04 11:33:04 -06:00
Todd C. Miller
7d621fc6f1 Plug memory leaks in sudo_sendlog 2020-05-04 11:25:47 -06:00
Todd C. Miller
0460008c5b Handle EAGAIN like we do ENOMEM from poll() and select().
On some systems, poll() and select() can return EAGAIN instead
of ENOMEM if there is a kernel resource shortage.  In this case
we just re-enter the event loop and retry.
2020-05-04 11:23:35 -06:00
Todd C. Miller
a212ee64e3 Use the --embed when running "python3-config --ldflags" if supported.
Newer versions of python3-config only include libpython in the
output when the --embed is used.  Otherwise, "python3-config --libs"
and "python3-config --ldflags" only list the libraries python is
dependent on and not the python library itself.
2020-05-03 12:56:26 -06:00
Todd C. Miller
aba4915b83 On error, remove the connection with an error without freeing the closure.
Fixes the final message at the end when there is a network error.
2020-04-30 15:54:35 -06:00
Todd C. Miller
2b1e986572 Do not call poll(2) or ppoll(2) with nfds > RLIMIT_NOFILE.
Both poll(2) and ppoll(2) will return EINVAL if the nfds function
argument is larger than the max files per process resource limit.
Prevent this by limiting the max number entries in the pfds[] array
to the RLIMIT_NOFILE soft limit.
2020-04-30 15:54:34 -06:00
Todd C. Miller
85fe30e49b The timeout parameter of sudo_ev_add() should be const. 2020-04-29 11:27:30 -06:00
Todd C. Miller
3b7768be76 Don't free TLS on error in tls_init(), it is freed in client_closure_free().
Fixes a double free on error introduced with the TLS state cleanup in
client_closure_free().
2020-04-28 10:52:09 -06:00
Todd C. Miller
2ab8f2a732 Check for tls_config->dhparams_path being non-NULL before using it. 2020-04-28 10:52:08 -06:00
Todd C. Miller
79b064139f Document the TLS and test options. 2020-04-23 14:26:16 -06:00
Todd C. Miller
5dec0f763f Allow -t option even without OpenSSL
Also add -t to the usage message
2020-04-23 14:16:02 -06:00
Todd C. Miller
0fafcf6aea Use sudo_strtonum() instead of relying on strtoll().
Older, pre-C99, systems may not include strtoll() in their C library.
2020-04-23 11:15:03 -06:00
Todd C. Miller
b26e32f398 Allow this to build on systems without stdint.h by using config.h.
Old, pre-C99, systems may have inttypes.h but not stdint.h.
2020-04-23 11:13:33 -06:00
Todd C. Miller
40f47f0136 Fix support for pp_systemd_disabled and check for systemd existence.
On our build schroots we don't have systemctl installed but do have
the /etc/systemd and /lib/systemd (or /usr/lib/systemd) directories.
2020-04-22 15:23:05 -06:00
Todd C. Miller
8c5befaae8 Set pp_macos_service_id instead of pp_macos_default_service_id_prefix.
It is only effective to set pp_macos_default_service_id_prefix in
the indivisual %service sections (and not %set) so we may was well
use pp_macos_service_id which includes the service name.
2020-04-22 12:40:52 -06:00
Todd C. Miller
c70606c3c9 Set launchd service id prefix to "ws.sudo."
The default value in PolyPkg is "com.quest.rc."
2020-04-22 10:45:03 -06:00
Todd C. Miller
d5b06ff7fa Fix macOS package creation. 2020-04-22 08:58:07 -06:00
Todd C. Miller
557be2b0b1 Shut down the TLS connection cleanly in client_closure_free().
Also free the SSL data which is part of the client closure.
2020-04-21 15:01:44 -06:00
Todd C. Miller
76bf9a73bc Fix sudoedit when running with SELinux RBAC mode.
We can't use run_command() to run sesh, that will use the sudo event
loop (and might run it in a pty!).
There's no need to relabel the tty when copying files.
Get the path to sesh from sudo.conf.

Currently, for SELinux RBAC, the editor runs with the target user's
security context. This defeats the purpose of sudoedit.  Fixing
that requires passing file descriptors between the main sudo process
(running with the invoking user's security context) and sesh (runnning
with the target user's security context).
2020-04-21 14:29:23 -06:00
Todd C. Miller
009876bf36 Refactor the sudoedit code to copy files so it can be shared.
The SELinux sudoedit code now extends the destination file the
same way the non-SELinux version does.
2020-04-21 11:05:32 -06:00
Todd C. Miller
0bd39701b4 Do not remove sudoedit temporary files if we cannot overwrite the real file.
The warning message says the files were preserved but they actually
got removed.
2020-04-21 11:05:30 -06:00
Todd C. Miller
d22800edd5 Only remove the systemd unit service file if we copied it manually.
If the service file was installed as part of the package it will
be removed automatically when the package is uninstalled.
2020-04-21 11:05:29 -06:00
Todd C. Miller
99129ba41f Make gl_pathc, gl_matchc and gl_offs size_t in glob_t to match POSIX. 2020-04-21 11:05:29 -06:00
Todd C. Miller
c161f68b43 Document TLS settings in ServerHello 2020-04-20 11:12:03 -06:00
Todd C. Miller
adb4360c40 Extend the original file before to the new size before updating it.
Instead of opening the original file for writing w/ tuncation, we
first extend the file with zeroes (by writing, not seeking), then
overwrite it.  This should allow sudo to fail early if the disk is
out of space before it overwrites the original file.
2020-04-17 19:08:56 -06:00
Todd C. Miller
2a60816f75 I/O log plugins should be closed *before* the policy plugin, not after. 2020-04-17 15:57:06 -06:00
Todd C. Miller
af4eb80dfb Fix typo 2020-04-17 15:37:41 -06:00
Todd C. Miller
132b943a2d Only display error string once on I/O error.
We already include the error string in the format so no need to use
errno too.
2020-04-17 15:36:45 -06:00
Todd C. Miller
ae7bb12335 Free passwd and group caches in I/O plugin after log_warning(), not before.
The logging functions may try to use the cache via set_perms(PERM_ROOT).
2020-04-17 15:07:25 -06:00
Laszlo Orban
481427f9f0 add missing shudown of TLS connection 2020-04-17 07:00:19 -06:00
Todd C. Miller
a89ddb63fd Disable systemd support on Linux systems that don't use it. 2020-04-16 15:32:07 -06:00
Todd C. Miller
024b146d06 1.9.0 final 2020-04-14 19:26:41 -06:00
Todd C. Miller
1034d3f5b6 Update PolyPkg from my branch with systemd support. 2020-04-14 19:25:49 -06:00
Todd C. Miller
75b9a26a37 If the signal.Signals enum is not present, search the dictionary.
The Signals enum was added in Python 3.5.  If it is not present we
need to iterate over the dictionary items, looking for signal name
to number mappings.  Fixes the signal tests with Python 3.4.
2020-04-09 10:49:59 -06:00
Todd C. Miller
57cef10ce9 Python dictionaries are sparse so we cannot use pos as an index.
When converting sudo options from a dictionary to a tuple we need
to track the current index into the tuple separately from the
position of the dictionary entry.
2020-04-09 08:34:29 -06:00
Todd C. Miller
324b237245 Fix handling of /etc/sudo_logsrvd.conf in the sudo-logsrvd package.
For rpm and deb we include the file directly and mark it volatile.
For all others we copy it in the postinstall script from the example
dir if the file doesn't already exist.
2020-04-08 15:46:30 -06:00
Todd C. Miller
eebe68233c Check for the Sun Studio C compiler on Solaris under /opt.
Also intialize with_python to false.
2020-04-08 14:10:03 -06:00
Todd C. Miller
6d32858b4f regen 2020-04-08 12:50:39 -06:00
Todd C. Miller
3bf4172272 Explicitly include stdio.h for getdelim(3) 2020-04-08 12:42:58 -06:00
Todd C. Miller
ce92674cc2 Reload sudo.conf upon SIGUP
This makes it possible to update the Debug settings in sudo.conf and
have them take effect on reload.
2020-04-08 10:19:55 -06:00