Test the managed agent's direct-mode launch without privileges
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start with the dispatch and spawn paths in nvx-rs/src/guest/managed_agent/seam.rs and nvx-rs/src/guest/sys/spawn.rs, then review the existing cases in git show 8142d4e54~1:scripts/test_nvx_tools.py. The issue calls for a fork-safe identity-call seam, a setpriv shim, a real spawn path, and a pseudo-terminal helper in nvx-rs/tests/guest_tools.rs. Done means the listed working-directory, identity, PWD, and sandbox STOP cases run without root privileges.
Written by the indexing model from the issue text.
Description
Follow-up to #561, part of #358.
#561 deletes scripts/test_managed_agent.py and the C-backed managed-agent classes of scripts/test_nvx_tools.py, and ports their cases to nvx-rs. The remaining cases need the real direct-mode launch, which no unprivileged test can run today:
TestSystem::spawninnvx-rs/src/guest/managed_agent/seam.rsreturnsENOSYS, so the dispatch tests stop before a workload starts.- The child's
setgroups,setegid,seteuid, andchdircalls innvx-rs/src/guest/sys/spawn.rsrun afterforkand bypass theSystemseam, so a non-root test fails atsetgroupsbefore it reaches the directory check.
The C harnesses stubbed those calls at link time and ran a setpriv shim. These cases remain to port, from ManagedAgentWorkingDirectoryTests and ManagedAgentStopTests (git show 8142d4e54~1:scripts/test_nvx_tools.py):
- Working-directory refusals. A missing directory (
ENOENT), a regular file (ENOTDIR), and a directory that the workload cannot search (EACCES) each printnvx-managed-agent: cannot enter working directory DIR: STRERRORon the workload's stderr, then answerAPP_ERROR(errno, "cwd-failed"), and run nothing. This is the guest side ofFEATURE_EXEC_CWD. - Identity failure. A
setgroupsfailure answersAPP_ERROR(125, "launch-failed")and runs nothing. - Checked directory. A symbolic link retargeted, or a directory renamed, between the check and the exec still starts the workload in the directory that was checked.
- End-to-end
PWD. The default working directory is/; a requested directory sets both the physical directory andPWD; a symbolic link keeps its name inPWD, whilelink/.gives the physical path; an exact environment controlsPWD; a layered environment keeps the agent'sPWD. - Sandbox stop. In sandbox mode,
STOPanswersSTOPPED, and the agent process then exits 0.
What is needed:
- A fork-safe, test-only way to make the identity calls in
spawn.rssucceed or fail without privileges, as the C harness's link-time stubs did. - A
setprivshim throughPaths.setprivthat can change the file system between the directory check and the exec. - A scripted or real spawn path in the dispatch test harness.
- A pseudo-terminal helper in
nvx-rs/tests/guest_tools.rsthat drives a real agent through RESET and STOP, then reaps it.
Running these tests as root in CI would avoid (1) for the success paths, but unprivileged developers would then skip them.
- Dominant language
- Python
- Stars
- 408
- Forks
- 28
- Avg merge
- 15h 20m
- Merged PRs (30d)
- 301
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/nvx
-
Difficulty 3/5 1-2 days Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 36/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
[Device Support Request] HOBEIAN ZG-204ZL (Tuya PIR motion sensor with illuminance)Possibly taken @lenucksi claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
zigpy/zha-device-handlers#5493 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
drevendev/BeautifulRepo#42 ·
Maintainers usually reply within 1 day
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
writerslogic/holographic-memory#93 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
antoine-tena/kiln#47 ·
Maintainers usually reply within 1 day