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
Todd C. Miller
c6f9f06c45
Check return value of dispatch_pending_signals() in case we received
...
SIGINT or SIGQUIT before executing the command.
2017-04-07 08:38:56 -06:00
Todd C. Miller
35e4bd3e9f
Replace pipe_nonblock() with pipe2()
2017-03-13 12:11:52 -06:00
Todd C. Miller
6dba84dca9
Reorganize the command execution code to separate out the pty and
...
non-pty code paths into their own event loops. The non-pty exec
code is now contained in exec_nopty.c and the pty exec code is split
between exec_pty.c (parent process) and exec_monitor.c (session leader).
This results in a small bit of duplicated code but improves readability.
Some of the duplicated code will fall out in future changes to the
event subsystem (the signal pipe).
2017-03-03 10:35:11 -07:00
Todd C. Miller
13fcdb4f5f
Set the child pid to -1 after we've waited for it and take care to
...
avoid killing pid -1. This makes it a bit more explicit and removes
the need for a separate variable to track the child's status.
Sudo already stops processing signals after it receives SIGCHLD so
it is not vulnerable to CVE-2017-2616.
2017-02-24 15:14:56 -07:00
Todd C. Miller
dde2b5eb2c
Close execfd in parent processes where it is not needed.
2017-01-22 18:56:13 -08:00
Todd C. Miller
3f022419ae
Be consistent with the naming of the variable used to store the
...
function return value. Previously, some code used "rval", some
used "ret". This standardizes on "ret" and uses "rc" for temporary
return codes.
2016-09-08 16:38:08 -06:00
Todd C. Miller
a9570e64ff
fix brace style
2016-08-31 08:34:07 -06:00
Todd C. Miller
1ec4d9918d
Move sudo_debug_execve() call into sudo_execve().
2016-06-09 10:48:59 -06:00
Todd C. Miller
a2e541aef8
O_NOCTTY has no effect when opening /dev/tty as the open can only
...
succeed if there is already a controlling tty.
2016-05-16 11:17:20 -06:00
Todd C. Miller
00727a310c
Ignore the result of send() on exec error, if it fails the other
...
end of the pipe is gone and we are headed for exit.
Coverity CID 104066.
2016-05-07 04:47:12 -06:00
Todd C. Miller
6473d55aa7
Cast the return value of fcntl() to void when setting FD_CLOEXEC.
...
Coverity CID 104063, 104064, 104069, 104070, 104071, 104072, 104073, 104074
2016-05-05 16:16:24 -06:00
Todd C. Miller
829917f008
pid_t is defined by POSIX as a signed integer type so we don't need
...
a cast when comparing to -1.
2016-05-04 14:14:38 -06:00
Todd C. Miller
c70da6dcdf
In dispatch_signal() for stopped processes check for tcgetpgrp()
...
returning -1. Also change checks from "saved_pgrp != -1" to
"fd != -1". Coverity CID 104098.
2016-05-04 14:13:44 -06:00
Todd C. Miller
3e9702580e
style fix; fork_cmnd should start on a new line
2016-04-25 09:58:32 -06:00
Todd C. Miller
b20977d445
Add support for using fexecve() if supported on commands that are
...
checksummed.
2016-01-04 10:35:18 -07:00
Todd C. Miller
3f6f1cd15c
When a terminal device is closed, SIGHUP is sent to the controlling
...
process associated with that terminal. It is not sent to the entire
process group so sudo needs to relay SIGHUP to the command when it
is not being run in a new pty. Bug #719
2015-09-15 10:30:36 -06:00
Todd C. Miller
d08faa73a7
Fill in cstat if exec_setup() fails. Previously it was only filled
...
in for an execve() failure. Fixes an unkillable sudo process when
exec_setup() fails and I/O logging is enabled.
2015-09-09 10:50:21 -06:00
Todd C. Miller
13869d349c
Linux sets si_pid in struct siginfo to 0 when the process that sent
...
the signal is in a different container since the PID namespaces in
different conatiners are separate. Avoid looking up the process
group by id when si_pid is 0 since getpgid(0) returns the process
group of the current process. Since sudo ignores signals sent
by processes in its own process group, this had the effect of
ignoring signals sent from other containers. From Maarten de Vries
2015-08-10 15:13:37 -06:00
Todd C. Miller
0b241088b3
There's no need to conditionalize the #include <unistd.h>, we require
...
a POSIX system.
2015-07-02 09:08:28 -06:00
Todd C. Miller
4a07b472f0
Only include stddef.h where it is needed.
2015-06-20 05:34:35 -06:00
Todd C. Miller
c36415417f
Add function name to "unable to allocate memory" warnings.
2015-06-19 14:51:17 -06:00
Todd C. Miller
dc883f2454
We require ANSI C so stop using the obsolete STDC_HEADERS.
2015-06-19 14:29:27 -06:00
Todd C. Miller
cb63ca701c
Avoid using exiting allocators in the front end.
2015-06-17 17:00:54 -06:00
Todd C. Miller
59ab26dbcc
Go back to a 2 args debug_decl and just use the "default" instance,
...
now renamed "active".
2015-02-01 08:24:49 -07:00
Todd C. Miller
29039859b7
Defer registration of the SIGCHLD handler until just before we exec
...
the command. Fixes a problem where pam_gnome_keyring installs its
own SIGCHLD handler and may not restore the original one. As a
result, we now have to explicitly wait for the askpass helper to
finish. Bug #657
2014-11-18 14:05:51 -07:00
Todd C. Miller
21166d4da9
Make sure that SIGCHLD is not treated as a user-generated signal
...
in which case it could be ignored. Bug #676
2014-11-04 09:24:41 -07:00
Todd C. Miller
17a2a27e46
Use generic bitmap macros instead of select-style fd_set.
2014-10-23 14:37:27 -06:00