fix: use owner-level unidesk state
This commit is contained in:
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
|
||||
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { dirname } from "node:path";
|
||||
import type { UniDeskConfig } from "./config";
|
||||
import { rootPath } from "./config";
|
||||
import { rootPath, stateRoot } from "./config";
|
||||
import { runCommand, type CommandResult } from "./command";
|
||||
import { resolveEgressProxySourceRef, type MasterShadowsocksSourceSpec } from "./egress-proxy-sources";
|
||||
import type { RenderedCliResult } from "./output";
|
||||
@@ -332,11 +332,11 @@ function managedClientSpec(raw: Record<string, unknown>, label: string): HostPro
|
||||
mode,
|
||||
upstreamUrl: httpsUrlField(raw, "upstreamUrl", label),
|
||||
version: stringField(raw, "version", label),
|
||||
archiveCachePath: repoStatePathField(raw, "archiveCachePath", label),
|
||||
archiveCachePath: canonicalStatePathField(raw, "archiveCachePath", label),
|
||||
archiveSha256: sha256Field(raw, "archiveSha256", label),
|
||||
archiveInstallPath: absolutePathField(raw, "archiveInstallPath", label),
|
||||
binaryMember: relativePathField(raw, "binaryMember", label),
|
||||
binaryCachePath: repoStatePathField(raw, "binaryCachePath", label),
|
||||
binaryCachePath: canonicalStatePathField(raw, "binaryCachePath", label),
|
||||
binarySha256: sha256Field(raw, "binarySha256", label),
|
||||
installPath: absolutePathField(raw, "installPath", label),
|
||||
configPath: absolutePathField(raw, "configPath", label),
|
||||
@@ -1314,10 +1314,10 @@ function repoYamlPathField(obj: Record<string, unknown>, key: string, label: str
|
||||
return value;
|
||||
}
|
||||
|
||||
function repoStatePathField(obj: Record<string, unknown>, key: string, label: string): string {
|
||||
function canonicalStatePathField(obj: Record<string, unknown>, key: string, label: string): string {
|
||||
const value = stringField(obj, key, label);
|
||||
if (value.startsWith("/") || value.includes("..") || !value.startsWith(".state/")) {
|
||||
throw new Error(`${label}.${key} must be a repo-relative .state/ path without ..`);
|
||||
if (value.includes("..") || !value.startsWith(`${stateRoot}/`)) {
|
||||
throw new Error(`${label}.${key} must be under ${stateRoot}/ without ..`);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user