You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/test/integration/targets/become_su/files/sushim.sh

23 lines
565 B
Bash

#!/usr/bin/env bash
# A command wrapper that delegates to su after lowering privilege through an intermediate user (via sudo).
# This allows forcing an environment that always requires a password prompt for su.
set -eu
args=("${@}")
for i in "${!args[@]}"; do
case "${args[$i]}" in
"--intermediate-user")
intermediate_user_idx="${i}"
;;
esac
done
intermediate_user_name="${args[intermediate_user_idx+1]}"
unset "args[intermediate_user_idx]"
unset "args[intermediate_user_idx+1]"
exec sudo -n -u "${intermediate_user_name}" su "${args[@]}"