Skip to content
Syno Package Land
Language: English

Run fixed administrator operations

Root operations let your app run a fixed set of shell scripts as root. You ship them in root/, an administrator approves them once with the DSM password, and your backend then runs one by name with root.run. Your app cannot run anything else or pass arguments.

Create a project with the capability, or add it to a native-go project:

Terminal window
synopkgland init -t native-go --with root-ops my-app
Terminal window
synopkgland add root-ops

Both write capabilities: {rootOps: true} to dsm-package.yaml; os_min_ver must be at least 7.1-42661, and add root-ops raises a lower value. A new project contains the example root/whoami.sh:

#!/bin/sh
set -eu
id -u

rootOps: true requires at least one root/<name>.sh; a root/ directory without it fails check.

RuleValue
File name^[a-z][a-z0-9_]{0,31}\.sh$, for example restart_service.sh
Other entries in root/Not allowed; each script is a regular file, not a symlink or directory
SizeAt most 16 KiB (16384 bytes)
ContentStarts with #!/bin/sh and a newline; UTF-8 text with no NUL byte, run as /bin/sh with no arguments
EnvironmentPATH=/usr/syno/bin:/usr/syno/sbin:/usr/bin:/bin, LANG=C, HOME=/, working directory /
Run time20 seconds, then the script is stopped
OutputMerged standard output and error, at most 1 MiB

An administrator approves the package once with the DSM password in Administrator setup. Approval records a digest (SHA-256) of every root/*.sh file, so only those exact scripts run. DSM checks the password; the app neither receives nor stores it. An empty submission sends nothing, a wrong password keeps the value for retry, and ordinary users are told to ask an administrator.

In a Vue UI the panel is the SDK’s ExecutorSettings, with the generated ExecutorGate.vue showing ExecutorApproval until approval; preload mounts pages hidden until the first status is read. A plain UI shows the panel in the DSM language.

These changes force a new approval:

ChangeNew approval
Any edit to a root/*.sh file, or adding or removing oneYes
Changing entry, or the delegate scope, destinations, operations or lifetimeYes
Changing the version number or the UI onlyNo

synopkgland status shows needs-admin-approval until approval, then ready. The executor reads its tasks back at start, every 10 minutes after a pass and every minute after a failure; executor.status reports tasks (checking, ready, stale or failed). Approval, the control task’s start, stop and purge, and a scope selection read both tasks back first.

DSM 7.1 lacks SYNO.Core.TaskScheduler.Root and SYNO.Core.EventScheduler.Root; approval there requires these API versions:

StepDSM 7.1DSM 7.2+
Check the passwordPasswordConfirm v1PasswordConfirm v2, which returns a one-use token
Create the tasksEventScheduler create v1 and TaskScheduler create v3EventScheduler.Root and TaskScheduler.Root, with the token
Read the tasks backTaskScheduler list v2 and get v3TaskScheduler list v3 and get v4

The app, status, deploy and uninstall use them only when DSM reports an unsupported version (104) or a missing method (103). Other errors, such as a wrong password (3121), are reported and never retried, and a create is never retried. On both paths nothing runs until the tasks’ owner, type and script match exactly.

If approval stops after creating one task, the app deletes what it created in that attempt, so no boot task is left without its control task. A failed approval shows its DSM error code, and a wrong password or withdrawn approval still offers to try again.

On DSM 7.1 the check records consent but does not gate task creation: any signed-in administrator session can create root tasks without your app, so it is not the server-enforced proof DSM 7.2+ gives.

The DSM 7.1 path is verified against the API set and error codes of DSM 7.1.1-42962; the 104 fallback is not verified on a NAS.

The generated native-go project has the root.run route; the generated UI has no button for it, so call it from your own code. Only administrators can call it.

const result = await ctx.call<{ output: string }>('root.run', { name: 'whoami' })

name is the file name without .sh; the result is { output }, the merged output of the script.

executor.status returns whether the approval is ready, with tasks, to every signed-in user. While the package is stopped or an upgrade waits for approval, it returns ready: false, state: "paused", with the next step in next. The root-only /usr/local/etc/synopkgland/<package>/executor.log names the cause.

LimitValue
Minimum DSM7.1-42661
Architecturesx86_64, aarch64 and armv7 (armv7 not verified on a NAS)
Who can call root.runAdministrators
Symptom or codeFix
internal from root.runEvery failure reaches your app as internal: unknown name, non-zero exit, timeout, missing approval, or no executor. Check synopkgland status and run the script with sh.
admin_required, session_requiredCall root.run from an administrator’s live DSM session.
STANDALONE_ROOT_OPS_UNUSEDroot/ exists but rootOps: true is missing. Add the capability, or delete root/.
needs-admin-approval in synopkgland statusAn administrator approves again in Administrator setup.
Uninstall takes longThe executor deletes the boot and control tasks through DSM, then its protected folders. synopkgland-executor log lines give task cleanup timing and purge timing, each with the package name; on DSM 7.1 they are only in the journal, so run journalctl -t synopkgland-executor.

See Errors for every code, and Data and removal for what uninstall removes.