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_sudo/files/sudoshim.sh

23 lines
574 B
Bash

#!/usr/bin/env bash
# A command wrapper that delegates to sudo after lowering privilege through an intermediate user (via sudo).
# This allows forcing an environment that always requires a password prompt for sudo.
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}" sudo -k "${args[@]}"