Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/sudo-tripwire.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Detect any attempts to call sudo during R CMD check.
# pak's sysreqs feature probes for passwordless sudo, which CRAN flags.
# This workflow confirms that we successfully suppress that probe.
on:
push:
branches: [main, master]
pull_request:

name: sudo-tripwire.yaml

permissions: read-all

jobs:
sudo-tripwire:
runs-on: ubuntu-latest

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: release
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- name: Install sudo tripwire
run: |
mkdir -p "$HOME/bin"
cat > "$HOME/bin/sudo" << 'EOF'
#!/bin/bash
echo "SUDO CALLED with args: $*" >> /tmp/sudo-tripwire.log
exit 1
EOF
chmod +x "$HOME/bin/sudo"
echo "$HOME/bin" >> $GITHUB_PATH

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'

- name: Check for sudo calls
if: always()
run: |
if [ -f /tmp/sudo-tripwire.log ]; then
echo "::error::sudo was called during R CMD check!"
cat /tmp/sudo-tripwire.log
exit 1
else
echo "No sudo calls detected."
fi
10 changes: 10 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,15 @@ devtools_default_options <- list(
options(devtools_default_options[toset])
}

# On certain linux systems, pak might call `sudo`, as a probe for
# capabilities. That lays the ground work for a potential need to work with
# sysreqs, but that's not necessary in this case and CRAN flags the
# `sudo -s id` as problematic. Setting `pkg.sysreq` to `FALSE` prevents
# pak from even checking this.
# https://pak.r-lib.org/reference/pak-config.html#pak-configuration
if (Sys.getenv("_R_CHECK_PACKAGE_NAME_", "") != "") {
options(pkg.sysreqs = FALSE)
}

invisible()
}
Loading