Skip to content

Commit 894daa8

Browse files
committed
Enable the use_pty option by default for sudo 1.9.14.
GitHub issue #258
1 parent d7b8f3f commit 894daa8

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

docs/UPGRADE.md

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
11
Notes on upgrading from an older release
22
========================================
33

4+
* Upgrading from a version prior to 1.9.14:
5+
6+
Sudo now runs commands in a new pseudo-terminal by default. This
7+
can prevent a malicious program run via sudo from accessing the
8+
user's terminal device after the command completes.
9+
10+
When sudo runs a command in a new pseudo-terminal, an additional
11+
process is created to monitor the command's status and pass
12+
terminal control signals between the two terminals. See the
13+
"Process model" subsection in the sudo manual and the description
14+
of the "use_pty" option in the sudoers manual for more information.
15+
16+
A side effect of running the command in a new pseudo-terminal
17+
is that sudo must pass input from the user's terminal to the
18+
pseudo-terminal, even if the command being run does not require
19+
the input. The "exec_background" option in sudoers can be used
20+
to prevent this, but some screen-oriented commands may not operate
21+
properly when run as a background process.
22+
23+
To restore the historic behavior where a command is run in the
24+
user's terminal, add the following line to the sudoers file:
25+
26+
Defaults !use_pty
27+
428
* Upgrading from a version prior to 1.9.13:
529

630
Sudo now builds AIX-style shared libraries and dynamic shared
@@ -166,7 +190,6 @@ Notes on upgrading from an older release
166190
those names, sudo, and visudo will report a syntax error with a
167191
message like "syntax error: unexpected TIMEOUT, expecting ALIAS".
168192

169-
Starting with version 1.9.3, sudoers rules must end in either
170193
Prior to version 1.8.20, when log_input, log_output, or use_pty
171194
were enabled, if any of the standard input, output, or error
172195
were not connected to a terminal, sudo would use a pipe. The

docs/sudoers.man.in

+3-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
.nr BA @BAMAN@
2626
.nr LC @LCMAN@
2727
.nr PS @PSMAN@
28-
.TH "SUDOERS" "@mansectform@" "March 28, 2023" "Sudo @PACKAGE_VERSION@" "File Formats Manual"
28+
.TH "SUDOERS" "@mansectform@" "April 6, 2023" "Sudo @PACKAGE_VERSION@" "File Formats Manual"
2929
.nh
3030
.if n .ad l
3131
.SH "NAME"
@@ -4214,8 +4214,7 @@ by default.
42144214
use_pty
42154215
If set, and
42164216
\fBsudo\fR
4217-
is running in a terminal, the command will be run in a pseudo-terminal
4218-
(even if no I/O logging is being done).
4217+
is running in a terminal, the command will be run in a new pseudo-terminal.
42194218
If the
42204219
\fBsudo\fR
42214220
process is not attached to a terminal,
@@ -4231,7 +4230,7 @@ executing.
42314230
By running the command in a separate pseudo-terminal, this attack is
42324231
no longer possible.
42334232
This flag is
4234-
\fIoff\fR
4233+
\fIon\fR
42354234
by default.
42364235
.TP 18n
42374236
user_command_timeouts

docs/sudoers.mdoc.in

+3-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
.nr BA @BAMAN@
2626
.nr LC @LCMAN@
2727
.nr PS @PSMAN@
28-
.Dd March 28, 2023
28+
.Dd April 6, 2023
2929
.Dt SUDOERS @mansectform@
3030
.Os Sudo @PACKAGE_VERSION@
3131
.Sh NAME
@@ -3988,8 +3988,7 @@ by default.
39883988
.It use_pty
39893989
If set, and
39903990
.Nm sudo
3991-
is running in a terminal, the command will be run in a pseudo-terminal
3992-
(even if no I/O logging is being done).
3991+
is running in a terminal, the command will be run in a new pseudo-terminal.
39933992
If the
39943993
.Nm sudo
39953994
process is not attached to a terminal,
@@ -4005,7 +4004,7 @@ executing.
40054004
By running the command in a separate pseudo-terminal, this attack is
40064005
no longer possible.
40074006
This flag is
4008-
.Em off
4007+
.Em on
40094008
by default.
40104009
.It user_command_timeouts
40114010
If set, the user may specify a timeout on the command line.

plugins/sudoers/defaults.c

+1
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ init_defaults(void)
559559
def_log_format = sudo;
560560
def_runas_allow_unknown_id = false;
561561
def_noninteractive_auth = false;
562+
def_use_pty = true;
562563

563564
/* Syslog options need special care since they both strings and ints */
564565
#if (LOGGING & SLOG_SYSLOG)

0 commit comments

Comments
 (0)