unl0kr: simplify the crash edge-case handling
This commit is contained in:
@@ -25,17 +25,7 @@ let
|
||||
# but modified to not leak pword to CLI
|
||||
# - implement some sort of watchdog (e.g. detect spawned children?)
|
||||
# - set a timeout at the outer scope (which gets canceled upon successful login)
|
||||
# eval 'redirect-tty "/dev/${tty}" unl0kr ; sleep 5 ; redirect-tty "/dev/${tty}" echo ""' &
|
||||
# redirect-tty "/dev/${tty}" unl0kr &
|
||||
# unl0kr_pid=$!
|
||||
# # login -p: preserve environment
|
||||
# login -p ${cfg.config.user} &
|
||||
# login_pid=$!
|
||||
# # wait for unl0kr, and if it succeeds then hand control fully to `login`.
|
||||
# # otherwise, exit, implicitly killing `login` and probably restarting the service
|
||||
# wait "$unl0kr_pid" && wait "$login_pid"
|
||||
|
||||
redirect-tty "/dev/${tty}" unl0kr &
|
||||
bash -c 'redirect-tty "/dev/${tty}" unl0kr ; sleep 2 ; redirect-tty "/dev/${tty}" echo ""' &
|
||||
login -p ${cfg.config.user}
|
||||
'';
|
||||
};
|
||||
|
@@ -13,7 +13,6 @@ import fcntl
|
||||
import subprocess
|
||||
import sys
|
||||
import termios
|
||||
import time
|
||||
|
||||
def write_to(text: bytes, dest_path: str) -> None:
|
||||
with open(dest_path, "w") as f:
|
||||
@@ -24,15 +23,7 @@ def main(argv: list[str]):
|
||||
dest_path = argv[1]
|
||||
cmd = argv[2:]
|
||||
|
||||
try:
|
||||
cmd_output = subprocess.check_output(cmd)
|
||||
except Exception as e:
|
||||
# command failed, somehow.
|
||||
# sleep, to ensure `login` has some time to start
|
||||
# then send it an empty newline to force it to fail
|
||||
time.sleep(1)
|
||||
write_to(b"\n", dest_path)
|
||||
raise
|
||||
cmd_output = subprocess.check_output(cmd)
|
||||
write_to(cmd_output, dest_path)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Reference in New Issue
Block a user