Split up the giant switch statement in homectl's parse_argv (#40059)

This is in preparation for later changes. The 1500+ line switch statement was very
hard to work with and had quite a bit of duplicated code. This is a rework that
splits outs parts into functions. I split this up into a bunch of commits so that it
can be reasonably reviewed. When viewed as one giant commit, diff just shows
a giant block of removed code and a giant block of added code.

In some cases I wasn't sure why one or the other of the identity arrays is used…
I preserved existing behaviour in all cases.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-01-16 14:31:08 +01:00
committed by GitHub
2 changed files with 983 additions and 1025 deletions
+979 -1023
View File
File diff suppressed because it is too large Load Diff
+4 -2
View File
@@ -578,8 +578,10 @@ cleanup_ssh() (
systemctl is-active -q mysshserver.socket && systemctl stop mysshserver.socket
rm -f /tmp/homed.id_ecdsa /run/systemd/system/mysshserver{@.service,.socket}
systemctl daemon-reload
wait_for_state homedsshtest inactive
homectl remove homedsshtest
if homectl inspect homedsshtest &>/dev/null; then
wait_for_state homedsshtest inactive
homectl remove homedsshtest
fi
for dir in /etc /usr/lib; do
if [[ -f "$dir/pam.d/sshd.bak" ]]; then
mv "$dir/pam.d/sshd.bak" "$dir/pam.d/sshd"