Restore nopasswd sudo rule on Mac OS X.

This seems to be missing from some (but not all) github runners, so
restore it if it seems to be missing.
This commit is contained in:
Darren Tucker 2023-10-30 13:32:03 +11:00
parent c5698abad6
commit 917ba181c2
No known key found for this signature in database

26
.github/setup_ci.sh vendored
View File

@ -29,18 +29,30 @@ TARGETS=$@
INSTALL_FIDO_PPA="no" INSTALL_FIDO_PPA="no"
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
set -ex set -e
if [ -x "`which lsb_release 2>&1`" ]; then if [ -x "`which lsb_release 2>&1`" ]; then
lsb_release -a lsb_release -a
fi fi
# Ubuntu 22.04 defaults to private home dirs which prevent the if [ ! -z "$SUDO" ]; then
# agent-getpeerid test from running ssh-add as nobody. See # Ubuntu 22.04 defaults to private home dirs which prevent the
# https://github.com/actions/runner-images/issues/6106 # agent-getpeerid test from running ssh-add as nobody. See
if [ ! -z "$SUDO" ] && ! "$SUDO" -u nobody test -x ~; then # https://github.com/actions/runner-images/issues/6106
echo ~ is not executable by nobody, adding perms. if ! "$SUDO" -u nobody test -x ~; then
chmod go+x ~ echo ~ is not executable by nobody, adding perms.
chmod go+x ~
fi
# Some of the Mac OS X runners don't have a nopasswd sudo rule. Regular
# sudo still works, but sudo -u doesn't. Restore the sudo rule.
if ! "$SUDO" grep -E 'runner.*NOPASSWD' /etc/passwd >/dev/null; then
echo "Restoring runner nopasswd rule to sudoers."
echo 'runner ALL=(ALL) NOPASSWD: ALL' |$SUDO tee -a /etc/sudoers
fi
if ! "$SUDO" -u nobody -S test -x ~ </dev/null; then
echo "Still can't sudo to nobody."
exit 1
fi
fi fi
if [ "${TARGETS}" = "kitchensink" ]; then if [ "${TARGETS}" = "kitchensink" ]; then