fix(homelab): cmd_sync missing the geteuid guard every other command has
Every other mutating subcommand (secret, refresh-creds, client add/remove) already re-execs via sudo only when os.geteuid() != 0. cmd_sync was the one exception, calling sudo unconditionally — fails with "No such file or directory: 'sudo'" on minimal root-only images (no sudo binary at all), hit live running `homelab sync` on strong over root SSH. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
17
bin/homelab
17
bin/homelab
@@ -1031,14 +1031,19 @@ def cmd_refresh_creds(args: argparse.Namespace) -> int:
|
|||||||
|
|
||||||
|
|
||||||
def cmd_sync(args: argparse.Namespace) -> int:
|
def cmd_sync(args: argparse.Namespace) -> int:
|
||||||
|
# Unlike every other mutating command here, this one had no os.geteuid()
|
||||||
|
# guard — always shelled out to sudo. Fails outright with "No such file
|
||||||
|
# or directory: 'sudo'" on minimal root-only Linux images (no sudo
|
||||||
|
# binary installed at all) reached via `ssh root@host`, e.g. strong.
|
||||||
|
needs_sudo = os.geteuid() != 0
|
||||||
if sys.platform == "darwin":
|
if sys.platform == "darwin":
|
||||||
return subprocess.call(
|
cmd = ["launchctl", "kickstart", "-k",
|
||||||
["sudo", "launchctl", "kickstart", "-k",
|
|
||||||
"system/network.hubris.homelab-context-sync"]
|
"system/network.hubris.homelab-context-sync"]
|
||||||
)
|
else:
|
||||||
return subprocess.call(
|
cmd = ["systemctl", "start", "homelab-context-sync.service"]
|
||||||
["sudo", "systemctl", "start", "homelab-context-sync.service"]
|
if needs_sudo:
|
||||||
)
|
cmd = ["sudo"] + cmd
|
||||||
|
return subprocess.call(cmd)
|
||||||
|
|
||||||
|
|
||||||
def cmd_mcp(args: argparse.Namespace) -> int:
|
def cmd_mcp(args: argparse.Namespace) -> int:
|
||||||
|
|||||||
Reference in New Issue
Block a user