#!/usr/bin/env bash # SPDX-License-Identifier: GPL-2.0-or-later # Copyright (C) 2026 Bryan Joshua Pedini # Fake sudo for the AUR E2E tests (tests/e2e/aur.bats installs it as /usr/local/bin/sudo on the # pacman backend): archlinux:latest has no sudo and the E2E run is offline. Runs # "sudo [--] COMMAND..." as root through su, which the fixture (FIXTURE_AUR=1) makes passwordless # for the members of wheel (pam_wheel trust), with the variables sudo sets for the command: # SUDO_USER, SUDO_UID and SUDO_GID. Used for the applet's own re-exec and by the fake paru. [[ ${1:-} != -- ]] || shift if (($# == 0)); then echo "usage: sudo [--] command..." >&2 exit 1 fi # shellcheck disable=SC2016 # $1... belong to the root shell started by su exec su -s /bin/bash root -c 'exec env SUDO_USER="$1" SUDO_UID="$2" SUDO_GID="$3" "${@:4}"' -- sudo "$(id -un)" "$(id -u)" "$(id -g)" "$@"