You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gpt-pilot/src/daemon
Aftab 700efe6d16
fix(daemon): skip machine-scope fallback on permission-denied bus errors (#62337)
* fix(daemon): skip machine-scope fallback on permission-denied bus errors; fall back to --user when sudo machine scope fails

When systemctl --user fails with "Failed to connect to bus: Permission
denied", the machine-scope fallback is now skipped. A Permission denied
error means the bus socket exists but the process cannot connect to it,
so --machine user@ would hit the same wall.

Additionally, the sudo path in execSystemctlUser now tries machine scope
first but falls through to a direct --user attempt if it fails, instead
of returning the error immediately.

Fixes #61959

* fix(daemon): guard against double machine-scope call when sudo path already tried it

When SUDO_USER is set and machine scope fails with a non-permission-denied
bus error, execution falls through to the direct --user attempt. If that
also fails with a bus-unavailable message, shouldFallbackToMachineUserScope
returns true and machine scope is tried a second time -- a redundant exec
that was never reachable before this PR opened the fallthrough path.

Add machineScopeAlreadyTried flag and include it in the bottom-fallback
guard condition so the second call is skipped when machine scope was
already attempted in the sudo branch.

Add regression test asserting exactly 2 execFile calls in this scenario.

* fix: keep sudo systemctl scoped

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
7 months ago
..
test-helpers test: share schtasks gateway script fixture 8 months ago
arg-split.ts
…
cmd-argv.test.ts
…
cmd-argv.ts
…
cmd-set.ts
…
constants.test.ts test: trim stale legacy coverage and repair mocks 8 months ago
constants.ts refactor: dedupe daemon lowercase helpers 7 months ago
container-context.ts refactor: dedupe cli daemon readers 7 months ago
diagnostics.ts
…
exec-file.ts
…
inspect.test.ts test: trim stale legacy coverage and repair mocks 8 months ago
inspect.ts refactor: dedupe daemon lowercase helpers 7 months ago
launchd-plist.ts
…
launchd-restart-handoff.test.ts test: trim core partial mocks 8 months ago
launchd-restart-handoff.ts refactor: dedupe cli daemon readers 7 months ago
launchd.integration.e2e.test.ts
…
launchd.test.ts fix: recover launchd restart and restore prompt-cache gate 8 months ago
launchd.ts refactor: dedupe core lowercase helpers 7 months ago
node-service.ts refactor: clarify doctor repair flow 8 months ago
output.ts
…
paths.ts refactor: dedupe cli daemon readers 7 months ago
program-args.test.ts test: trim test partial mocks 8 months ago
program-args.ts fix(runtime): support Node 22.14 installs 8 months ago
runtime-binary.test.ts
…
runtime-binary.ts refactor: dedupe core lowercase helpers 7 months ago
runtime-format.ts
…
runtime-hints.test.ts
…
runtime-hints.ts
…
runtime-hints.windows-paths.test.ts test: speed up core runtime suites 8 months ago
runtime-parse.ts refactor: dedupe daemon lowercase helpers 7 months ago
runtime-paths.test.ts test: trim core partial mocks 8 months ago
runtime-paths.ts refactor: dedupe core lowercase helpers 7 months ago
schtasks-exec.test.ts test: speed up core runtime suites 8 months ago
schtasks-exec.ts
…
schtasks.install.test.ts fix: preserve Windows scheduled task restart/install behavior (#59335) (thanks @tmimmanuel) 8 months ago
schtasks.startup-fallback.test.ts fix: preserve Windows scheduled task restart/install behavior (#59335) (thanks @tmimmanuel) 8 months ago
schtasks.stop.test.ts fix: preserve Windows scheduled task restart/install behavior (#59335) (thanks @tmimmanuel) 8 months ago
schtasks.test.ts fix(daemon): accept 'Last Result' schtasks key variant on Windows (#47726) 8 months ago
schtasks.ts refactor: dedupe daemon lowercase helpers 7 months ago
service-audit.test.ts fix: resolve current ci regressions 8 months ago
service-audit.ts refactor: dedupe core lowercase helpers 7 months ago
service-env.test.ts Tests: fix boundary and late-run drift 7 months ago
service-env.ts refactor: dedupe setup token readers 7 months ago
service-runtime.ts
…
service-types.ts refactor: centralize daemon service start state flow 8 months ago
service.test-helpers.ts test: eliminate remaining clone seams 8 months ago
service.test.ts test: eliminate remaining clone seams 8 months ago
service.ts refactor: dedupe normalization lowercase helpers 7 months ago
systemd-hints.test.ts refactor: centralize systemd unavailable classification 8 months ago
systemd-hints.ts refactor: centralize systemd unavailable classification 8 months ago
systemd-linger.ts refactor: dedupe reply lowercase helpers 7 months ago
systemd-unavailable.test.ts refactor: centralize systemd unavailable classification 8 months ago
systemd-unavailable.ts refactor: dedupe core lowercase helpers 7 months ago
systemd-unit.test.ts
…
systemd-unit.ts
…
systemd.test.ts fix(daemon): skip machine-scope fallback on permission-denied bus errors (#62337) 7 months ago
systemd.ts fix(daemon): skip machine-scope fallback on permission-denied bus errors (#62337) 7 months ago