#!/bin/bash
set -euo pipefail
. /usr/local/libexec/codex-guard-verify
IFS=: read -r account _ target_uid target_gid _ target_home _ < <(getent passwd developer)
[[ $account == developer && $target_uid -ge 1000 && $target_uid -ne 0 && $target_home == /home/developer ]] || {
    echo 'Expected an ordinary developer account with home /home/developer' >&2; exit 1;
}
# setpriv avoids starting a PAM session that could move the child into another cgroup.
exec /usr/bin/setpriv --reuid="$target_uid" --regid="$target_gid" --init-groups \
    --bounding-set=-all --inh-caps=-all --ambient-caps=-all --no-new-privs --reset-env \
    -- "$target_home/.local/libexec/codex-proxy" "$@"
