mrrl-logincaps

MRRL version of logincaps
git clone https://ccx.te2000.cz/git/mrrl-logincaps
Log | Files | Refs

commit 1611a851d0601f02eae89a2f69e5c4d41c5917ea
parent d00d08c307f2a4e40b27519e954309c7cc697e30
Author: Jan Pobrislo <ccx@webprojekty.cz>
Date:   Thu, 17 Dec 2020 04:25:51 +0100

Reset signal handlers in spawn-pty.py for the tty-attached process.
Diffstat:
Mbin/handle-nsx11-message | 3++-
Mbin/spawn-pty.py | 30++++++++++++++++++++++++++----
2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/bin/handle-nsx11-message b/bin/handle-nsx11-message @@ -19,7 +19,8 @@ IFS= read -ru 0 -k $plumb_ndata data || return $? case $data in (show-inbox) - in_terminal watch -n 1 'tree /run/containers/*.ccx/inbox' + in_terminal zsh -c "watch -n 1 'tree /run/containers/*.ccx/inbox'" + #in_terminal watch -n 1 'tree /run/containers/*.ccx/inbox' ;; (*) s6-sudo $x_container_tmpfs/run/exec/exec \ diff --git a/bin/spawn-pty.py b/bin/spawn-pty.py @@ -8,7 +8,7 @@ import os import os.path from fcntl import ioctl from termios import TIOCSCTTY -import pwd +import signal # parser = argparse.ArgumentParser(description="Runs one program inside pty and another with changed privileges with master pty as fd 0") # parser.add_argument('term_env', help='The TERM variable used by the slave') @@ -44,6 +44,29 @@ def exec_terminal(terminal, term_env, slave_exe): execve(terminal, env) else: # child + + # reset select signal handlers + for sig in ( + signal.SIGHUP, + signal.SIGINT, + signal.SIGQUIT, + signal.SIGPIPE, + signal.SIGALRM, + signal.SIGTERM, + signal.SIGCHLD, + signal.SIGCONT, + # signal.SIGSTOP, + signal.SIGTSTP, + signal.SIGTTIN, + signal.SIGTTOU, + + ): + signal.signal(sig, signal.SIG_DFL) + + env = dict(os.environ) + env['TERM'] = term_env + env.pop('LOGNAME', None) + os.close(master) os.dup2(slave, 0) os.dup2(slave, 1) @@ -51,9 +74,7 @@ def exec_terminal(terminal, term_env, slave_exe): os.close(slave) os.setsid() # create new session for this terminal ioctl(0, TIOCSCTTY, 0) # set controlling terminal - env = dict(os.environ) - env['TERM'] = term_env - env.pop('LOGNAME', None) + execve(slave_exe, env) @@ -87,6 +108,7 @@ def main(): slave_exe=slave_argv, term_env=term_env, ) + return 3 if __name__ == '__main__':