mrrl-logincaps

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

commit a4b27f665802fc6d7426ecc5adb3c349306fd7e5
parent 6dfc6d8d245083704b6824620b93c50eca69055b
Author: Jan Pobrislo <ccx@te2000.cz>
Date:   Sun, 16 Mar 2025 21:48:29 +0000

Remove files merged into logincaps-user

Diffstat:
Dbin/cat_pass_fd | 4----
Dbin/handle-nsx11-message | 449-------------------------------------------------------------------------------
Dbin/link-to-container-inbox | 25-------------------------
Dbin/link-to-container-inbox.old | 26--------------------------
Dbin/pinentry-statuswrapper | 14--------------
Dbin/spawn-pty-nc.py | 115-------------------------------------------------------------------------------
Dbin/spawn-pty.py | 115-------------------------------------------------------------------------------
Dbin/startsshagent | 15---------------
Dbin/startsshagent.passfd | 16----------------
Dbin/supervised-gpg-agent-from-fdholder | 48------------------------------------------------
Dbin/zshaskpass | 37-------------------------------------
Dbin/zshaskpass_lock | 362-------------------------------------------------------------------------------
Dbin/zshaskpass_mux | 131-------------------------------------------------------------------------------
Dhome/.xinitrc | 76----------------------------------------------------------------------------
Dhome/loginexec | 17-----------------
15 files changed, 0 insertions(+), 1450 deletions(-)

diff --git a/bin/cat_pass_fd b/bin/cat_pass_fd @@ -1,4 +0,0 @@ -#!/command/execlineb -importas -i LOGINPASS_FD LOGINPASS_FD -fdmove 0 $LOGINPASS_FD -cat diff --git a/bin/handle-nsx11-message b/bin/handle-nsx11-message @@ -1,449 +0,0 @@ -#!/bin/zsh -setopt no_unset warn_create_global extended_glob - -typeset -g data terminal_exec_socket terminal_el x_container_service x_container_tmpfs -typeset -ga terminal_cmd -x_container_tmpfs=/run/containers/xsession.$X.$USER -x_container_service=/run/service/container.xsession.$X.$USER -terminal_exec_socket=$x_container_tmpfs/run/exec/urxvt -terminal_el="redirfd -w 1 /dev/null redirfd -w 2 /dev/null s6-sudo ${(qqq)terminal_exec_socket:A}" -terminal_cmd=( redirfd -w 1 /dev/null redirfd -w 2 /dev/null s6-sudo $terminal_exec_socket ) -terminal_env=rxvt-unicode # the TERM variable used - -nag() { - s6-sudo $x_container_tmpfs/run/exec/exec i3-nagbar -f fixed "$@" -} - -in_terminal() { - spawn-pty.py "$terminal_env" " $^@" "" "$terminal_cmd[@]" -} -typeset -f -t in_terminal - -in_terminal_nc() { - spawn-pty-nc.py "$terminal_env" " $^@" "" "$terminal_cmd[@]" -} -typeset -f -t in_terminal_nc - - -adjust-brightness() { - local backlight=/sys/class/backlight/intel_backlight - awk >$backlight/brightness \ - -v adjustment=$1 \ - -v max=$(<$backlight/max_brightness) \ - -v current=$(<$backlight/brightness) \ - 'BEGIN { - if(match(adjustment, /^\+[0-9]+%$/)) { - adjustment = substr(adjustment, 2, RLENGTH - 2) - adjustment = current + adjustment * 0.01 * max - } else if(match(adjustment, /^-[0-9]+%$/)) { - adjustment = substr(adjustment, 2, RLENGTH - 2) - adjustment = current - adjustment * 0.01 * max - } else if(match(adjustment, /^[0-9]+%$/)) { - adjustment = substr(adjustment, 1, RLENGTH - 1) - adjustment = adjustment * 0.01 * max - } else if(match(adjustment, /^\+[0-9]+$/)) { - adjustment = substr(adjustment, 2) - adjustment = current + adjustment - } else if(match(adjustment, /^-[0-9]+$/)) { - adjustment = substr(adjustment, 2) - adjustment = current - adjustment - } - adjustment = adjustment < 0 ? 0 : ( adjustment > max ? max : adjustment ) - printf ("%d\n", adjustment) - }' -} - -update-zsh-history() { - local container_histfile skel_histfile - skel_histfile=$HOME/bzr/nsx11/xsession-skel/home/ccx/.zsh-history - container_histfile=$x_container_tmpfs/home/$USER/.zsh-history - # TODO: do actual merge once we have a tool to parse - if [[ $container_histfile -nt $skel_histfile ]]; then - cp -v $container_histfile $skel_histfile - elif [[ $skel_histfile -nt $container_histfile ]]; then - cp -v $skel_histfile $container_histfile - fi - # ls -lh $skel_histfile $container_histfile -} - -ensure-container-started() { - [[ $1 == */* ]] && return 1 - s6-svc -wU -T 5000 -o /run/service/container.$1 -} - -abduco-run() { - local container session cmd rest out - local -a socket - container=${1%%/*} - rest=${1#*/} - - session=${rest%%/*} - if [[ $rest == */* ]]; then - cmd=${rest#*/} - fi - - if [[ $container == */* ]]; then - nag -m "Invalid container name: contains slashes" - return 1 - fi - - if [[ $session == */* ]]; then - nag -m "Invalid session name: contains slashes" - return 1 - fi - - if ! ensure-container-started $container; then - nag -m "Failed to start container ${(qqq)container}" - return 1 - fi - - socket=( /run/containers/$container/run/abduco/$USER/$session@*(=N) ) - if (( $#socket == 0 )); then - if [[ -n $cmd ]]; then - if out=$( 2>&1 s6-sudo /run/containers/$container/run/exec/exec execlineb -c "env TERM=rxvt-unicode-256color abduco -n ${(qqq)session} $cmd" ); then - socket=( /run/containers/$container/run/abduco/$USER/$session@*(=N) ) - if (( $#socket == 0 )); then - nag -m "Session spawned but no socket found." - return 1 - fi - else - nag -m "Error spawning session (exit $?): ${(qqq)out}" - return 1 - fi - else - nag -m "Session ${(qqq)session} does not exist in ${(qqq)container} and no command provided." - return 1 - fi - fi - if (( $#socket > 1 )); then - nag -m "More than one socket found for session ${(qqq)session} in ${(qqq)container}: ${socket:t}" - return 1 - fi - if ! link-to-container-inbox $container xsession.$X.$USER ${socket#/run/containers/${container}}; then - nag -m "Failed to link abduco socket." - return 1 - fi - if ! s6-sudo $x_container_tmpfs/run/exec/exec urxvt \ - -name abduco:${session//./-}:${container//./-} \ - -title "[$session@$container] abduco" \ - -e abduco -a /run/inbox/${socket#/run/containers/} - then - nag -m "Failed to spawn terminal for abduco session: /run/inbox/${socket#/run/containers/}" - fi -} -typeset -f -t abduco-run - -abduco-xpra-run() { - local display container session cmd rest out - local -a socket - display=${1%%/*} - rest=${1#*/} - - container=${rest%%/*} - rest=${rest#*/} - - session=${rest%%/*} - if [[ $rest == */* ]]; then - cmd=${rest#*/} - fi - - if [[ $container == */* ]]; then - nag -m "Invalid container name: contains slashes" - return 1 - fi - - if [[ $session == */* ]]; then - nag -m "Invalid session name: contains slashes" - return 1 - fi - - if ! ensure-container-started $container; then - nag -m "Failed to start container ${(qqq)container}" - return 1 - fi - - socket=( /run/containers/$container/run/abduco/$USER/$session@*(=N) ) - if (( $#socket == 0 )); then - if [[ -n $cmd ]]; then - if out=$( 2>&1 s6-sudo /run/containers/$container/run/exec/exec execlineb -c "env TERM=rxvt-unicode-256color abduco -n ${(qqq)session} $cmd" ); then - socket=( /run/containers/$container/run/abduco/$USER/$session@*(=N) ) - if (( $#socket == 0 )); then - nag -m "Session spawned but no socket found." - return 1 - fi - else - nag -m "Error spawning session (exit $?): ${(qqq)out}" - return 1 - fi - else - nag -m "Session ${(qqq)session} does not exist in ${(qqq)container} and no command provided." - return 1 - fi - fi - if (( $#socket > 1 )); then - nag -m "More than one socket found for session ${(qqq)session} in ${(qqq)container}: ${socket:t}" - return 1 - fi - if ! link-to-container-inbox $container xsession.$X.$USER ${socket#/run/containers/${container}}; then - nag -m "Failed to link abduco socket." - return 1 - fi - if ! s6-sudo $x_container_tmpfs/run/exec/exec env DISPLAY=$display urxvt \ - -fn 'xft:Terminus:pixelsize=16,xft:Unifont:pixelsize=16' \ - -name abduco:${session//./-}:${container//./-} \ - -title "[$session@$container] abduco" \ - -e abduco -a /run/inbox/${socket#/run/containers/} - then - nag -m "Failed to spawn terminal for abduco session: /run/inbox/${socket#/run/containers/}" - fi -} -typeset -f -t abduco-xpra-run - -x11-run() { - if ! [[ $1 == */*/*/* ]]; then - nag -m "Got malformed x11 command: ${(qqq)1}" - return 1 - fi - local container display cookie cmd rest out cmd_ret - container=${1%%/*} - rest=${1#*/} - - display=${rest%%/*} - rest=${rest#*/} - - cookie=${rest%%/*} - cmd=${rest#*/} - - if [[ $container == */* ]]; then - nag -m "Invalid container name: contains slashes" - return 1 - fi - - if ! [[ $display =~ ^[0-9]+$ ]]; then - nag -m "Invalid display name: ${(qqq)display}" - return 1 - fi - - if ! [[ $display == ${X}* ]]; then - nag -m "Display number not starting with ${X}: ${(qqq)display}" - return 1 - fi - - if ! [[ $cookie =~ ^[0-9a-fA-F]+$ ]]; then - nag -m "Invalid MIT cookie format: ${(qqq)cookie}" - return 1 - fi - - if ! ensure-container-started $container; then - nag -m "Failed to start container ${(qqq)container}" - return 1 - fi - - if ! link-to-container-inbox xsession.$X.$USER $container tmp/.X11-unix/X$display; then - nag -m "Failed to link X11 socket." - return 1 - fi - - out=$( 2>&1 env EXEC_PATH=/run/containers/$container/run/exec/x11 execlineb -c "importas -i -u EXEC_PATH EXEC_PATH s6-sudo \$EXEC_PATH ${(qqq)display} ${(qqq)cookie} $cmd" | tail -n 5 ) - cmd_ret=$pipestatus[1] - if (($cmd_ret)); then - nag -m "Error spawning session (exit $cmd_ret): ${(qqq)out}" - return 1 - fi - return 0 -} -typeset -f -t x11-run - -container-ssh() { - local container cmd out - local -a socket - container=$1 - shift - - if [[ $container == */* ]]; then - nag -m "Invalid container name: contains slashes" - return 1 - fi - - if ! ensure-container-started $container; then - nag -m "Failed to start container ${(qqq)container}" - return 1 - fi - - in_terminal_nc s6-sudo /run/containers/$container/run/exec/exec \ - env TERM=rxvt-unicode-256color s6-setsid s6-setsid -d 0 "$@" -} - -container-exec() { - if ! [[ $1 == */* ]]; then - nag -m "Got malformed exec command: ${(qqq)1}" - return 1 - fi - local container cmd out - container=${1%%/*} - cmd=${1#*/} - - if [[ $container == */* ]]; then - nag -m "Invalid container name: contains slashes" - return 1 - fi - - if ! ensure-container-started $container; then - nag -m "Failed to start container ${(qqq)container}" - return 1 - fi - - if ! link-to-container-inbox $container xsession.$X.$USER run/exec/exec; then - nag -m "Failed to link exec socket." - return 1 - fi - - if out=$( 2>&1 env EXEC_PATH=/run/containers/$container/run/exec/exec execlineb -c "importas -i -u EXEC_PATH EXEC_PATH s6-sudo \$EXEC_PATH $cmd" ); then - return 0 - else - nag -m "Error spawning session (exit $?): ${(qqq)out}" - return 1 - fi -} -typeset -f -t container-exec - -container-urxvt() { - if ! [[ $1 == */* ]]; then - nag -m "Got malformed exec command: ${(qqq)1}" - return 1 - fi - local container cmd out - container=${1%%/*} - cmd=${1#*/} - - if [[ $container == */* ]]; then - nag -m "Invalid container name: contains slashes" - return 1 - fi - - if ! ensure-container-started $container; then - nag -m "Failed to start container ${(qqq)container}" - return 1 - fi - - if ! link-to-container-inbox xsession.$X.$USER $container run/exec/urxvt; then - nag -m "Failed to link urxvt socket." - return 1 - fi - - local -a el_env=( - EXEC_PATH=/run/containers/$container/run/exec/exec - URXVT_PATH=/run/inbox/xsession.$X.$USER/run/exec/urxvt - ) - local -a el_cmd=( - 'multisubstitute {' - ' importas -i -u EXEC_PATH EXEC_PATH' - ' importas -i -u URXVT_PATH URXVT_PATH' - '}' - 's6-sudo $EXEC_PATH' - '/mnt/ns/bin/spawn-pty rxvt-unicode-256color {' - " $cmd" - '} s6-sudo $URXVT_PATH '${(qqq)${container//./:}} - ) - if out=$( 2>&1 env $el_env execlineb -c "${(F)el_cmd}" ); then - return 0 - else - nag -m "Error spawning session (exit $?): ${(qqq)out}" - return 1 - fi -} -typeset -f -t container-urxvt - -pass-input() { - local wid=$1 - local entry=$2 - pass show -- $entry | \ - awk -v wid=$wid 'NR == 1 { printf("type --window \"%s\" \"%s\"\n", wid, $0) }' | \ - s6-sudo $x_container_tmpfs/run/exec/exec xdotool - - # s6-sudo $x_container_tmpfs/run/exec/exec forstdin IN importas -i IN IN i3-nagbar -f fixed -t warning -m '$IN' -} - -# read full data from stdin, will handle binary payloads correctly unlike env -IFS= read -ru 0 -k $plumb_ndata data || return $? - -case $data in - (show-inbox) - in_terminal zsh -c "watch -n 1 'tree /run/containers/*.ccx/run/inbox'" - #in_terminal watch -n 1 'tree /run/containers/*.ccx/inbox' - ;; - - (top) - in_terminal /usr/bin/top --secure-mode - ;; - - (htop) - in_terminal htop --readonly - ;; - - (atop) - in_terminal atop - ;; - - (procs) - in_terminal procs -w --load-config $HOME/procs.conf - ;; - - (zsh-history) - update-zsh-history - ;; - - (adjust-brightness/*) - adjust-brightness "${data#*/}" - ;; - - (abduco/*/*) - abduco-run "${data#*/}" - ;; - - (abduco-xpra/*/*/*) - abduco-xpra-run "${data#*/}" - ;; - - (x11/*) - x11-run "${data#*/}" - ;; - - (container-exec/*) - container-exec "${data#*/}" - ;; - - (container-urxvt/*) - container-urxvt "${data#*/}" - ;; - - (ssh/*:*) - local ssh_hostport="${data#*/}" - local ssh_host="${ssh_hostport%:*}" - local ssh_port="${ssh_hostport##*:}" - in_terminal ssh -t -p $ssh_port -- $ssh_host - ;; - (ssh/*) - local ssh_host="${data#*/}" - in_terminal ssh -t -- $ssh_host - ;; - - (ssh2/*) - local ssh_host="${data#*/}" - container-ssh alpine-ssh.${USER} zsh -li - #container-ssh alpine-ssh.${USER} ssh -t -- $ssh_host - ;; - - (pass-input/wid:*/*) - local wid_entry="${data#*/wid:}" - local wid="${wid_entry%%/*}" - local entry="${wid_entry#*/}" - pass-input $wid $entry - ;; - - (amixer/*) - local amixer_args="${data#amixer/}" - execlineb -c "amixer $amixer_args" - (*) - nag -t warning -m "Powerbox got message: ${(qqq)plumb_data}" - ;; -esac diff --git a/bin/link-to-container-inbox b/bin/link-to-container-inbox @@ -1,25 +0,0 @@ -#!/bin/sh -# usage: src_container dst_container path/to/file [path/to/another ...] -usage() { - printf '%s\n' "usage: link-to-container-inbox src_container dst_container path/to/file [path/to/another ...]" -} - -if test $# -lt 3 || test -z "$1" || test -z "$2"; then - usage - exit 100 -fi - -src_container=$1 -dst_container=$2 -shift 2 || exit 100 -containers_dir=/run/containers -safelink_executable=safelink - -case $src_container in (*/*) usage; exit 100;; esac -case $dst_container in (*/*) usage; exit 100;; esac - -for f in "$@"; do - src=$containers_dir/$src_container/${f#/} - dst=$containers_dir/$dst_container/run/inbox/$src_container/$f - "$safelink_executable" "$src" "$dst" -done diff --git a/bin/link-to-container-inbox.old b/bin/link-to-container-inbox.old @@ -1,26 +0,0 @@ -#!/bin/zsh - -# usage: src_container dst_container path/to/file [path/to/another ...] - -setopt no_unset no_chase_links - -(( $# <= 3 )) || exit 100 -src_container=$1 -dst_container=$2 -shift 2 || exit 100 -[[ -z $src_container || $src_container == */* ]] && exit 100 -[[ -z $dst_container || $dst_container == */* ]] && exit 100 - -containers_dir=/run/containers - -for f in "$@"; do - src=$containers_dir/$src_container/${f#/} - [[ $src == ${src:a} ]] || exit 100 # check for non-canonical path (eg. containing ../) - dst=$containers_dir/$dst_container/run/inbox/$src_container/$f - mkdir -p ${dst:h} || exit $? - if [[ -d $dst ]]; then - rm -rf $dst || exit $? - fi - cd -s ${src:h} || exit $? # should fail if there is a symlink in the path - ln -f ./${src:t} $dst || exit $? -done diff --git a/bin/pinentry-statuswrapper b/bin/pinentry-statuswrapper @@ -1,14 +0,0 @@ -#!/bin/zsh -setopt no_unset - -statusfile=/run/user/$UID/i3status/pinentry -mkdir -p $statusfile:h || exit $? -exec 9>>$statusfile || exit $? -flock -s 9 || exit $? -printf "%s\n" "PINENTRY: ${TTY#/dev/}" >$statusfile -9>& - flock $statusfile redirfd -w 1 $statusfile true &! -if (($#)); then - exec "$@" -else - exec pinentry -fi diff --git a/bin/spawn-pty-nc.py b/bin/spawn-pty-nc.py @@ -1,115 +0,0 @@ -#!/usr/bin/env python3 - -from __future__ import ( - generators, division, absolute_import, with_statement, print_function -) -import sys -import os -import os.path -from fcntl import ioctl -from termios import TIOCSCTTY -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') -# parser.add_argument('exe', nargs='+', help='Execline block defining program ran on slave end, then terminal program') - - -def execve(argv, env): - if '/' in argv[0]: - os.execve(argv[0], argv, env) - else: - for p in os.environ['PATH'].split(os.path.pathsep): - try: - os.execve(os.path.join(p, argv[0]), argv, env) - except OSError: - continue - raise SystemExit(1) - - -def exec_terminal(terminal, term_env, slave_exe): - assert isinstance(terminal, (list, tuple)) - assert all(isinstance(s, str) for s in terminal) - assert len(terminal) - assert isinstance(slave_exe, list) - assert all(isinstance(s, str) for s in slave_exe) - master, slave = os.openpty() - if os.fork(): - # parent - os.close(slave) - os.dup2(master, 0) - os.close(master) - env = dict(os.environ) - env['PTY_FD'] = "0" - 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) - os.dup2(slave, 2) - os.close(slave) - #os.setsid() # create new session for this terminal - #ioctl(0, TIOCSCTTY, 0) # set controlling terminal - - execve(slave_exe, env) - - -def main(): - argv = sys.argv[1:] - if len(argv) < 2: - return 1 - - term_env = argv.pop(0) - # compat with argparse way - if term_env in ('-', '--'): - term_env = argv.pop(0) - - slave_argv = [] - - while argv: - a = argv.pop(0) - if a == '': - break - elif a[0] == ' ': - slave_argv.append(a[1:]) - else: - sys.stderr.write("Improperly terminated block!\n") - return 1 - if not argv: - sys.stderr.write("Terminal executable not specified.\n") - return 1 - - exec_terminal( - terminal=argv, - slave_exe=slave_argv, - term_env=term_env, - ) - return 3 - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/bin/spawn-pty.py b/bin/spawn-pty.py @@ -1,115 +0,0 @@ -#!/usr/bin/env python3 - -from __future__ import ( - generators, division, absolute_import, with_statement, print_function -) -import sys -import os -import os.path -from fcntl import ioctl -from termios import TIOCSCTTY -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') -# parser.add_argument('exe', nargs='+', help='Execline block defining program ran on slave end, then terminal program') - - -def execve(argv, env): - if '/' in argv[0]: - os.execve(argv[0], argv, env) - else: - for p in os.environ['PATH'].split(os.path.pathsep): - try: - os.execve(os.path.join(p, argv[0]), argv, env) - except OSError: - continue - raise SystemExit(1) - - -def exec_terminal(terminal, term_env, slave_exe): - assert isinstance(terminal, (list, tuple)) - assert all(isinstance(s, str) for s in terminal) - assert len(terminal) - assert isinstance(slave_exe, list) - assert all(isinstance(s, str) for s in slave_exe) - master, slave = os.openpty() - if os.fork(): - # parent - os.close(slave) - os.dup2(master, 0) - os.close(master) - env = dict(os.environ) - env['PTY_FD'] = "0" - 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) - os.dup2(slave, 2) - os.close(slave) - os.setsid() # create new session for this terminal - ioctl(0, TIOCSCTTY, 0) # set controlling terminal - - execve(slave_exe, env) - - -def main(): - argv = sys.argv[1:] - if len(argv) < 2: - return 1 - - term_env = argv.pop(0) - # compat with argparse way - if term_env in ('-', '--'): - term_env = argv.pop(0) - - slave_argv = [] - - while argv: - a = argv.pop(0) - if a == '': - break - elif a[0] == ' ': - slave_argv.append(a[1:]) - else: - sys.stderr.write("Improperly terminated block!\n") - return 1 - if not argv: - sys.stderr.write("Terminal executable not specified.\n") - return 1 - - exec_terminal( - terminal=argv, - slave_exe=slave_argv, - term_env=term_env, - ) - return 3 - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/bin/startsshagent b/bin/startsshagent @@ -1,15 +0,0 @@ -#!/command/execlineb -s1 -backtick SSH_ASKPASS { which zshaskpass } -piperw 5 4 -piperw 6 7 -fdmove -c 3 0 -s6-env DISPLAY=tty ZSHASKPASS_READFD=6 ZSHASKPASS_WRITEFD=4 -ssh-agent -a $1 -fdclose 3 -fdclose 4 -fdclose 6 -unexport ZSHASKPASS_READFD -unexport ZSHASKPASS_WRITEFD -if { env DISPLAY=terminal ssh-add -c } -s6-env ZSHASKPASS_PASSFD=7 ZSHASKPASS_PROMPTFD=5 -$@ diff --git a/bin/startsshagent.passfd b/bin/startsshagent.passfd @@ -1,16 +0,0 @@ -#!/command/execlineb -s1 -backtick SSH_ASKPASS { which zshaskpass } -piperw 5 4 -piperw 6 7 -s6-env DISPLAY=tty ZSHASKPASS_READFD=6 ZSHASKPASS_WRITEFD=4 -ssh-agent -a $1 -fdclose 4 -fdclose 6 -unexport ZSHASKPASS_READFD -unexport ZSHASKPASS_WRITEFD -if { redirfd -r 0 /dev/null env DISPLAY=pipe ssh-add -c } -importas -i LOGINPASS_FD LOGINPASS_FD -fdclose $LOGINPASS_FD -unexport LOGINPASS_FD -s6-env ZSHASKPASS_PASSFD=7 ZSHASKPASS_PROMPTFD=5 -$@ diff --git a/bin/supervised-gpg-agent-from-fdholder b/bin/supervised-gpg-agent-from-fdholder @@ -1,48 +0,0 @@ -#!/command/execlineb -P - -backtick USER { whoami } -importas -i USER USER - -backtick HOME { homeof ${USER} } -importas -i HOME HOME - -if { - s6-rc -v2 -u -l /run/user/${USER}/s6-rc change fdholder -} - -#if { -# ln -v -f ${HOME}/.gnupg/fdholder.S.gpg-agent ${HOME}/.gnupg/S.gpg-agent -#} -#if { -# ln -v -f /run/user/${USER}/fdholder.gpg-agent-ssh.sock /run/user/${USER}/gpg-agent-ssh.sock -#} -#if { -# ln -v -f /run/user/${USER}/fdholder.gpg-agent.sock /run/user/${USER}/gpg-agent.sock -#} - -foreground { - if { test -d /run/containers/alpine-recombee.ccx/inbox/ } - foreground { - ln -fv /run/user/ccx/gpg-agent-ssh.sock /run/containers/alpine-recombee.ccx/inbox/ - } - ln -fv /run/user/ccx/gpg-agent.sock /run/containers/alpine-recombee.ccx/inbox/ -} - -s6-fdholder-retrieve -t 1000 /run/user/${USER}/service/fdholder/s gpg-agent:std -fdmove 3 0 - -s6-fdholder-retrieve -t 1000 /run/user/${USER}/service/fdholder/s gpg-agent:ssh -fdmove 4 0 - -s6-fdholder-retrieve -t 1000 /run/user/${USER}/service/fdholder/s gpg-agent:extra -fdmove 5 0 - -redirfd -r 0 /dev/null - -export SD_LISTEN_FDS_START 3 -export LISTEN_FDS 3 -export LISTEN_FDNAMES "std:ssh:extra" -getpid LISTEN_PID - -#fdmove -c 2 1 -gpg-agent --enable-ssh-support --keep-tty --keep-display --supervised diff --git a/bin/zshaskpass b/bin/zshaskpass @@ -1,37 +0,0 @@ -#!/bin/zsh -if [[ -n $LOGINPASS_FD && $(</proc/$PPID/cmdline) == ssh-add* ]]; then - exec cat_pass_fd -fi -if [[ $+ZSHASKPASS_READFD -eq 0 || -z $ZSHASKPASS_READFD ]]; then - echo >&2 'ZSHASKPASS_READFD not set' - exit 2 -fi - -if [[ $+ZSHASKPASS_WRITEFD -eq 0 || -z $ZSHASKPASS_WRITEFD ]]; then - echo >&2 'ZSHASKPASS_WRITEFD not set' - exit 2 -fi - -prompt_color=%F{yellow} -accept_color=%F{green} -cancel_color=%F{red} - -exec <& $ZSHASKPASS_READFD -#exec 2>&$ZSHASKPASS_WRITEFD -#exec 2>/run/user/$USER/zshaskpass.new -#mv /run/user/$USER/zshaskpass.new /run/user/$USER/zshaskpass -#set -x -#filan >&2 - -prompt="$* (^D cancels): " -printf "${(%)prompt_color}%s\n" ${(f)prompt} >& $ZSHASKPASS_WRITEFD -read -s PASS -RET=$? -[[ $PASS == $'\0' ]] && RET=1 -if (($RET)); then - printf '%s\n' ${(%)cancel_color}Cancelled >& $ZSHASKPASS_WRITEFD -else - printf '%s\n' ${(%)accept_color}OK >& $ZSHASKPASS_WRITEFD - cat <<<$PASS || exit $? -fi -exit $RET diff --git a/bin/zshaskpass_lock b/bin/zshaskpass_lock @@ -1,362 +0,0 @@ -#!/bin/zsh -if [[ $+ZSHASKPASS_PROMPTFD -eq 0 || -z $ZSHASKPASS_PROMPTFD ]]; then - echo >&2 'ZSHASKPASS_PROMPTFD not set' - exit 2 -fi - -if [[ $+ZSHASKPASS_PASSFD -eq 0 || -z $ZSHASKPASS_PASSFD ]]; then - echo >&2 'ZSHASKPASS_PASSFD not set' - exit 2 -fi - -setopt no_unset warn_create_global -zmodload zsh/zselect - -typeset -g COPROC_OUT fd newfd prompt_end keep_running X die_color plumb_r plumb_w -typeset -a coproc_args clean_process_state -typeset -gA fds - -clean_process_state=( - unexport SSH_ASKPASS - fdclose $ZSHASKPASS_PROMPTFD unexport ZSHASKPASS_PROMPTFD - fdclose $ZSHASKPASS_PASSFD unexport ZSHASKPASS_PASSFD -) - -if [[ $TTY == /dev/tty[1234] ]]; then - typeset -g X - X=$[ ${TTY#/dev/tty} + 4 ] -fi - -die_color=%F{red} -warn_color=%F{yellow} -prompt_end=%f - -die() { - printf '%s\n' "${(%)die_color}$^@${(%)prompt_end}" - exit 1 -} - -coproc_args=( - fdmove -c 2 1 -) -if [[ -n $X ]]; then - typeset -g plumber_fifo terminal_exec_socket terminal_el x_container_service x_container_tmpfs - x_container_tmpfs=/run/containers/xsession.$X.$USER - x_container_service=/run/service/container.xsession.$X.$USER - xpra_container_service=/run/service/container.xpra.$USER - plumber_fifo=$x_container_tmpfs/run/plumber_fifo - terminal_exec_socket=$x_container_tmpfs/run/exec/urxvt - terminal_el="redirfd -w 1 /dev/null redirfd -w 2 /dev/null s6-sudo ${(qqq)terminal_exec_socket:A}" - terminal_env=rxvt-unicode # the TERM variable used - coproc_args+=( - tail -F - # $x_container_tmpfs/run/uncaught-logs/current - /run/container-logs/xsession.$X.$USER/current - ) -else - coproc_args+=( tail -F /run/user/$UID.logs/current ) -fi -if (($+LOGINCAP_READFD)); then - clean_process_state+=( fdclose $LOGINCAP_READFD unexport LOGINCAP_FD ) - #coproc_args=( fdclose $LOGINCAP_READFD unexport LOGINCAP_FD "$coproc_args[@]" ) -fi -if (($+LOGINCAP_WRITEFD)); then - clean_process_state+=( fdclose $LOGINCAP_WRITEFD unexport LOGINCAP_FD ) - #coproc_args=( fdclose $LOGINCAP_WRITEFD unexport LOGINCAP_FD "$coproc_args[@]" ) -fi - -run() { # run external process in cleaned-up environment - "$clean_process_state[@]" "$@" -} -# 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' " $^@" "" -} - -set-statefile() { - mkdir -p /run/user/$UID/i3status && - printf "%s\n" $@ >/run/user/$UID/i3status/${TTY:t} -} - -logincap() { - if ! (( $+LOGINCAP_READFD & $+LOGINCAP_WRITEFD )); then - echo "logincap FDs not defined" - return - fi - printf >&$LOGINCAP_WRITEFD '%s\n' "$*" - local line result_color - read -u $LOGINCAP_READFD line - result_color=%F{cyan} - printf '%s\n' ${(%)result_color}$line${(%)prompt_end} - [[ $line == [Oo][Kk]* ]] -} - -lock() { - plumb zsh-history # This is a good spot to synchronize history in absence of fs watcher - set-statefile lock - ssh-add -D || die "Error removing identities" - s6-svc -o -wu -T 3000 $x_container_tmpfs/run/service/screen-locker/ || "Failed to bring up screen locker" - s6-svstat $x_container_tmpfs/run/service/screen-locker/ - s6-svlisten1 -d $x_container_tmpfs/run/service/screen-locker/ zsh -c "read -sk 1 $'?\e[1mSession locked\e[m, press enter to unlock.\n' || exit 98; until ssh-add -c; do sleep 2; read -sk 1 $'?\nUnlock failed, press enter to try again.\n' || exit 98; done; if ssh-add -l >/dev/null; then printf '%s\n' 'Success, stopping screen locker'; s6-svc -d '$x_container_tmpfs/run/service/screen-locker/'; fi" - ssh-add -l >/dev/null || die "Failed to load SSH agent identities (screen locker died?), exiting." - set-statefile -} - -setup-plumber-listener() { - local temp_r # keep plumb_r in temp variable and set it at the end to indicate success - local wait_loop=10 - [[ -n $plumb_r ]] && return 0 - - while [[ ! -p $plumber_fifo ]]; do - if (( wait_loop-- <= 0 )); then - return 1 - fi - sleep .5 - #mkfifo $plumber_fifo || return $? - done - - : >$plumber_fifo &! # background disowned task to keep the fifo's writing side open until it's opened below - sysopen -o cloexec -u temp_r -r $plumber_fifo || return $? - if ! sysopen -o cloexec -u plumb_w -w $plumber_fifo; then - exec {temp_r}>&- # close fd - return 1 - fi - plumb_r=$temp_r - select_fds+=( $plumb_r ) -} -typeset -f -t setup-plumber-listener - -cmd() { - case $1 in - ('') ;; - (-x) set -x;; - (+x) set +x;; - ('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 - if run s6-svc -wU -T 8000 -o $xpra_container_service; then - run s6-svstat $xpra_container_service - else - printf '%s\n' "${(%)warn_color}Warning:${(%)prompt_end} ${(qqq)xpra_container_service} failed to start" - fi - logincap X\ $X || break - if run s6-svc -wU -T 8000 -o $x_container_service; then - run s6-svstat $x_container_service - setup-plumber-listener - else - s6-svc -d $x_container_service - logincap stopX\ $X - fi - ;; - (nox|stopx) - logincap stopX\ $X - ;; - (off|poweroff) - logincap o;; - (reboot) - logincap b;; - (root) - logincap "terminal $terminal_env $terminal_el" && \ - logincap chvt X - ;; - (t *) - logincap "terminal-${1#t } $terminal_env $terminal_el" - logincap chvt X - ;; - (lock) - lock - ;; - (exit) - set-statefile exit - true >/run/user/$UID/X$X/fifo - logincap stopX\ $X - keep_running=0 - ;; - (shell) - set-statefile shell - zsh -li; printf "shell exited with %d\n" $? - set-statefile - ;; - (cleanshell) - set-statefile cleanshell - run zsh -li; printf "shell exited with %d\n" $? - set-statefile - ;; - (tmux) - set-statefile tmux - run tmux -u new-session -A -s ${TTY:t} ; printf "tmux exited with %d\n" $? - set-statefile - ;; - (T) - cmd tmux - if [[ $(run s6-svstat -o up $x_container_service) == true ]]; then - logincap chvt X - else - cmd x - fi - ;; - (*) printf '%s: unknown command\n' ${(qqq)REPLY};; - esac -} -typeset -f -t cmd - -logincap-filter() { - case $1 in - (login.capability.service) - logincap "login.capability.service $2" - return - ;; - (login.capability.brightness) - logincap "login.capability.brightness $2" - return - ;; - esac - nag -m "capability not whitelisted: ${(qqq)1}" -} - -read-plumber-message() { - local plumb_src plumb_dst plumb_wdir plumb_type plumb_attr plumb_ndata plumb_data - - IFS= read -ru $plumb_r plumb_src || return $? - IFS= read -ru $plumb_r plumb_dst || return $? - IFS= read -ru $plumb_r plumb_wdir || return $? - IFS= read -ru $plumb_r plumb_type || return $? - IFS= read -ru $plumb_r plumb_attr || return $? - IFS= read -ru $plumb_r plumb_ndata || return $? - [[ $plumb_ndata =~ [0-9]+ ]] || return $? - IFS= read -ru $plumb_r -k $plumb_ndata plumb_data || return $? - printf >&2 '%s=%s\n' src ${(qqq)plumb_src} dst ${(qqq)plumb_dst} wdir ${(qqq)plumb_wdir} type ${(qqq)plumb_type} attr ${(qqq)plumb_attr} data ${(qqq)plumb_data} - case $plumb_data in - (poweroff) logincap o;; - (reboot) logincap b;; - (terminal-*) logincap "${plumb_data%% *} $terminal_env $terminal_el";; - (root-terminal) - logincap chvt tty - 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) - logincap chvt tty - lock - logincap chvt X - ;; - (exit) - 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 - keep_running=0 - ;; - (adjust-brightness/*) - logincap "login.capability.brightness ${plumb_data#*/}" - ;; - - (login.capability.*/*) - logincap-filter ${plumb_data%%/*} ${plumb_data#*/} - ;; - - (*) - # force subshell to reset signal handlers - ( printf %s $plumb_data | run env \ - plumb_src=$plumb_src \ - plumb_dst=$plumb_dst \ - plumb_wdir=$plumb_wdir \ - plumb_type=$plumb_type \ - plumb_attr=$plumb_attr \ - plumb_ndata=$plumb_ndata \ - plumb_data=$plumb_data \ - X=$X \ - handle-nsx11-message &! ) - ;; - - esac -} - -plumb() { - # force subshell to reset signal handlers - ( printf %s $1 | run env \ - plumb_src=zshaskpass_lock \ - plumb_dst= \ - plumb_wdir= \ - plumb_type=text \ - plumb_attr= \ - plumb_ndata=$( printf %s $1 | wc -c ) \ - plumb_data=$1 \ - X=$X \ - handle-nsx11-message &! ) -} - -coproc run "$coproc_args[@]" | run s6-tai64nlocal -trap 'kill %1' EXIT -trap 'kill %1; ssh-add -D; exit' INT HUP TERM QUIT -trap 'printf "\nALRM!\n"' ALRM -(($+TMOUT)) && printf 'TMOUT=%s\n' ${(qqq)TMOUT} -#coproc "$@" -exec {COPROC_OUT}<& p -select_fds=( $ZSHASKPASS_PROMPTFD $COPROC_OUT ) - -set-statefile -keep_running=1 -while (($keep_running)) && zselect -A fds -r 0 $select_fds; do - set-statefile - if ! (($#jobstates)); then - echo >&2 "Session exited." - set-statefile exit - exit 0 - fi - for fd in ${(k)fds}; do - if [[ $fds[$fd] != r ]]; then - echo >&2 "Error on filedescriptor $fd" - set-statefile error-on-fd-$fd - exit 1 - fi - if [[ $fd == $ZSHASKPASS_PROMPTFD ]]; then - # zshaskpass - if IFS= read -u $fd; then - if [[ $REPLY == *': ' ]]; then - set-statefile "askpass: $REPLY" - printf '%s' "$REPLY${(%)prompt_end}" - read -s - RET=$? - echo - if (($RET)); then - REPLY=$'\0' - fi - cat <<<$REPLY >& $ZSHASKPASS_PASSFD - else - printf '%s\n' "$REPLY${(%)prompt_end}" - fi - else - echo >&2 "Read from askpass failed" - fi - elif [[ $fd == $COPROC_OUT ]]; then - # coprocess - if IFS= read -u $COPROC_OUT -t; then - # if [[ $REPLY == "XFIFO: "* ]]; then - # printf '< opening: %s\n' ${REPLY#*: } - # exec {newfd}>>${REPLY#*: } - # else - printf '> %s\n' $REPLY - # fi - fi - elif [[ $fd == $plumb_r ]]; then - read-plumber-message - else - # stdin - if IFS= read -u $fd -s; then - cmd "$REPLY" - else - echo >&2 "Read from filedescriptor $fd failed" - fi - fi - done -done diff --git a/bin/zshaskpass_mux b/bin/zshaskpass_mux @@ -1,131 +0,0 @@ -#!/bin/zsh -if [[ $+ZSHASKPASS_PROMPTFD -eq 0 || -z $ZSHASKPASS_PROMPTFD ]]; then - echo >&2 'ZSHASKPASS_PROMPTFD not set' - exit 2 -fi - -if [[ $+ZSHASKPASS_PASSFD -eq 0 || -z $ZSHASKPASS_PASSFD ]]; then - echo >&2 'ZSHASKPASS_PASSFD not set' - exit 2 -fi - -setopt no_unset warn_create_global -zmodload zsh/zselect - -typeset -g COPROC_OUT fd newfd prompt_end keep_running -typeset -a coproc_args -typeset -gA fds - -#if [[ $ZSHASKPASS_PROMPTFD -gt $ZSHASKPASS_PASSFD ]]; then -# COPROC_OUT=$[ $ZSHASKPASS_PROMPTFD + 1 ] -#else -# COPROC_OUT=$[ $ZSHASKPASS_PASSFD + 1 ] -#fi - -prompt_end=%f -coproc_args=( - fdmove -c 2 1 - unexport ZSHASKPASS_PROMPTFD - unexport ZSHASKPASS_PASSFD - unexport SSH_ASKPASS - "$@" -) -if (($+LOGINCAP_READFD)); then - coproc_args=( fdclose $LOGINCAP_READFD unexport LOGINCAP_FD "$coproc_args[@]" ) -fi -if (($+LOGINCAP_WRITEFD)); then - coproc_args=( fdclose $LOGINCAP_WRITEFD unexport LOGINCAP_FD "$coproc_args[@]" ) -fi - -logincap() { - if ! (( $+LOGINCAP_READFD & $+LOGINCAP_WRITEFD )); then - echo "logincap FDs not defined" - return - fi - printf >&$LOGINCAP_WRITEFD '%s\n' "$*" - local line result_color - read -u $LOGINCAP_READFD line - result_color=%F{cyan} - printf '%s\n' ${(%)result_color}$line${(%)prompt_end} -} - -cmd() { - case $1 in - ('') ;; - ('c '*) - logincap ${1#c };; - (off|poweroff) - logincap o;; - (reboot) - logincap b;; - (root) - logincap "terminal rxvt-unicode importas -i PTY_FD PTY_FD s6-envdir /run/user/ccx/X$[ ${TTY#/dev/tty} + 4 ]/env urxvt -pty-fd \$PTY_FD" ;; - (exit) - true >/run/user/ccx/X$[ ${TTY#/dev/tty} + 4 ]/fifo - keep_running=0;; - (shell) - zsh -i; printf "shell exited with %d\n" $?;; - (*) printf '%s: unknown command\n' ${(qqq)REPLY};; - esac -} - -# typeset -f -t cmd - -coproc "$coproc_args[@]" -trap 'kill %1' EXIT -trap 'kill %1; ssh-add -D; exit' INT HUP TERM QUIT -trap 'printf "\nALRM!\n"' ALRM -(($+TMOUT)) && printf 'TMOUT=%s\n' ${(qqq)TMOUT} -#coproc "$@" -exec {COPROC_OUT}<& p -select_fds=( $ZSHASKPASS_PROMPTFD $COPROC_OUT ) - -keep_running=1 -while (($keep_running)) && zselect -A fds -r 0 $select_fds; do - if ! (($#jobstates)); then - echo >&2 "Session exited." - exit 0 - fi - for fd in ${(k)fds}; do - if [[ $fds[$fd] != r ]]; then - echo >&2 "Error on filedescriptor $fd" - exit 1 - fi - if [[ $fd == $ZSHASKPASS_PROMPTFD ]]; then - # zshaskpass - if IFS= read -u $fd; then - if [[ $REPLY == *': ' ]]; then - printf '%s' "$REPLY${(%)prompt_end}" - read -s - RET=$? - echo - if (($RET)); then - REPLY=$'\0' - fi - cat <<<$REPLY >& $ZSHASKPASS_PASSFD - else - printf '%s\n' "$REPLY${(%)prompt_end}" - fi - else - echo >&2 "Read from askpass failed" - fi - elif [[ $fd == $COPROC_OUT ]]; then - # coprocess - if IFS= read -u $COPROC_OUT -t; then - if [[ $REPLY == "XFIFO: "* ]]; then - printf '< opening: %s\n' ${REPLY#*: } - exec {newfd}>>${REPLY#*: } - else - printf '> %s\n' $REPLY - fi - fi - else - # stdin - if IFS= read -u $fd -s; then - cmd "$REPLY" - else - echo >&2 "Read from filedescriptor $fd failed" - fi - fi - done -done diff --git a/home/.xinitrc b/home/.xinitrc @@ -1,76 +0,0 @@ -#!/bin/sh -#set -x - -# Per-user supervision tree is expected in /run/user/$USER/service -# Files specific to each X11 session are put in /run/user/$USER/X<display-number> -DNAME=X${DISPLAY#:} -RUNDIR=/run/user/$USER - -cd "$RUNDIR" || exit $? -mkdir -p "$DNAME" || exit $? -cd "$DNAME" || exit $? - -# Set up lockfile and exit-fifo -touch ./lock || exit $? -exec 3<./lock -flock -w 2 3 || exit $? -if ! test -p fifo; then - mkfifo fifo || exit $? -fi - -# Share the necessary environment variables -# Runscripts should start with: s6-envdir ../../../env -export SX_RC_FIFO=$RUNDIR/$DNAME/fifo -rm -r ./env -s6-dumpenv ./env || exit $? -# mkdir -p ./env || exit $? -# printf '%s' >../env/"$DNAME"/DISPLAY "$DISPLAY" || exit $? -# printf '%s' >../env/"$DNAME"/XAUTHORITY "$XAUTHORITY" || exit $? - -# Check if s6-rc was already initialized -if test -e ./s6-rc; then - # Make sure the session is down - s6-rc -l "$PWD"/s6-rc -da -t 1500 change - - # Update the session so it uses the current compiled state - s6-rc-update -l "$PWD"/s6-rc "$(s6-linkname -f "$HOME"/s6-rc/xsession/compiled)" || exit $? -else - # Check for any leftover service symlinks which would prevent s6-rc-init from succeeding - if stat >/dev/null ../service/"$DNAME"-*; then - for sv in ../service/"$DNAME"-*; do - dst=$(s6-linkname -f "$sv") - rm "$sv" - test -e "$dst/supervise" && s6-svc -wD -T 300 -x "$dst" - done - fi - - if ! s6-rc-init -p "$DNAME"- -d -l "$PWD"/s6-rc -c "$HOME"/s6-rc/xsession/compiled "$RUNDIR"/service; then - # s6-rc-init failed, clean up livedir symlink so it's not considered initialized successfully - rm -f ./s6-rc - exit 1 - fi -fi - -set -x -# Start up the session -s6-svscanctl -a "$RUNDIR"/service || exit $? -s6-rc -l "$PWD"/s6-rc -- change ok-all || exit $? - -# Run until we get message on fifo to exit or until this process dies -# Cleanup process is forked until parent dies and then stops s6-rc -exec env PWD="$PWD" execlineb -c ' -importas -i PWD PWD -pipeline -w { - foreground { redirfd -w 1 /dev/null cat } - fdclose 0 - foreground { s6-echo "X session terminated" } - if -n { s6-rc -l $PWD/s6-rc -da change } - foreground { s6-echo "`s6-rc -da change` failed" } -} -cat fifo -' -#foreground { -# importas -i SX_RC_FIFO SX_RC_FIFO -# fdmove 1 2 -# s6-echo XFIFO: $SX_RC_FIFO -#} diff --git a/home/loginexec b/home/loginexec @@ -1,17 +0,0 @@ -#!/bin/zsh -l -set -x -mkdir -p /run/user/$UID/ssh-master && chmod 700 /run/user/$UID/ssh-master -local db_current=${XDG_DATA_HOME:-$HOME/.local/share}/s6-rc/current -if [[ -e ${db_current:P} && ! -e /run/user/$UID/s6-rc ]]; then - if ! s6-rc-init -c ${db_current:P} -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/$UID/ssh_agent.${${TTY#/dev/}//\//.} ]] && rm /run/user/$UID/ssh_agent.${${TTY#/dev/}//\//.} - X=$[ ${TTY#/dev/tty} + 4 ] - exec startsshagent.passfd /run/user/$UID/ssh_agent.${${TTY#/dev/}//\//.} =zshaskpass_lock -else - 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="'$commands[cat_pass_fd]'" ssh-add } zsh -l' -fi