File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Detect any attempts to call sudo during R CMD check.
2+ # pak's sysreqs feature probes for passwordless sudo, which CRAN flags.
3+ # This workflow confirms that we successfully suppress that probe.
4+ on :
5+ push :
6+ branches : [main, master]
7+ pull_request :
8+
9+ name : sudo-tripwire.yaml
10+
11+ permissions : read-all
12+
13+ jobs :
14+ sudo-tripwire :
15+ runs-on : ubuntu-latest
16+
17+ env :
18+ GITHUB_PAT : ${{ secrets.GITHUB_TOKEN }}
19+ R_KEEP_PKG_SOURCE : yes
20+
21+ steps :
22+ - uses : actions/checkout@v4
23+
24+ - uses : r-lib/actions/setup-pandoc@v2
25+
26+ - uses : r-lib/actions/setup-r@v2
27+ with :
28+ r-version : release
29+ use-public-rspm : true
30+
31+ - uses : r-lib/actions/setup-r-dependencies@v2
32+ with :
33+ extra-packages : any::rcmdcheck
34+ needs : check
35+
36+ - name : Install sudo tripwire
37+ run : |
38+ mkdir -p "$HOME/bin"
39+ cat > "$HOME/bin/sudo" << 'EOF'
40+ #!/bin/bash
41+ echo "SUDO CALLED with args: $*" >> /tmp/sudo-tripwire.log
42+ exit 1
43+ EOF
44+ chmod +x "$HOME/bin/sudo"
45+ echo "$HOME/bin" >> $GITHUB_PATH
46+
47+ - uses : r-lib/actions/check-r-package@v2
48+ with :
49+ upload-snapshots : true
50+ build_args : ' c("--no-manual","--compact-vignettes=gs+qpdf")'
51+
52+ - name : Check for sudo calls
53+ if : always()
54+ run : |
55+ if [ -f /tmp/sudo-tripwire.log ]; then
56+ echo "::error::sudo was called during R CMD check!"
57+ cat /tmp/sudo-tripwire.log
58+ exit 1
59+ else
60+ echo "No sudo calls detected."
61+ fi
Original file line number Diff line number Diff line change @@ -14,5 +14,15 @@ devtools_default_options <- list(
1414 options(devtools_default_options [toset ])
1515 }
1616
17+ # On certain linux systems, pak might call `sudo`, as a probe for
18+ # capabilities. That lays the ground work for a potential need to work with
19+ # sysreqs, but that's not necessary in this case and CRAN flags the
20+ # `sudo -s id` as problematic. Setting `pkg.sysreq` to `FALSE` prevents
21+ # pak from even checking this.
22+ # https://pak.r-lib.org/reference/pak-config.html#pak-configuration
23+ if (Sys.getenv(" _R_CHECK_PACKAGE_NAME_" , " " ) != " " ) {
24+ options(pkg.sysreqs = FALSE )
25+ }
26+
1727 invisible ()
1828}
You can’t perform that action at this time.
0 commit comments