mrrl-logincaps

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

commit 032c9cc341394d2ebb6a4f041ac62d63b8755c59
parent 215100d29383cb4777b9b672a2d7b27a9b718e5b
Author: Jan Pobrislo <ccx@webprojekty.cz>
Date:   Wed, 12 Oct 2022 23:19:31 +0200

Use UID-based /run/user directory, drop xsession in-container catch-all logger
Diffstat:
Mbin/zshaskpass_lock | 19+++++++++++++------
Mhome/loginexec | 14+++++++-------
2 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/bin/zshaskpass_lock b/bin/zshaskpass_lock @@ -48,11 +48,11 @@ if [[ -n $X ]]; then terminal_env=rxvt-unicode # the TERM variable used coproc_args+=( tail -F - $x_container_tmpfs/run/uncaught-logs/current + # $x_container_tmpfs/run/uncaught-logs/current /run/container-logs/xsession.$X.$USER/current ) else - coproc_args+=( tail -F /run/user/$USER.logs/current ) + coproc_args+=( tail -F /run/user/$UID.logs/current ) fi if (($+LOGINCAP_READFD)); then clean_process_state+=( fdclose $LOGINCAP_READFD unexport LOGINCAP_FD ) @@ -75,8 +75,8 @@ nag() { } set-statefile() { - mkdir -p /run/user/$USER/i3status && - printf "%s\n" $@ >/run/user/$USER/i3status/${TTY:t} + mkdir -p /run/user/$UID/i3status && + printf "%s\n" $@ >/run/user/$UID/i3status/${TTY:t} } logincap() { @@ -135,6 +135,10 @@ cmd() { ('c '*) logincap ${1#c };; (x) + if ! run s6-svwait -D -t 1000 $x_container_service; then + printf '%s\n' "${(%)die_color}Error:${(%)prompt_end} ${(qqq)x_container_service} already running" + break + fi logincap X\ $X || break if run s6-svc -wU -T 8000 -o $x_container_service; then run s6-svstat $x_container_service @@ -144,6 +148,9 @@ cmd() { logincap stopX\ $X fi ;; + (nox|stopx) + logincap stopX\ $X + ;; (off|poweroff) logincap o;; (reboot) @@ -161,7 +168,7 @@ cmd() { ;; (exit) set-statefile exit - true >/run/user/$USER/X$X/fifo + true >/run/user/$UID/X$X/fifo logincap stopX\ $X keep_running=0 ;; @@ -214,7 +221,7 @@ read-plumber-message() { logincap chvt X ;; (exit) - true >/run/user/$USER/X$X/fifo + true >/run/user/$UID/X$X/fifo run s6-svc -wd -di -T 1 $x_container_service # run s6-svc -wd -d -T 1 /run/service/X$X logincap stopX\ $X diff --git a/home/loginexec b/home/loginexec @@ -1,20 +1,20 @@ #!/bin/zsh -l set -x -mkdir -p /run/user/$USER/ssh-master && chmod 700 /run/user/$USER/ssh-master -if [[ -e $HOME/s6-rc/user/compiled && ! -e /run/user/$USER/s6-rc ]]; then - if ! s6-rc-init -c $HOME/s6-rc/user/compiled -l /run/user/$USER/s6-rc -d /run/user/$USER/service; then +mkdir -p /run/user/$UID/ssh-master && chmod 700 /run/user/$UID/ssh-master +if [[ -e $HOME/s6-rc/user/compiled && ! -e /run/user/$UID/s6-rc ]]; then + if ! s6-rc-init -c $HOME/s6-rc/user/compiled -l /run/user/$UID/s6-rc -d /run/user/$UID/service; then echo >&2 'Warning: s6-rc failed to start!' fi fi if [[ $TTY = /dev/tty[1-4] ]]; then - [[ -S /run/user/$USER/ssh_agent.${${TTY#/dev/}//\//.} ]] && rm /run/user/$USER/ssh_agent.${${TTY#/dev/}//\//.} + [[ -S /run/user/$UID/ssh_agent.${${TTY#/dev/}//\//.} ]] && rm /run/user/$UID/ssh_agent.${${TTY#/dev/}//\//.} X=$[ ${TTY#/dev/tty} + 4 ] # if [[ $X == 5 ]]; then -# exec startsshagent.passfd /run/user/$USER/ssh_agent.${${TTY#/dev/}//\//.} =zshaskpass_mux xinit -- :$X tty$X -quiet -nolisten local -nolisten tcp -retro +# exec startsshagent.passfd /run/user/$UID/ssh_agent.${${TTY#/dev/}//\//.} =zshaskpass_mux xinit -- :$X tty$X -quiet -nolisten local -nolisten tcp -retro # else - exec startsshagent.passfd /run/user/$USER/ssh_agent.${${TTY#/dev/}//\//.} =zshaskpass_lock + exec startsshagent.passfd /run/user/$UID/ssh_agent.${${TTY#/dev/}//\//.} =zshaskpass_lock # fi else - exec ssh-agent -a /run/user/$USER/ssh_agent.${${TTY#/dev/}//\//.} /bin/execlineb -c \ + exec ssh-agent -a /run/user/$UID/ssh_agent.${${TTY#/dev/}//\//.} /bin/execlineb -c \ 'if { redirfd -r 0 /dev/null env DISPLAY=pipe SSH_ASKPASS=/home/ccx/bin/cat_pass_fd ssh-add } zsh -l' fi