fix(system): set_hostname hands the name to uci as one shell word (#43) #44

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

What was wrong: set_hostname() ran uci set system.@system[0].hostname='<name>' && … with the name between single quotes of its own; a name with a single quote ended them and the rest ran as root (x';reboot;'). See NetOrk/netork#2456.

Fix: the uci set is built with uci_steps.uci(), which quotes each word with shlex.join.

Tests: tests/unit/test_set_hostname.py — the name, including x';reboot;', $(reboot) and a space, reaches uci as one word, and nothing else runs (red before the fix for the quote).

Closes #43

**What was wrong:** `set_hostname()` ran `uci set system.@system[0].hostname='<name>' && …` with the name between single quotes of its own; a name with a single quote ended them and the rest ran as root (`x';reboot;'`). See NetOrk/netork#2456. **Fix:** the `uci set` is built with `uci_steps.uci()`, which quotes each word with `shlex.join`. **Tests:** `tests/unit/test_set_hostname.py` — the name, including `x';reboot;'`, `$(reboot)` and a space, reaches `uci` as one word, and nothing else runs (red before the fix for the quote). Closes #43
christianmanivong added 1 commit 2026-11-12 21:26:26 +00:00
fix(system): set_hostname hands the name to uci as one shell word (#43)
driver / standard (pull_request) Successful in 18s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 1m5s
driver / test (3.12) (pull_request) Successful in 1m7s
driver / lowest (pull_request) Successful in 30s
driver / test (3.13) (pull_request) Successful in 56s
driver / build (pull_request) Successful in 33s
driver / security (pull_request) Successful in 1m2s
CI / driver (pull_request) Successful in 2m38s
driver / publish (pull_request) Skipped
d3abda34b4
The name stood between single quotes of its own in
`uci set system.@system[0].hostname='<name>'`, so a name with a single
quote ended them and the rest ran as root (NetOrk/netork#2456). The
command is now built with uci_steps.uci(), which quotes each word with
shlex.
christianmanivong merged commit 0ca486bed5 into main 2026-11-13 08:55:11 +00:00
christianmanivong deleted branch fix/hostname-quote-2456 2026-11-13 08:55:11 +00:00
Sign in to join this conversation.