fix(system): set_hostname quotes the name in its root commands (#64) #65

Merged
christianmanivong merged 2 commits from fix/hostname-quote-2456 into main 2026-11-13 08:55:14 +00:00
Owner

What was wrong: set_hostname() ran postconf -e 'myhostname = <fqdn>', hostname '<name>' and the /etc/pve/nodes/<old> → <new> move with the values between single quotes of their own; a name with a single quote ended them and the rest ran as root (x';reboot;'). See NetOrk/netork#2456. /etc/hostname, /etc/hosts and /etc/mailname were already written through base64.

Fix: each value passes through shlex.quote; set_hostname keeps its length (quality baseline).

Tests: tests/test_set_hostname.py — the runtime hostname, Postfix's myhostname and the node directory paths each reach the shell as one word, and no command runs what the name holds (red before the fix). The existing rename tests pass unchanged.

The five failures of tests/test_time_sync.py in my environment fail the same way on main; they are not touched here.

Closes #64

**What was wrong:** `set_hostname()` ran `postconf -e 'myhostname = <fqdn>'`, `hostname '<name>'` and the `/etc/pve/nodes/<old>` → `<new>` move with the values between single quotes of their own; a name with a single quote ended them and the rest ran as root (`x';reboot;'`). See NetOrk/netork#2456. `/etc/hostname`, `/etc/hosts` and `/etc/mailname` were already written through base64. **Fix:** each value passes through `shlex.quote`; `set_hostname` keeps its length (quality baseline). **Tests:** `tests/test_set_hostname.py` — the runtime hostname, Postfix's `myhostname` and the node directory paths each reach the shell as one word, and no command runs what the name holds (red before the fix). The existing rename tests pass unchanged. The five failures of `tests/test_time_sync.py` in my environment fail the same way on `main`; they are not touched here. Closes #64
christianmanivong added 1 commit 2026-11-12 21:26:26 +00:00
fix(system): set_hostname quotes the name in its root commands (#64)
driver / standard (pull_request) Successful in 18s
driver / lint (pull_request) Successful in 15s
driver / types (pull_request) Successful in 57s
driver / test (3.12) (pull_request) Failing after 1m6s
driver / test (3.13) (pull_request) Failing after 1m6s
driver / lowest (pull_request) Successful in 35s
driver / build (pull_request) Successful in 30s
driver / security (pull_request) Successful in 1m19s
CI / driver (pull_request) Failing after 2m58s
driver / publish (pull_request) Skipped
a13cd0202f
`postconf -e 'myhostname = <fqdn>'`, `hostname '<name>'` and the
/etc/pve/nodes move put the name between single quotes of their own, so
a name with a single quote ended them and the rest ran as root
(NetOrk/netork#2456). Each value is now passed through shlex.quote.
/etc/hostname, /etc/hosts and /etc/mailname were already written
through base64.
christianmanivong added 1 commit 2026-11-13 07:55:59 +00:00
test(time-sync): follow napalm-device-types 4.36.0, which keeps DHCP's servers
driver / lint (pull_request) Successful in 13s
driver / standard (pull_request) Successful in 16s
driver / types (pull_request) Successful in 51s
driver / test (3.13) (pull_request) Successful in 53s
driver / test (3.12) (pull_request) Successful in 1m0s
driver / lowest (pull_request) Successful in 28s
driver / build (pull_request) Successful in 25s
driver / security (pull_request) Successful in 54s
CI / driver (pull_request) Successful in 2m3s
driver / publish (pull_request) Skipped
66828a9564
napalm-device-types 4.36.0 (released after main's last CI run) changed
PosixTimeSyncMixin: get_time_sync() reports DHCP-provided servers apart
(dhcp_ntp_servers), and configure_time_sync() no longer comments out the
DHCP client's chrony sourcedir; it gives back one that 4.35.0 took out
(NetOrk/netork#2380). CI installs the newest release, so five time-sync
tests failed on every branch.

The tests now expect that behaviour, read DHCP's servers apart, and check
that a node 4.35.0 aligned gets its DHCP sourcedir back. The floor moves
to 4.36.0, so the lowest-versions job tests the same behaviour; README,
CHANGELOG and the module docstring say what a write leaves alone.
christianmanivong merged commit 6fccd7a8f0 into main 2026-11-13 08:55:14 +00:00
christianmanivong deleted branch fix/hostname-quote-2456 2026-11-13 08:55:14 +00:00
Sign in to join this conversation.