fix: expand linux service PATH handling
This commit is contained in:
@@ -6,7 +6,7 @@ import {
|
||||
isVersionManagedNodePath,
|
||||
resolveSystemNodePath,
|
||||
} from "./runtime-paths.js";
|
||||
import { getMinimalServicePathParts } from "./service-env.js";
|
||||
import { getMinimalServicePathPartsFromEnv } from "./service-env.js";
|
||||
import { resolveSystemdUserUnitPath } from "./systemd.js";
|
||||
|
||||
export type GatewayServiceCommand = {
|
||||
@@ -206,6 +206,7 @@ function normalizePathEntry(entry: string, platform: NodeJS.Platform): string {
|
||||
function auditGatewayServicePath(
|
||||
command: GatewayServiceCommand,
|
||||
issues: ServiceConfigIssue[],
|
||||
env: Record<string, string | undefined>,
|
||||
platform: NodeJS.Platform,
|
||||
) {
|
||||
if (platform === "win32") return;
|
||||
@@ -219,12 +220,13 @@ function auditGatewayServicePath(
|
||||
return;
|
||||
}
|
||||
|
||||
const expected = getMinimalServicePathParts({ platform });
|
||||
const expected = getMinimalServicePathPartsFromEnv({ platform, env });
|
||||
const parts = servicePath
|
||||
.split(getPathModule(platform).delimiter)
|
||||
.map((entry) => entry.trim())
|
||||
.filter(Boolean);
|
||||
const normalizedParts = parts.map((entry) => normalizePathEntry(entry, platform));
|
||||
const normalizedExpected = new Set(expected.map((entry) => normalizePathEntry(entry, platform)));
|
||||
const missing = expected.filter((entry) => {
|
||||
const normalized = normalizePathEntry(entry, platform);
|
||||
return !normalizedParts.includes(normalized);
|
||||
@@ -239,6 +241,9 @@ function auditGatewayServicePath(
|
||||
|
||||
const nonMinimal = parts.filter((entry) => {
|
||||
const normalized = normalizePathEntry(entry, platform);
|
||||
if (normalizedExpected.has(normalized)) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
normalized.includes("/.nvm/") ||
|
||||
normalized.includes("/.fnm/") ||
|
||||
@@ -315,7 +320,7 @@ export async function auditGatewayServiceConfig(params: {
|
||||
const platform = params.platform ?? process.platform;
|
||||
|
||||
auditGatewayCommand(params.command?.programArguments, issues);
|
||||
auditGatewayServicePath(params.command, issues, platform);
|
||||
auditGatewayServicePath(params.command, issues, params.env, platform);
|
||||
await auditGatewayRuntime(params.env, params.command, issues, platform);
|
||||
|
||||
if (platform === "linux") {
|
||||
|
||||
Reference in New Issue
Block a user