Skip to content

Commit b6df365

Browse files
committed
Disable PTY ECHO on spawned shell
1 parent a4d7320 commit b6df365

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

crates/sandchest-agent/src/session.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,17 @@ fn spawn_shell(
215215
let pty = nix::pty::openpty(None, None)
216216
.map_err(|e| Status::internal(format!("openpty failed: {e}")))?;
217217

218+
#[cfg(unix)]
219+
{
220+
use nix::sys::termios::{LocalFlags, SetArg, tcgetattr, tcsetattr};
221+
222+
let mut termios = tcgetattr(&pty.slave)
223+
.map_err(|e| Status::internal(format!("tcgetattr failed: {e}")))?;
224+
termios.local_flags.remove(LocalFlags::ECHO);
225+
tcsetattr(&pty.slave, SetArg::TCSANOW, &termios)
226+
.map_err(|e| Status::internal(format!("tcsetattr failed: {e}")))?;
227+
}
228+
218229
let slave_raw = pty.slave.as_raw_fd();
219230

220231
let mut cmd = Command::new(shell);

0 commit comments

Comments
 (0)