@synopackageland/cli 0.52.16 → 0.52.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.52.17 (2026-11-09)
4
+
5
+ - Use SDK 0.53.26 by default.
6
+ - Ship the SDK initializer for Compose services that declare `console` (the container init for interactive console Apps), not only for `storage_init`.
7
+ - Refuse `console` and `run_as.sudo` with an older Compose SDK (`SDK_COMPOSE_UNSUPPORTED`: SDK 0.53.26 or later).
8
+ - Show Compose services that opt into `run_as.sudo` in `inspect` (`Container privilege: <service>: sudo inside container (<reason>)`) and in the inspect JSON, and write them to INFO `synopkgland_container_sudo` (JSON service and reason) for catalogs; `inspect` refuses an SPK whose INFO differs from its Compose plan.
9
+ - Add the `COMPOSE_SUDO_INVALID`, `COMPOSE_CONSOLE_INVALID` and `COMPOSE_CONSOLE_SUDO_UNAVAILABLE` explanations.
10
+
3
11
  ## 0.52.16 (2026-11-09)
4
12
 
5
13
  - Pin SDK 0.53.25 for Compose planning.
package/README.md CHANGED
@@ -691,7 +691,9 @@ absence of a GPU produces no device mapping. See the matching SDK's Compose GPU
691
691
  documentation for the security boundary and hardware validation limits.
692
692
 
693
693
  DSM's native provider adds NET_BIND_SERVICE to the bounding set for Compose
694
- packages. The SDK still emits `cap_drop: [ALL]` and requests no `cap_add`; the
694
+ packages. The SDK still emits `cap_drop: [ALL]` and requests no `cap_add` unless
695
+ a console service declares `run_as.sudo` (see the SDK Compose documentation on
696
+ interactive console services); the
695
697
  nonroot package process with no-new-privileges has zero effective, permitted and
696
698
  ambient capabilities on the tested provider. This general platform behavior is
697
699
  not a GPU blocker. Plan metadata describes SDK policy, not an attestation of the
package/dist/cli.js CHANGED
@@ -156,6 +156,7 @@ function formatSpkReport(spk, report) {
156
156
  ...(report.compose.hostUdp?.length
157
157
  ? [`Host UDP listeners: ${report.compose.hostUdp.map(l => `${l.port} (${l.purpose})`).join(", ")}`]
158
158
  : []),
159
+ ...(report.compose.containerSudo ?? []).map((s) => `Container privilege: ${s.service}: sudo inside container (${s.reason}). It starts as the package account; sudo commands run as container root, which is root on the NAS for mounted folders.`),
159
160
  report.compose.readiness.limitation,
160
161
  ]
161
162
  : []),
@@ -1,7 +1,7 @@
1
1
  export { goPrivateCovers } from './go-env.js';
2
2
  import { type ExecutorManifest } from './sdk-executor-manifest.js';
3
3
  /** Pinned SDK for CLI-owned controllers and Compose planning; App pins take precedence. */
4
- export declare const DEFAULT_SDK_VERSION = "0.53.23";
4
+ export declare const DEFAULT_SDK_VERSION = "0.53.26";
5
5
  export declare const SDK_PACKAGE = "@synopackageland/sdk";
6
6
  export declare const SDK_MODULE = "github.com/synopackageland/syno-pkg-land-sdk";
7
7
  export declare const EXECUTOR_MODULE = "github.com/synopackageland/syno-pkg-land-sdk/executor";
@@ -5,7 +5,7 @@ import { tmpdir } from 'node:os';
5
5
  import { join } from 'node:path';
6
6
  import { readExecutorManifest, predatesExecutorManifest } from './sdk-executor-manifest.js';
7
7
  /** Pinned SDK for CLI-owned controllers and Compose planning; App pins take precedence. */
8
- export const DEFAULT_SDK_VERSION = '0.53.23';
8
+ export const DEFAULT_SDK_VERSION = '0.53.26';
9
9
  export const SDK_PACKAGE = '@synopackageland/sdk';
10
10
  export const SDK_MODULE = 'github.com/synopackageland/syno-pkg-land-sdk';
11
11
  export const EXECUTOR_MODULE = `${SDK_MODULE}/executor`;
@@ -12,7 +12,7 @@ export declare const OPTIONAL_INFO_FIELDS: readonly ["displayname", "maintainer_
12
12
  * shown by Package Center and used by first-party packages; the others are
13
13
  * SDK metadata, including the native layout's declared Portal alias.
14
14
  */
15
- export declare const EXTRA_INFO_FIELDS: readonly ["changelog", "synopkgland_executor_sha256", "synopkgland_portal_alias", "spk_land_metadata"];
15
+ export declare const EXTRA_INFO_FIELDS: readonly ["changelog", "synopkgland_executor_sha256", "synopkgland_portal_alias", "spk_land_metadata", "synopkgland_container_sudo"];
16
16
  /** Optional fields whose value is "yes" or "no". */
17
17
  export declare const BOOLEAN_INFO_FIELDS: readonly ["support_center", "checkport", "startable", "ctl_stop", "ctl_uninstall", "precheckstartstop", "beta", "install_reboot", "support_conf_folder", "silent_install", "silent_upgrade", "silent_uninstall", "offline_install", "thirdparty", "support_move", "use_deprecated_replace_mechanism", "install_on_cold_storage"];
18
18
  /** Language codes of `displayname_<lang>` and `description_<lang>`. */
@@ -22,7 +22,7 @@ export const OPTIONAL_INFO_FIELDS = [
22
22
  * shown by Package Center and used by first-party packages; the others are
23
23
  * SDK metadata, including the native layout's declared Portal alias.
24
24
  */
25
- export const EXTRA_INFO_FIELDS = ["changelog", "synopkgland_executor_sha256", "synopkgland_portal_alias", "spk_land_metadata"];
25
+ export const EXTRA_INFO_FIELDS = ["changelog", "synopkgland_executor_sha256", "synopkgland_portal_alias", "spk_land_metadata", "synopkgland_container_sudo"];
26
26
  /** Optional fields whose value is "yes" or "no". */
27
27
  export const BOOLEAN_INFO_FIELDS = [
28
28
  "support_center", "checkport", "startable", "ctl_stop", "ctl_uninstall", "precheckstartstop", "beta",
@@ -25,15 +25,40 @@ export const COMPOSE_ERRORS = {
25
25
  description: "Container readiness exhausted its declared startup budget.",
26
26
  suggestion: "Inspect the safe phase code in daemon/daemon.log and upstream migration/bootstrap health. Declare a sufficient bounded startup_timeout_seconds and rebuild; keep ingress closed until ready.",
27
27
  },
28
+ COMPOSE_TMPFS_UNDECLARED: {
29
+ code: "COMPOSE_TMPFS_UNDECLARED",
30
+ description: "A Compose service mounts a memory tmpfs that the package did not declare.",
31
+ suggestion: "Put temporary files on disk: declare compose.services.<service>.scratch: [<target>] and set TMPDIR to it if the App reads it. Use compose.services.<service>.tmpfs only for small memory data; the SDK bounds it to 64 MiB unless you give a size.",
32
+ },
33
+ COMPOSE_TMPFS_UNBOUNDED: {
34
+ code: "COMPOSE_TMPFS_UNBOUNDED",
35
+ description: "A tmpfs size of 0 means unlimited memory.",
36
+ suggestion: "Omit size for the SDK default of 64 MiB, or give a positive size such as 16m. Use disk scratch for larger temporary data.",
37
+ },
38
+ COMPOSE_TMPFS_INVALID: {
39
+ code: "COMPOSE_TMPFS_INVALID",
40
+ description: "The tmpfs or scratch declaration is malformed, duplicated or conflicts with another mount.",
41
+ suggestion: "Declare each clean absolute container target once, outside /synopkgland, as either scratch or tmpfs (at most 8 scratch and 16 tmpfs targets per service).",
42
+ },
43
+ COMPOSE_SCRATCH_INVALID: {
44
+ code: "COMPOSE_SCRATCH_INVALID",
45
+ description: "The disk scratch declaration is invalid.",
46
+ suggestion: "Declare clean absolute targets that no volume, Share or package data already uses; a Compose tmpfs at the same target is replaced. Keep the service nonroot and declare explicit entrypoint/command argv so the SDK can empty scratch before the App starts.",
47
+ },
48
+ COMPOSE_SCRATCH_NOT_READY: {
49
+ code: "COMPOSE_SCRATCH_NOT_READY",
50
+ description: "The disk scratch directory is missing, not owned by the package UID, or not writable.",
51
+ suggestion: "Reinstall or upgrade with the matching SDK so preinst creates scratch as the package account; inspect free space and quota. Do not add root or chown hooks.",
52
+ },
28
53
  COMPOSE_STORAGE_INIT_INVALID: {
29
54
  code: "COMPOSE_STORAGE_INIT_INVALID",
30
55
  description: "The container storage initialization declaration is invalid.",
31
- suggestion: "Declare private subdirectories on writable mounts and explicit upstream entrypoint/command argv; keep the service nonroot. The SDK initializer is supplied by the SPK.",
56
+ suggestion: "Declare subdirectories on writable mounts (package storage or a read/write Shared Folder), or only runtime environment, with explicit upstream entrypoint/command argv; keep the service nonroot. Runtime files stay on package storage. The SDK initializer is supplied by the SPK.",
32
57
  },
33
58
  COMPOSE_STORAGE_NOT_WRITABLE: {
34
59
  code: "COMPOSE_STORAGE_NOT_WRITABLE",
35
60
  description: "The package UID cannot initialize or write its private container data.",
36
- suggestion: "Use a writable mount base with a package-owned private subtree; inspect ownership, permissions, read-only storage, quota and free space. Do not add root or chown hooks.",
61
+ suggestion: "Use a writable mount base with a package-owned private subtree, or a Shared Folder that DSM grants read/write to the package; inspect ownership, permissions, read-only storage, quota and free space. Do not add root or chown hooks.",
37
62
  },
38
63
  COMPOSE_STORAGE_COMMAND_INVALID: {
39
64
  code: "COMPOSE_STORAGE_COMMAND_INVALID",
@@ -205,6 +230,21 @@ export const COMPOSE_ERRORS = {
205
230
  description: "Container-root service the declared value cannot bind host files or Shares.",
206
231
  suggestion: "Use the package identity; container-root requires explicit reason, bridge and no host bind. Never elevate the App on the host.",
207
232
  },
233
+ COMPOSE_SUDO_INVALID: {
234
+ code: "COMPOSE_SUDO_INVALID",
235
+ description: "The sudo opt-in of a console service is invalid.",
236
+ suggestion: "Use run_as: {mode: package, sudo: {reason: <one line>}} with console, bridge networking, no run_as.capabilities, no GPU and scratch outside /tmp.",
237
+ },
238
+ COMPOSE_CONSOLE_INVALID: {
239
+ code: "COMPOSE_CONSOLE_INVALID",
240
+ description: "The console container init declaration is invalid.",
241
+ suggestion: "Give console.home at or below a writable mount, an explicit entrypoint, the package identity, and tmp at or below a scratch target.",
242
+ },
243
+ COMPOSE_CONSOLE_SUDO_UNAVAILABLE: {
244
+ code: "COMPOSE_CONSOLE_SUDO_UNAVAILABLE",
245
+ description: "The image does not meet the sudo contract.",
246
+ suggestion: "Install setuid sudo, add a NOPASSWD sudoers rule for console.user and let the package UID append /etc/passwd and /etc/group; or remove run_as.sudo.",
247
+ },
208
248
  COMPOSE_ROOT_OPT_IN_INVALID: {
209
249
  code: "COMPOSE_ROOT_OPT_IN_INVALID",
210
250
  description: "Container root needs a reason and bridge networking.",
@@ -42,14 +42,32 @@ export interface ComposePlan {
42
42
  acceptance_blockers: string[];
43
43
  services: Array<{
44
44
  storage_init?: {
45
- directories: Array<{
45
+ directories?: Array<{
46
46
  base: string;
47
47
  path: string;
48
+ share?: boolean;
48
49
  }>;
50
+ scratch?: string[];
49
51
  };
52
+ scratch?: string[];
53
+ tmpfs?: Array<{
54
+ target: string;
55
+ bytes: number;
56
+ }>;
50
57
  service: string;
51
58
  user: string;
52
59
  container_root: boolean;
60
+ /** SDK container init for interactive console services. */
61
+ console?: {
62
+ home: string;
63
+ user?: string;
64
+ tmp?: string;
65
+ };
66
+ /** Explicit per-command sudo inside the container, with its reason. */
67
+ sudo?: {
68
+ reason: string;
69
+ };
70
+ cap_add?: string[] | null;
53
71
  egress: string;
54
72
  network: string;
55
73
  mounts: unknown[] | null;
@@ -145,6 +163,15 @@ export declare function writeComposePayload(c: ComposeApp, root: string, target:
145
163
  export declare function renderComposeInstall(pkg: string): string;
146
164
  /** The same SDK entry point supplies the package-account install materializer. */
147
165
  export declare function buildComposeControl(m: StandaloneManifest, arch: NativeArchFamily, work: string, run: import("./build.js").CommandRunner): Promise<string | undefined>;
166
+ /** The SDK binary serves storage_init and the console container init. */
167
+ export declare const usesStorageInit: (s: ComposePlan["services"][number]) => boolean;
168
+ /** INFO key listing sudo services and reasons, as JSON, for catalogs. */
169
+ export declare const CONTAINER_SUDO_INFO = "synopkgland_container_sudo";
170
+ /** Services that may run single commands as container root through sudo. */
171
+ export declare function containerSudo(plan: ComposePlan): Array<{
172
+ service: string;
173
+ reason: string;
174
+ }>;
148
175
  /** The SPK supplies this read-only binary; upstream registry images stay unchanged. */
149
176
  export declare function buildComposeStorageInit(m: StandaloneManifest, arch: NativeArchFamily, work: string, run: import("./build.js").CommandRunner): Promise<string | undefined>;
150
177
  /** Only the build resolves registry metadata; check and inspect remain offline. */
@@ -113,6 +113,16 @@ export function readComposeApp(value, root, arches, fail, context = {}) {
113
113
  if (major === 0 && (minor < 53 || minor === 53 && patch < minimumPatch))
114
114
  return invalid(`Folder selection requires SDK 0.53.${minimumPatch} or later.`, 'SDK_COMPOSE_UNSUPPORTED');
115
115
  }
116
+ if (record(value.services) && Object.values(value.services).some((s) => record(s) && (s.scratch !== undefined || s.tmpfs !== undefined))) {
117
+ const [major, minor, patch] = sdk.split('.').map(Number);
118
+ if (major === 0 && (minor < 53 || minor === 53 && patch < 25))
119
+ return invalid('Disk scratch and declared tmpfs require SDK 0.53.25 or later.', 'SDK_COMPOSE_UNSUPPORTED');
120
+ }
121
+ if (record(value.services) && Object.values(value.services).some((s) => record(s) && (s.console !== undefined || (record(s.run_as) && s.run_as.sudo !== undefined)))) {
122
+ const [major, minor, patch] = sdk.split('.').map(Number);
123
+ if (major === 0 && (minor < 53 || minor === 53 && patch < 26))
124
+ return invalid('The console container init and run_as.sudo require SDK 0.53.26 or later.', 'SDK_COMPOSE_UNSUPPORTED');
125
+ }
116
126
  let targets = {};
117
127
  if (value.helpers !== undefined) {
118
128
  const d = readDaemon({ exec: "_sso/gateway", targets: value.helpers }, root, arches, fail, context.package);
@@ -261,9 +271,19 @@ export async function buildComposeControl(m, arch, work, run) {
261
271
  return;
262
272
  return buildComposeTool(m, arch, work, run, "plan");
263
273
  }
274
+ /** The SDK binary serves storage_init and the console container init. */
275
+ export const usesStorageInit = (s) => !!s.storage_init || !!s.console;
276
+ /** INFO key listing sudo services and reasons, as JSON, for catalogs. */
277
+ export const CONTAINER_SUDO_INFO = "synopkgland_container_sudo";
278
+ /** Services that may run single commands as container root through sudo. */
279
+ export function containerSudo(plan) {
280
+ return plan.services
281
+ .filter((s) => s.sudo)
282
+ .map((s) => ({ service: s.service, reason: s.sudo.reason }));
283
+ }
264
284
  /** The SPK supplies this read-only binary; upstream registry images stay unchanged. */
265
285
  export async function buildComposeStorageInit(m, arch, work, run) {
266
- if (!m.compose?.plan.services.some((s) => s.storage_init))
286
+ if (!m.compose?.plan.services.some(usesStorageInit))
267
287
  return;
268
288
  return buildComposeTool(m, arch, work, run, "storage-init");
269
289
  }
@@ -47,6 +47,11 @@ export interface SpkInspection {
47
47
  compose?: {
48
48
  projectName?: string;
49
49
  hostUdp?: ComposeApp["plan"]["host_udp"];
50
+ /** Services that run single commands as container root through sudo. */
51
+ containerSudo?: Array<{
52
+ service: string;
53
+ reason: string;
54
+ }>;
50
55
  devices?: ComposeApp["plan"]["devices"];
51
56
  ingress?: ComposeApp["plan"]["ingress"];
52
57
  images: unknown[];
@@ -19,7 +19,7 @@ import { inspectCtlArtifacts } from './native-http-inspect.js';
19
19
  import { dsmLauncherType } from "../contract/app-launch.js";
20
20
  import { isWebLaunchMode, resolvedWebLaunch, trustedAppEntryPath, usesAuthGateway, } from "../contract/web-launch.js";
21
21
  import { loadContract } from "../contract/load.js";
22
- import { readComposeApp, composeSource, dsmComposeProblem, COMPOSE_READINESS_LIMITATION, COMPOSE_HOST_READINESS_LIMITATION, } from "./compose.js";
22
+ import { readComposeApp, usesStorageInit, containerSudo, CONTAINER_SUDO_INFO, composeSource, dsmComposeProblem, COMPOSE_READINESS_LIMITATION, COMPOSE_HOST_READINESS_LIMITATION, } from "./compose.js";
23
23
  import { gatewayReviewReport } from "./gateway-review.js";
24
24
  import { createHash } from "node:crypto";
25
25
  import { inspectNativeLayout } from "./native-layout.js";
@@ -906,7 +906,7 @@ async function inspectUnifiedCompose(dir, payload, metadata, findings, baseline
906
906
  if (payload.find((p) => p.path === "compose/control")?.mode !== "0755")
907
907
  throw new Error("Compose materializer must be executable");
908
908
  const initializer = join(root, "compose/storage-init");
909
- if (c.plan.services.some((s) => s.storage_init)) {
909
+ if (c.plan.services.some(usesStorageInit)) {
910
910
  const error = checkCgiBinary(root, initializer, arch);
911
911
  if (error)
912
912
  throw new Error(error.message);
@@ -933,12 +933,18 @@ async function inspectUnifiedCompose(dir, payload, metadata, findings, baseline
933
933
  throw new Error("daemon configuration differs from the SDK profile");
934
934
  if (!isDsmAtLeast(info.os_min_ver, CONTAINER_MIN_DSM))
935
935
  throw new Error("Compose requires DSM >= 7.2.1");
936
+ // Catalogs read sudo services from INFO; it must state exactly the plan.
937
+ const sudoInfo = info[CONTAINER_SUDO_INFO]?.replace(/\\([\\"$`])/g, "$1");
938
+ const sudo = containerSudo(c.plan);
939
+ if ((sudo.length ? JSON.stringify(sudo) : undefined) !== sudoInfo)
940
+ throw new Error(`INFO ${CONTAINER_SUDO_INFO} differs from the Compose plan`);
936
941
  const storageProblem = dsmComposeProblem(c);
937
942
  if (storageProblem)
938
943
  throw new Error(`[${storageProblem.code}] ${storageProblem.message}`);
939
944
  base.compose = {
940
945
  projectName: c.plan.project_name,
941
946
  ...(c.plan.host_udp?.length ? { hostUdp: c.plan.host_udp } : {}),
947
+ ...(containerSudo(c.plan).length ? { containerSudo: containerSudo(c.plan) } : {}),
942
948
  ...(c.plan.devices ? { devices: c.plan.devices } : {}),
943
949
  ...(c.plan.ingress ? { ingress: c.plan.ingress } : {}),
944
950
  images: c.plan.images,
@@ -39,7 +39,7 @@ import { copyStandaloneNotices, copyNoticeTree } from "../build-spk/notices.js";
39
39
  import { copyAppTree } from "./bridge-app.js";
40
40
  import { isBridgeBackend } from "./bridge-backend.js";
41
41
  import { hostScriptName, renderHostAdapterScript } from "./host-adapter.js";
42
- import { writeComposePayload } from "./compose.js";
42
+ import { CONTAINER_SUDO_INFO, containerSudo, usesStorageInit, writeComposePayload } from "./compose.js";
43
43
  import { daemonConfig, copyDaemonPayload, daemonSdkVersion } from "./daemon.js";
44
44
  import { DAEMON_INGRESS_CONFIG, renderDaemonIngressConfig } from "./daemon-ingress.js";
45
45
  import { gatewayCgiPaths, gatewayExternalAccess, GATEWAY_CONFIG_PATH, GATEWAY_EXEC, identityGatewayConfig, identityGatewayDeclaration, } from "./identity-gateway.js";
@@ -237,7 +237,7 @@ export async function assembleStandaloneSpk(options) {
237
237
  throw new StandaloneBuildError("SDK_COMPOSE_BUILD_FAILED", "Compose runtime artifact required.");
238
238
  copyFileSync(options.composeControl, join(target, "control"));
239
239
  chmodSync(join(target, "control"), EXEC_MODE);
240
- if (manifest.compose.plan.services.some((s) => s.storage_init)) {
240
+ if (manifest.compose.plan.services.some(usesStorageInit)) {
241
241
  if (!options.composeStorageInit)
242
242
  throw new StandaloneBuildError("SDK_COMPOSE_BUILD_FAILED", "Compose storage initializer required.");
243
243
  copyFileSync(options.composeStorageInit, join(target, "storage-init"));
@@ -462,6 +462,10 @@ export function renderInfo(manifest, arch, checksum, executorDigest) {
462
462
  if (dependencies)
463
463
  fields.push(["install_dep_packages", dependencies]);
464
464
  fields.push(...metadataInfoFields(manifest.metadata));
465
+ // Catalog-facing: services that run single commands as container root via sudo.
466
+ const sudo = manifest.compose ? containerSudo(manifest.compose.plan) : [];
467
+ if (sudo.length)
468
+ fields.push([CONTAINER_SUDO_INFO, JSON.stringify(sudo)]);
465
469
  // Background packages need prestart: it runs before DSM's systemd-user-unit acquire.
466
470
  if (manifest.daemon || manifest.compose || manifest.capabilities.jobs)
467
471
  fields.push(["precheckstartstop", "yes"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synopackageland/cli",
3
- "version": "0.52.16",
3
+ "version": "0.52.17",
4
4
  "description": "Syno Package Land Developer Kit CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -137,6 +137,7 @@ a build operator trust decision. `check`/`inspect` remain offline.
137
137
  | Egress | isolated internal networks, or explicit internet outbound bridge; fine allowlist declarations fail |
138
138
  | Public ports | All upstream publishes removed; the host gateway dials the declared web service on its fixed bridge IP; auxiliary ingress is unsupported |
139
139
  | Root | Fixed package UID/GID by default; per-service container-root requires reason, bridge and no host binds; only CHOWN/FOWNER/SETUID/SETGID opt-ins |
140
+ | Sudo inside the container | Interactive console services only (`console` + `run_as: {mode: package, sudo: {reason}}`); starts as the package UID, Shares stay bound and are writable as root through sudo; fixed capability set; `inspect` prints `Container privilege: <service>: sudo inside container (<reason>)` |
140
141
  | Build, hooks, privileged, host PID/IPC, devices, sockets | Rejected; no host root workaround |
141
142
  | Secret/config file resources, plugins, replicas/deploy | Rejected until their bounded delivery/runtime contract exists |
142
143
  | Subpath hosting | Unsupported; use the app's dedicated origin at / |