THE-Spellchecker
5eba4b48cf
Typographical and Grammatical fixes
2023-11-28 15:00:04 -07:00
Todd C. Miller
e343e07543
Use #include <foo.h> instead of #include "foo.h" in most cases.
...
We rely on the include path to find many of these headers. It
especially doesn't make sense to use #include "foo.h" for headers
in the top-level include directory.
2023-09-25 10:13:28 -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
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
32f4b98f6b
sudo frontend: silence most -Wconversion warnings.
2023-07-07 15:07:04 -06:00
Todd C. Miller
6c3c8acbac
More accurate description of what happens for "sudo -b".
2023-04-19 15:09:23 -06:00
Todd C. Miller
f0030cf30f
Make struct {command,user}_details pointers const where possible.
2023-03-27 16:29:46 -06:00
Todd C. Miller
5108c279af
Make user_details private to sudo.c.
2023-03-27 16:19:08 -06:00
Todd C. Miller
86002226b6
Store submitcwd (from user_details) in struct command_details.
...
This eliminates use of the user_details global from exec_setup().
2023-03-25 08:27:41 -06:00
Todd C. Miller
f9b1beced2
Move ptyname to struct exec_closure
2023-03-24 14:56:45 -06:00
Todd C. Miller
c61306e583
Plug a memory leak with ptrace-based intercept.
2023-03-10 13:32:56 -07:00
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