mirror of
https://github.com/sudo-project/sudo.git
synced 2025-09-06 01:05:43 +00:00
Use O_NOCTTY when opening a tty.
This commit is contained in:
@@ -160,7 +160,7 @@ relabel_tty(const char *ttyn, int ptyfd)
|
|||||||
|
|
||||||
/* If sudo is not allocating a pty for the command, open current tty. */
|
/* If sudo is not allocating a pty for the command, open current tty. */
|
||||||
if (ptyfd == -1) {
|
if (ptyfd == -1) {
|
||||||
se_state.ttyfd = open(ttyn, O_RDWR|O_NONBLOCK);
|
se_state.ttyfd = open(ttyn, O_RDWR|O_NOCTTY|O_NONBLOCK);
|
||||||
if (se_state.ttyfd == -1) {
|
if (se_state.ttyfd == -1) {
|
||||||
sudo_warn(U_("unable to open %s, not relabeling tty"), ttyn);
|
sudo_warn(U_("unable to open %s, not relabeling tty"), ttyn);
|
||||||
goto bad;
|
goto bad;
|
||||||
@@ -208,7 +208,7 @@ relabel_tty(const char *ttyn, int ptyfd)
|
|||||||
} else {
|
} else {
|
||||||
/* Re-open tty to get new label and reset std{in,out,err} */
|
/* Re-open tty to get new label and reset std{in,out,err} */
|
||||||
close(se_state.ttyfd);
|
close(se_state.ttyfd);
|
||||||
se_state.ttyfd = open(ttyn, O_RDWR|O_NONBLOCK);
|
se_state.ttyfd = open(ttyn, O_RDWR|O_NOCTTY|O_NONBLOCK);
|
||||||
if (se_state.ttyfd == -1) {
|
if (se_state.ttyfd == -1) {
|
||||||
sudo_warn(U_("unable to open %s"), ttyn);
|
sudo_warn(U_("unable to open %s"), ttyn);
|
||||||
goto bad;
|
goto bad;
|
||||||
|
Reference in New Issue
Block a user