2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 14:25:15 +00:00

Add exec_background option in plugin command info and a sudoers

option to match.  When set, commands are started in the background
and automatically foregrounded as needed.  There are issues with
some ill-mannered programs (like Linux su) so this is not the
default.
This commit is contained in:
Todd C. Miller
2013-01-11 14:34:09 -05:00
parent a6f3517f23
commit 9479bb623b
13 changed files with 351 additions and 36 deletions

View File

@@ -1,7 +1,7 @@
.\" DO NOT EDIT THIS FILE, IT IS NOT THE MASTER!
.\" IT IS GENERATED AUTOMATICALLY FROM sudo_plugin.mdoc.in
.\"
.\" Copyright (c) 2009-2012 Todd C. Miller <Todd.Miller@courtesan.com>
.\" Copyright (c) 2009-2013 Todd C. Miller <Todd.Miller@courtesan.com>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
@@ -16,7 +16,7 @@
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.TH "SUDO_PLUGIN" "5" "November 26, 2012" "Sudo @PACKAGE_VERSION@" "OpenBSD Programmer's Manual"
.TH "SUDO_PLUGIN" "5" "Janurary 11, 2013" "Sudo @PACKAGE_VERSION@" "OpenBSD Programmer's Manual"
.nh
.if n .ad l
.SH "NAME"
@@ -1018,6 +1018,67 @@ If not set,
\fBsudo\fR
will base the new entry on
the invoking user's existing entry.
.TP 6n
exec_background=bool
By default,
\fBsudo\fR
runs a command as the foreground process as long as
\fBsudo\fR
itself is running in the foreground.
When
\fIexec_background\fR
is enabled and the command is being run in a pty (due to I/O logging
or the
\fIuse_pty\fR
setting), the command will be run as a background process.
Attempts to read from the controlling terminal (or to change terminal
settings) will result in the command being suspended with the
\fRSIGTTIN\fR
signal (or
\fRSIGTTOU\fR
in the case of terminal settings).
If this happens when
\fBsudo\fR
is a foreground process, the command will be granted the controlling terminal
and resumed in the foreground with no user intervention required.
The advantage of initially running the command in the background is that
\fBsudo\fR
need not read from the terminal unless the command explicitly requests it.
Otherwise, any terminal input must be passed to the command, whether it
has required it or not (the kernel buffers terminals so it is not possible
to tell whether the command really wants the input).
This is different from historic
\fIsudo\fR
behavior or when the command is not being run in a pty.
.sp
For this to work seamlessly, the operating system must support the
automatic restarting of system calls.
Unfortunately, not all operating systems do this by default,
and even those that do may have bugs.
For example, Mac OS X fails to restart the
\fBtcgetattr\fR()
and
\fBtcsetattr\fR()
system calls (this is a bug in Mac OS X).
Furthermore, because this behavior depends on the command stopping with the
\fRSIGTTIN\fR
or
\fRSIGTTOU\fR
signals, programs that catch these signals and suspend themselves
with a different signal (usually
\fRSIGTOP\fR)
will not be automatically foregrounded.
Some versions of the linux
su(1)
command behave this way.
Because of this, a plugin should not set
\fIexec_background\fR
unless it is explicitly enabled by the administrator and there should
be a way to enabled or disable it on a per-command basis.
.sp
This setting has no effect unless I/O logging is enabled or
\fIuse_pty\fR
is enabled.
.PP
Unsupported values will be ignored.
.PP