mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-28 04:10:41 +00:00
Daemon: harden WSL2 systemctl install checks (#39294)
* Daemon: harden WSL2 systemctl install checks * Changelog: note WSL2 daemon install hardening * Daemon: tighten systemctl failure classification
This commit is contained in:
@@ -278,6 +278,37 @@ function isSystemdUnitNotEnabled(detail: string): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
function isSystemctlBusUnavailable(detail: string): boolean {
|
||||
if (!detail) {
|
||||
return false;
|
||||
}
|
||||
const normalized = detail.toLowerCase();
|
||||
return (
|
||||
normalized.includes("failed to connect to bus") ||
|
||||
normalized.includes("failed to connect to user scope bus") ||
|
||||
normalized.includes("dbus_session_bus_address") ||
|
||||
normalized.includes("xdg_runtime_dir") ||
|
||||
normalized.includes("no medium found")
|
||||
);
|
||||
}
|
||||
|
||||
function isGenericSystemctlIsEnabledFailure(detail: string): boolean {
|
||||
if (!detail) {
|
||||
return false;
|
||||
}
|
||||
const normalized = detail.toLowerCase().trim();
|
||||
return (
|
||||
normalized.startsWith("command failed: systemctl") &&
|
||||
normalized.includes(" is-enabled ") &&
|
||||
!normalized.includes("permission denied") &&
|
||||
!normalized.includes("access denied") &&
|
||||
!normalized.includes("no space left") &&
|
||||
!normalized.includes("read-only file system") &&
|
||||
!normalized.includes("out of memory") &&
|
||||
!normalized.includes("cannot allocate memory")
|
||||
);
|
||||
}
|
||||
|
||||
function resolveSystemctlDirectUserScopeArgs(): string[] {
|
||||
return ["--user"];
|
||||
}
|
||||
@@ -538,7 +569,12 @@ export async function isSystemdServiceEnabled(args: GatewayServiceEnvArgs): Prom
|
||||
return true;
|
||||
}
|
||||
const detail = readSystemctlDetail(res);
|
||||
if (isSystemctlMissing(detail) || isSystemdUnitNotEnabled(detail)) {
|
||||
if (
|
||||
isSystemctlMissing(detail) ||
|
||||
isSystemdUnitNotEnabled(detail) ||
|
||||
isSystemctlBusUnavailable(detail) ||
|
||||
isGenericSystemctlIsEnabledFailure(detail)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
throw new Error(`systemctl is-enabled unavailable: ${detail || "unknown error"}`.trim());
|
||||
|
||||
Reference in New Issue
Block a user