fix(channel): a privileged stream sends the sudo password only to a sudo that asks (NetOrk/netork#818) #83

Merged
christianmanivong merged 3 commits from feature/podman-engine-netork-818 into main 2026-11-17 03:58:35 +00:00
Owner

Prio: P3 -- part of NetOrk/netork#818 (Podman runtime driver), raised to P3 by epic NetOrk/netork#2572.

What changes

open_stream(privileged=True) with a sudo password wrote the password first, for sudo -S. A sudo that does not prompt (NOPASSWD, a cached timestamp) left it on stdin, and it reached the command as the first bytes of the stream. With netOrk reading rootful Podman over sudo podman system dial-stdio (napalm-device-types, same branch name), those bytes go to the Podman API service.

The stream now asks sudo first (sudo -n sh -c true, the shape every privileged command takes) and runs the command through sudo -n when sudo wants no password; only a sudo that asks gets the password. A root login and a driver without a sudo password ask nothing, as before. One extra round trip per privileged stream with a sudo password.

Tests

tests/test_command_channel.py::TestNoPasswordIntoAStream; full suite 430 passed.

Order

Merge after NAPALM/napalm-device-types' PR of the same branch name: test_podman_is_reached_as_root reaches Podman through it, and this repository's CI installs napalm-device-types from main (re-run this PR's CI after that merge).

Prio: P3 -- part of NetOrk/netork#818 (Podman runtime driver), raised to P3 by epic NetOrk/netork#2572. ## What changes `open_stream(privileged=True)` with a sudo password wrote the password first, for `sudo -S`. A sudo that does not prompt (NOPASSWD, a cached timestamp) left it on stdin, and it reached the command as the first bytes of the stream. With netOrk reading rootful Podman over `sudo podman system dial-stdio` (napalm-device-types, same branch name), those bytes go to the Podman API service. The stream now asks sudo first (`sudo -n sh -c true`, the shape every privileged command takes) and runs the command through `sudo -n` when sudo wants no password; only a sudo that asks gets the password. A root login and a driver without a sudo password ask nothing, as before. One extra round trip per privileged stream with a sudo password. ## Tests `tests/test_command_channel.py::TestNoPasswordIntoAStream`; full suite 430 passed. ## Order Merge after NAPALM/napalm-device-types' PR of the same branch name: `test_podman_is_reached_as_root` reaches Podman through it, and this repository's CI installs napalm-device-types from main (re-run this PR's CI after that merge).
christianmanivong added 1 commit 2026-11-16 22:34:02 +00:00
fix(channel): a privileged stream sends the sudo password only to a sudo that asks (NetOrk/netork#818)
driver / standard (pull_request) Failing after 16s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 58s
driver / test (3.12) (pull_request) Failing after 1m1s
driver / test (3.13) (pull_request) Failing after 54s
driver / lowest (pull_request) Failing after 30s
driver / build (pull_request) Successful in 30s
driver / security (pull_request) Successful in 1m9s
CI / driver (pull_request) Failing after 2m41s
driver / publish (pull_request) Skipped
553b4d5153
open_stream(privileged=True) with a sudo password wrote the password first,
for sudo -S. A sudo that does not prompt (NOPASSWD, a cached timestamp) left it
on stdin, where it reached the command as the first bytes of the stream: the
Podman API, over sudo podman system dial-stdio. The stream now asks sudo first
(sudo -n sh -c true) and runs the command through sudo -n when it needs no
password.
christianmanivong added 1 commit 2026-11-16 23:16:34 +00:00
refactor(channel): the sudo probe of a privileged stream lives in _shell (NetOrk/netork#818)
driver / lint (pull_request) Successful in 14s
driver / standard (pull_request) Successful in 19s
driver / types (pull_request) Successful in 1m5s
driver / test (3.13) (pull_request) Failing after 1m1s
driver / test (3.12) (pull_request) Failing after 1m7s
driver / lowest (pull_request) Failing after 29s
driver / build (pull_request) Successful in 38s
driver / security (pull_request) Successful in 1m19s
CI / driver (pull_request) Failing after 2m39s
driver / publish (pull_request) Skipped
69c43d3288
linux.py stays at the size its quality ratchet records.
christianmanivong added 1 commit 2026-11-16 23:17:39 +00:00
refactor(channel): import run_on_transport from the package, as linux.py does (NetOrk/netork#818)
driver / standard (pull_request) Successful in 15s
driver / lint (pull_request) Successful in 13s
driver / types (pull_request) Successful in 55s
driver / test (3.12) (pull_request) Successful in 58s
driver / test (3.13) (pull_request) Successful in 50s
driver / lowest (pull_request) Successful in 25s
driver / build (pull_request) Successful in 26s
driver / security (pull_request) Successful in 55s
CI / driver (pull_request) Successful in 2m20s
driver / publish (pull_request) Skipped
98157f3673
Author
Owner

CI: the one failing test is test_podman_is_reached_as_root (429 passed), because this repository installs napalm-device-types from main, which does not know Podman until NAPALM/napalm-device-types#123 merges. Merge that first, then re-run this CI.

CI: the one failing test is `test_podman_is_reached_as_root` (429 passed), because this repository installs napalm-device-types from main, which does not know Podman until NAPALM/napalm-device-types#123 merges. Merge that first, then re-run this CI.
christianmanivong merged commit 0e1c4e7927 into main 2026-11-17 03:58:35 +00:00
christianmanivong deleted branch feature/podman-engine-netork-818 2026-11-17 03:58:35 +00:00
Sign in to join this conversation.