Repository navigation
Commit 90ae9a0
committed
fix: make restart honor every CLI flag exactly like start
Since fc2dbda, restart reloads the workspace config between its stop
and start, because main's argument scheme had loaded the booted
snapshot while the container was alive and that snapshot is gone after
the stop. The reload silently clobbered every flag the CLI override
pass had applied: restart --hw-access -f came up with hardware access
disabled and in the background, and -B binds vanished the same way.
start was unaffected only because it never reloads.
The architecture's invariant is that CLI overrides are applied after
any disk load; restart inverted it because the override pass was
welded inline into main(). Extract it into ds_apply_cli_overrides()
and re-run it right after restart's reload. Daemon mode is covered
for free since workers re-exec the full binary with the client's
argv; the socketd bridge passes NULL since its config arrives over
the wire with no CLI overrides to re-apply.
The extraction keeps every case byte-identical except where a second
run over the same argv demanded it: -B now tokenizes a strdup'd copy
instead of writing NULs into argv, -n validates into a scratch buffer
since the discovery pass already captured the names, and -u becomes a
no-op for the same reason. long_options moves to file scope so the
helper can see it.
Three more gaps separated restart from start, all closed here. --reset
moved inside ds_apply_cli_overrides: a pre-scan wipes the config
before the other flags land, so restart resets and re-applies exactly
like start instead of surviving by accident of the eager workspace
save; main's separate reset block and its dead cli_net_mode plumbing
are gone. --conf skips restart's reload entirely: an explicit config
file never read the booted snapshot, so cfg already holds that file
plus the overrides, where the old reload overwrote them with the
workspace copy and then wrote that back over the user's own file. And
the by-name reload now starts from a clean slate via
ds_config_reset_defaults, split out of apply_reset_config without its
trailing save: ds_config_load only overlays keys present in the file,
so loading into the lived-in snapshot cfg left stale values behind
for every conditionally-written key and unioned port_forwards and
upstream_ifaces across the two loads. The reset also frees env vars,
closing a stale-environment hazard.
The result is one pipeline for both commands: load, reset if asked,
apply CLI overrides, save, boot. Persistence was already shared:
start_rootfs mirrors the effective config to the workspace
unconditionally before the fork, and restart ends in start_rootfs.
The enforce_nat_safety argv rescan stays as belt and braces.
Signed-off-by: ravindu644 <droidcasts@protonmail.com>1 parent 5d20069 commit 90ae9a0
5 files changed
Lines changed: 403 additions & 356 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
988 | 988 | | |
989 | 989 | | |
990 | 990 | | |
991 | | - | |
992 | | - | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
993 | 997 | | |
994 | 998 | | |
995 | 999 | | |
| |||
1029 | 1033 | | |
1030 | 1034 | | |
1031 | 1035 | | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
1032 | 1041 | | |
1033 | 1042 | | |
1034 | 1043 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1992 | 1992 | | |
1993 | 1993 | | |
1994 | 1994 | | |
1995 | | - | |
| 1995 | + | |
| 1996 | + | |
1996 | 1997 | | |
1997 | 1998 | | |
1998 | 1999 | | |
| |||
2005 | 2006 | | |
2006 | 2007 | | |
2007 | 2008 | | |
2008 | | - | |
2009 | | - | |
2010 | | - | |
2011 | | - | |
2012 | | - | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
2013 | 2025 | | |
2014 | 2026 | | |
2015 | 2027 | | |
2016 | 2028 | | |
2017 | 2029 | | |
2018 | | - | |
2019 | | - | |
| 2030 | + | |
| 2031 | + | |
2020 | 2032 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
558 | 558 | | |
559 | 559 | | |
560 | 560 | | |
| 561 | + | |
561 | 562 | | |
562 | 563 | | |
563 | 564 | | |
| |||
868 | 869 | | |
869 | 870 | | |
870 | 871 | | |
871 | | - | |
872 | | - | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
873 | 880 | | |
874 | 881 | | |
875 | 882 | | |
| |||
0 commit comments