Todd C. Miller
87b7209ebb
Add support for logging stdin/stdout/stderr in the non-pty exec path.
...
If we are logging I/O but not terminal input/output (either because
no terminal is present or because that is what the plugin requested),
the non-pty exec path is now taken.
2022-09-27 13:46:55 -06:00
Todd C. Miller
803b4939be
Move exec code to call into I/O log plugin to exec_iolog.c.
...
This will be shared with exec_nopty.c in the future to log
stdin/stdout/stderr without running the command in a pty.
Both exec_pty.c and exec_nopty.c now use the same closure.
2022-09-27 13:35:45 -06:00
Todd C. Miller
9c61d7e6e9
Bump the sudo plugin minor version.
...
The "update_ticket" entry was added to the settings list and the
"intercept_verify" entry was added to the command_info list.
2022-08-02 14:28:29 -06:00
Todd C. Miller
cf250354fc
Defer chdir(2) until sesh when running with SELinux.
...
We need to be running with the correct security context or the
chdir(2) may fail. GitHub issue #160 .
2022-08-01 13:40:47 -06:00
Todd C. Miller
de4d53e488
When using ptrace(2), push the point where we suspend into exec_cmnd().
...
This should reduce the amount of time the child has to wait for
the parent to use PTRACE_SEIZE to seize control and then PTRACE_CONT
to continue the child.
2022-05-31 19:51:26 -06:00
Todd C. Miller
9ac42292d1
Bump plugin minor version and document new intercept-related settings.
...
There should have been a minor version bump for sudo 1.9.8 when
intercept was originally implemented.
2022-05-26 09:19:08 -06:00
Todd C. Miller
5d385b3c58
Enable intercept and log_subcmds for SELinux using ptrace and seccomp.
2022-04-29 13:09:03 -06:00
Todd C. Miller
01733a5214
Add scaffolding for ptrace-based intercept mode.
2022-04-29 12:35:31 -06:00
Todd C. Miller
841375783a
Don't require a pty for intercept or log_subcmmds.
...
The code to take back control of the tty before a policy check
doesn't appear to be needed. If the command is run in its own pty,
sudo has control over the user's tty. If the command is run in
the user's tty, sudo should be in the foreground process group.
2022-04-20 11:56:26 -06:00
Todd C. Miller
839c189373
Translate "unable to set limit privileges" strings.
2022-04-20 13:55:51 -06:00
Todd C. Miller
7c8746bc70
Document resource limit support in command_info[] and Bump plugin API minor.
...
This is supported beginning with sudo 1.9.9 and plugin API 1.17.
2021-11-09 12:57:25 -07:00
Todd C. Miller
74ef983f60
Add front-end support for setting resouce limits.
...
The special value "user" means preserve the invoking user's limit.
The value "default" means don't override the default limit for the
user as assigned by the system (PAM, loging.conf, userdb, etc).
2021-11-08 18:21:11 -07:00
Todd C. Miller
ba171724f7
Rename log_children -> log_subcmds
2021-08-26 16:36:41 -06:00
Todd C. Miller
c9d9225469
Split off intercept code into exec_intercept.c.
2021-08-11 16:00:47 -06:00
Todd C. Miller
0ea5efd8b7
If msg_control is not present in struct msghdr use msg_accrights instead.
...
Fixes building on Solaris and probably others. It is possible to
expose msg_control on Solaris but this requires a specific set of
feature flag defines which can cause other complications.
2021-08-09 15:50:26 -06:00
Todd C. Miller
13b89e9103
Make the log_children option only log and not check policy.
2021-08-09 15:50:25 -06:00
Todd C. Miller
60e76e3e35
Take control of the tty and save its settings before doing a policy check.
...
Otherwise the policy plugin won't be able to read the password.
2021-08-09 15:50:25 -06:00
Todd C. Miller
42598735d0
Call the approval plugin after the policy plugin accepts a command.
...
Previously, for intercepted commands we only called the policy plugin.
2021-08-09 15:50:25 -06:00
Todd C. Miller
4cf3d1c416
Implement sudo_intercept.so.
...
Uses protobuf to talk to main sudo process over a socketpair.
2021-08-09 15:50:25 -06:00
Todd C. Miller
d7380bb271
Implement the sudo side of the sudo_intercept.so communication.
2021-08-09 15:50:25 -06:00
Todd C. Miller
a556b373c9
Allocate a socketpair to communicate with sudo_intercept.so over.
...
This is used for the intercept and log_children options.
2021-08-09 15:50:25 -06:00
Todd C. Miller
6287e8ca7d
Add support for loading the sudo_intercept.so DSO.
2021-08-09 15:50:25 -06:00
Todd C. Miller
ece5adc662
Add struct sudo_cred to hold the invoking or runas user credentials.
...
We can use this when we need to pass around credential info instead
of the user_details and command_details structs.
2021-01-06 13:01:09 -07:00
Todd C. Miller
267b9a8a23
Cannot do direct exec of a command when SELinux RBAC is enabled.
2021-01-02 10:43:34 -07:00
Todd C. Miller
fe9e65754c
Add event_alloc to the audit plugin API.
...
The sudoers audit plugin will use this to communicate with sudo_logsrvd.
2020-11-02 15:28:21 -07:00
Todd C. Miller
c4a579cf8a
Pass resource limits values to the plugin in user_info[]
...
Sudo resets the resource limits early in its execution so
the plugin cannot tell what the original limits were itself.
2020-08-31 16:37:01 -06:00
Todd C. Miller
961a4afe67
Fix some warnings from pvs-studio
2020-08-12 13:45:09 -06:00
Todd C. Miller
2dd1e1907d
Check audit plugins for a close function too before execing command directly.
...
We cannot exec the command directly if any of the policy or audit
plugins use a close function.
2020-05-26 11:36:17 -06:00
Todd C. Miller
446ae3f507
Include string.h unconditionally and only use strings.h for strn?casecmp()
...
In the pre-POSIX days BSD had strings.h, not string.h.
Now strings.h is only used for non-ANSI string functions.
2020-05-18 07:59:24 -06:00
Todd C. Miller
dd88460800
We no longer need to include headers we don't use for sudo*.h files.
...
Previously we needed to include headers required by the various
sudo*h files. Now those files are more self-sufficient and we
should only include headers needed by code in the various .c files.
2020-05-18 06:47:04 -06:00
Todd C. Miller
0cf2e09e0c
Apply spelling fixes.
...
Fixes from PR #30 (ka7) and Bug #925 (fossies.org codespell)
2020-05-06 09:27:43 -06:00
Todd C. Miller
93aa9f9e90
Add cwd_optional to command details and enable it in the sudoers plugin.
...
If cwd_optional is set to true, a failure to set the cwd will be a
warning, not an error, and the command will still run.
Debian bug #598519
2020-03-31 19:43:48 -06:00
Todd C. Miller
ac61b5655d
Use EXIT_SUCCESS and EXIT_FAILURE more consistently.
2020-02-08 12:43:00 -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
5793023ffd
Add a plugin interface to sudo main event loop.
2019-11-15 13:36:01 -07:00
Todd C. Miller
7acbfc18a9
Call closefrom() before we change to a non-root UID.
...
This prevents another process from changing the NOFILE resource limit
of the child process and defeating the closefrom() call.
Reported by Joe Vennix from Apple Information Security.
2019-11-02 10:51:49 -06:00
Todd C. Miller
e80079eaa8
Set resource limits in the sudo process to unlimited.
...
We don't want sudo to be limited by the caller's resource limits.
The original resource limits are restore before session setup.
2019-10-21 11:41:48 -06:00
Todd C. Miller
c3ce3a84fb
Refer to user-ID and group-ID instead of "user ID" and "group ID"
2019-10-19 14:26:41 -06:00
Todd C. Miller
b02851dcf3
Change how the umask is handled with PAM and login.conf.
...
If the umask is explicitly set in sudoers, use that value regardless
of what is in PAM or login.conf. If using the default umask from
sudoers, allow PAM or login.conf to override it. Bug #900
2019-10-18 06:20:27 -06:00
Todd C. Miller
112dff276a
Fix restoring the file context of the user's tty with SELinux.
...
Also fix broken tty labeling when running a command in a pty.
Includes a fix for a typo introduced in the last change set.
2019-09-27 15:32:49 -06:00
Todd C. Miller
5e692576c9
Restore core dump resource limit before the PAM session module is run.
...
Otherwise, we may override the limits set by PAM.
Bug #894
2019-08-20 07:25:53 -06:00
Todd C. Miller
1e1ef61902
Add SPDX-License-Identifier to files.
2019-04-29 07:21:51 -06:00
Todd C. Miller
e91e5ee820
Don't run the command in a pty if no I/O plugins are logging anything.
...
That way an I/O plugin that doesn't actually log anything won't cause
the command to be run in a pty.
2018-12-05 10:43:14 -07:00
Todd C. Miller
6c3d20cb41
Convert PVS-Studio comment to ANSI C.
2018-10-26 08:39:09 -06:00
Todd C. Miller
64e5d34c57
Add comments in .c files so PVS-Studio will check them.
2018-10-21 08:46:05 -06:00
Todd C. Miller
48fba3c2cc
update my email to Todd.Miller@sudo.ws
2017-12-03 17:53:40 -07:00
Todd C. Miller
84af812b8c
If /dev/tty is not available and no I/O logging plugins are configured,
...
fall back on exec_nopty() even if the policy plugin requested a pty.
We never allocate a pty when sudo is not run from a terminal anyway.
2017-09-07 11:32:30 -06:00
Todd C. Miller
d85056d95f
sudo_terminated() should not return true when SIGCHLD is pending.
...
Bug #801
2017-09-06 16:08:23 -06:00
Todd C. Miller
6a8eaef4b8
Move exec_setup(), unlimit_nproc() and restore_nproc() from sudo.c
...
to exec.c.
2017-05-15 09:01:10 -06:00
Todd C. Miller
1186f39842
Use SUDO_EV_SIGNAL and SUDO_EV_SIGINFO instead of managing the
...
signal_pipe explicitly.
2017-05-12 10:02:17 -06:00