mrrl-logincaps

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

commit b979668208d499274c400340c38bf10e27d658e4
parent 74a5987415c09fdac410eaeb26a8fd79be49906a
Author: ccx <ccx@te2000.cz>
Date:   Sun, 24 Mar 2024 23:01:12 +0000

Add powerbox command to exec arbitrary command via /run/exec/exec

Diffstat:
Mbin/handle-nsx11-message | 37+++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+), 0 deletions(-)

diff --git a/bin/handle-nsx11-message b/bin/handle-nsx11-message @@ -207,6 +207,39 @@ container-ssh() { 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 display cookie cmd rest 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 + pass-input() { local wid=$1 local entry=$2 @@ -241,6 +274,10 @@ case $data in x11-run "${data#*/}" ;; + (container-exec/*) + container-exec-run "${container-exec#*/}" + ;; + (ssh/*:*) local ssh_hostport="${data#*/}" local ssh_host="${ssh_hostport%:*}"