mrrl-logincaps

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

commit 266e0a49911feaeac12dba334a791717e845f485
parent 857824fb08e3e7fdd5124342ba606305d2428d59
Author: Jan Pobrislo <ccx@webprojekty.cz>
Date:   Thu, 31 Dec 2020 05:46:34 +0100

Handle refused root terminal nicely.
Diffstat:
Mbin/zshaskpass_lock | 13+++++++++++--
Mlogin.c | 2++
2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/bin/zshaskpass_lock b/bin/zshaskpass_lock @@ -64,6 +64,12 @@ run() { # run external process in cleaned-up environment } # typeset -f -t run +nag() { + run redirfd -w 1 /dev/null redirfd -w 2 /dev/null \ + s6-sudo $x_container_tmpfs/run/exec/exec \ + background ' i3-nagbar' ' -f' ' fixed' " $^@" "" +} + logincap() { if ! (( $+LOGINCAP_READFD & $+LOGINCAP_WRITEFD )); then echo "logincap FDs not defined" @@ -74,6 +80,7 @@ logincap() { read -u $LOGINCAP_READFD line result_color=%F{cyan} printf '%s\n' ${(%)result_color}$line${(%)prompt_end} + [[ $line == [Oo][Kk]* ]] } lock() { @@ -121,7 +128,7 @@ cmd() { (reboot) logincap b;; (root) - logincap "terminal $terminal_env $terminal_el" + logincap "terminal $terminal_env $terminal_el" && \ logincap chvt X ;; (t *) @@ -161,7 +168,9 @@ read-plumber-message() { (terminal-*) logincap "${plumb_data%% *} $terminal_env $terminal_el";; (root-terminal) logincap chvt tty - logincap "terminal $terminal_env $terminal_el" + if ! logincap "terminal $terminal_env $terminal_el"; then + nag -m "Error asking for root terminal (are you in wheel group?)" + fi logincap chvt X ;; (lock) diff --git a/login.c b/login.c @@ -151,6 +151,8 @@ void login_main(void) /* TODO */ /* set UID, GID and GIDLIST env variables */ + alarm(0); // remove pending SIGALRM for stale login + execl("/etc/loginexec", "/etc/loginexec", loginexec, (char *)0); } }