commit c89fdace29ababe01bf19e336bf695041c85411e parent 60cb8c9c7f0770d3a9fae59da4418f469a1c7cf4 Author: Jan Pobrislo <ccx@te2000.cz> Date: Fri, 18 Dec 2020 01:22:04 +0100 Convert ns_run to execline. Diffstat:
M | sbin/ns_run | | | 24 | +++++++++++++----------- |
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/sbin/ns_run b/sbin/ns_run @@ -1,12 +1,14 @@ -#!/bin/zsh -add_args=( ) -for a in "$@"; do - # execline-safe escaping - add_args+=( \"${a//\\/\\\\}\" ) -done -if [[ $$ != 1 ]]; then - echo >&2 "ns_run: fatal: not PID 1" +#!/command/execlineb -S0 +getpid PID +ifelse { importas -i PID PID test 1 -ne $PID } { + fdmove -c 1 2 + echo "ns_run: fatal: not PID 1" exit 2 -fi -exec unshare -m -u -i /command/execlineb -c "foreground { importas -i HOST HOST hostname $HOST } fdmove -c 3 0 pipeline -d { /root/ns_execline.zsh $add_args } execlineb /dev/stdin" -# exec unshare -m -u -i -n /command/execlineb -c "foreground { importas -i HOST HOST hostname $HOST } fdmove -c 3 0 pipeline -d { /root/ns_execline.zsh $add_args } execlineb /dev/stdin" +} +unexport PID + +unshare -m -u -i # new mount, UTS and IPC namespaces +foreground { importas -i HOST HOST hostname $HOST } +fdmove -c 3 0 # store original stdin as we are calling pipelined script +pipeline -d { /root/ns_execline.zsh $@ } +execlineb /dev/stdin