sanebox: add --sanebox-capsh-arg flag

This commit is contained in:
2024-08-01 03:57:51 +00:00
parent 6135be5f72
commit f678508b33

View File

@@ -94,6 +94,7 @@ portalEnv=()
# arguments to forward onto a specific backend (if that backend is active) # arguments to forward onto a specific backend (if that backend is active)
bwrapArgs=() bwrapArgs=()
capshArgs=()
pastaArgs=() pastaArgs=()
usage() { usage() {
@@ -126,6 +127,7 @@ usage() {
echo ' --sanebox-no-portal' echo ' --sanebox-no-portal'
echo ' undo a previous `--sanebox-portal` arg' echo ' undo a previous `--sanebox-portal` arg'
echo ' --sanebox-bwrap-arg <arg>' echo ' --sanebox-bwrap-arg <arg>'
echo ' --sanebox-capsh-arg <arg>'
echo ' --sanebox-pasta-arg <arg>' echo ' --sanebox-pasta-arg <arg>'
echo ' --sanebox-net-dev <iface>|all' echo ' --sanebox-net-dev <iface>|all'
echo ' --sanebox-net-gateway <ip-address>' echo ' --sanebox-net-gateway <ip-address>'
@@ -550,6 +552,11 @@ parseArgs() {
shift shift
bwrapArgs+=("$bwrapArg") bwrapArgs+=("$bwrapArg")
;; ;;
(--sanebox-capsh-arg)
local capshArg=$1
shift
capshArgs+=("$capshArg")
;;
(--sanebox-pasta-arg) (--sanebox-pasta-arg)
local pastaArg=$1 local pastaArg=$1
shift shift
@@ -808,11 +815,11 @@ landlockGetCli() {
# N.B: capsh passes its arg to bash (via /nix/store/.../bash), which means you have to `-c "my command"` to # N.B: capsh passes its arg to bash (via /nix/store/.../bash), which means you have to `-c "my command"` to
# invoke the actual user command. # invoke the actual user command.
locate _sandboxer "sandboxer" "$LANDLOCK_SANDBOXER_FALLBACK" locate _sandboxer "sandboxer" "$LANDLOCK_SANDBOXER_FALLBACK"
locate _capsh "capsh" "$CAPSH_FALLBACK"
locate _env "env" "$ENV_FALLBACK" locate _env "env" "$ENV_FALLBACK"
capshonlyGetCli
cliArgs=("$_env" LL_FS_RO= LL_FS_RW="$landlockPaths" "${landlockNetFlags[@]}" cliArgs=("$_env" LL_FS_RO= LL_FS_RW="$landlockPaths" "${landlockNetFlags[@]}"
"$_sandboxer" "$_sandboxer"
"$_capsh" "--caps=$capshCapsArg" --no-new-privs --shell="$_env" -- "${portalEnv[@]}" "${cliArgs[@]}" "${cliArgs[@]}"
) )
} }
@@ -866,7 +873,7 @@ capshonlyGetCli() {
locate _capsh "capsh" "$CAPSH_FALLBACK" locate _capsh "capsh" "$CAPSH_FALLBACK"
locate _env "env" "$ENV_FALLBACK" locate _env "env" "$ENV_FALLBACK"
cliArgs=( cliArgs=(
"$_capsh" "--caps=$capshCapsArg" --no-new-privs --shell="$_env" -- "${portalEnv[@]}" "${cliArgs[@]}" "$_capsh" "--caps=$capshCapsArg" --no-new-privs --shell="$_env" "${capshArgs[@]}" -- "${portalEnv[@]}" "${cliArgs[@]}"
) )
} }