Skip to content

Commit 7a21854

Browse files
committed
test(ci): add rootless capability regression test on ubuntu-24.04
Run supervisor capability unit tests on a bare GHA ubuntu-24.04 runner as an unprivileged user, where CAP_SETPCAP is unavailable and the bounding set is non-empty. This exercises the EPERM + non-empty path that caused the NVIDIA#2069 crash. Also simplify drop_privileges_succeeds_for_current_group to expect success unconditionally now that the EPERM + non-empty case is tolerated. Refs: NVIDIA#2069 Assisted-by: Claude Signed-off-by: Wayne Sun <[email protected]>
1 parent 956ccb5 commit 7a21854

2 files changed

Lines changed: 30 additions & 15 deletions

File tree

‎.github/workflows/branch-checks.yml‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,35 @@ jobs:
172172
- name: Test
173173
run: mise run test:python
174174

175+
rootless-caps:
176+
name: Rootless capability tests
177+
needs: pr_metadata
178+
if: needs.pr_metadata.outputs.should_run == 'true'
179+
runs-on: ubuntu-24.04
180+
steps:
181+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
182+
183+
- uses: dtolnay/rust-toolchain@fa04a1451ff1842e2626ccb99004d0195b455a88
184+
with:
185+
toolchain: "1.95.0"
186+
187+
- name: Run supervisor capability tests without CAP_SETPCAP
188+
run: |
189+
sudo useradd -m testuser
190+
sudo chmod a+rx /home/runner /home/runner/work /home/runner/work/OpenShell
191+
sudo chmod -R a+rX "$GITHUB_WORKSPACE"
192+
sudo cp -r /home/runner/.rustup /home/testuser/.rustup
193+
sudo chown -R testuser: /home/testuser/.rustup
194+
sudo mkdir -p /home/testuser/.cargo
195+
sudo cp /home/runner/.cargo/config.toml /home/testuser/.cargo/ 2>/dev/null || true
196+
sudo chown -R testuser: /home/testuser/.cargo
197+
sudo -u testuser env \
198+
PATH="/home/testuser/.cargo/bin:/home/testuser/.rustup/toolchains/1.95.0-x86_64-unknown-linux-gnu/bin:$PATH" \
199+
CARGO_HOME="/home/testuser/.cargo" \
200+
RUSTUP_HOME="/home/testuser/.rustup" \
201+
CARGO_TARGET_DIR="/home/testuser/target" \
202+
bash -c "cd $GITHUB_WORKSPACE && cargo test -p openshell-supervisor-process --lib -- capability_bounding drop_privileges"
203+
175204
markdown:
176205
name: Markdown
177206
needs: pr_metadata

‎crates/openshell-supervisor-process/src/process.rs‎

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,21 +1273,7 @@ mod tests {
12731273

12741274
let result = drop_privileges(&policy);
12751275

1276-
#[cfg(target_os = "linux")]
1277-
{
1278-
if capability_bounding_set_clear_available() {
1279-
assert!(result.is_ok(), "drop_privileges failed: {result:?}");
1280-
} else {
1281-
let msg = format!("{}", result.unwrap_err());
1282-
assert!(
1283-
msg.contains("Failed to clear child capability bounding set"),
1284-
"unexpected failure: {msg}"
1285-
);
1286-
}
1287-
}
1288-
1289-
#[cfg(not(target_os = "linux"))]
1290-
assert!(result.is_ok());
1276+
assert!(result.is_ok(), "drop_privileges failed: {result:?}");
12911277
}
12921278

12931279
#[test]

0 commit comments

Comments
 (0)