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.
Add it
Section titled “Add it”Create a project with the capability, or add it to a native-go project:
synopkgland init -t native-go --with root-ops my-appsynopkgland add root-opsBoth 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/shset -euid -urootOps: true requires at least one root/<name>.sh; a root/ directory without it fails check.
Script rules
Section titled “Script rules”| Rule | Value |
|---|---|
| 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 |
| Size | At most 16 KiB (16384 bytes) |
| Content | Starts with #!/bin/sh and a newline; UTF-8 text with no NUL byte, run as /bin/sh with no arguments |
| Environment | PATH=/usr/syno/bin:/usr/syno/sbin:/usr/bin:/bin, LANG=C, HOME=/, working directory / |
| Run time | 20 seconds, then the script is stopped |
| Output | Merged standard output and error, at most 1 MiB |
Approval
Section titled “Approval”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:
| Change | New approval |
|---|---|
Any edit to a root/*.sh file, or adding or removing one | Yes |
Changing entry, or the delegate scope, destinations, operations or lifetime | Yes |
| Changing the version number or the UI only | No |
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
Section titled “DSM 7.1”DSM 7.1 lacks SYNO.Core.TaskScheduler.Root and SYNO.Core.EventScheduler.Root; approval there requires these API versions:
| Step | DSM 7.1 | DSM 7.2+ |
|---|---|---|
| Check the password | PasswordConfirm v1 | PasswordConfirm v2, which returns a one-use token |
| Create the tasks | EventScheduler create v1 and TaskScheduler create v3 | EventScheduler.Root and TaskScheduler.Root, with the token |
| Read the tasks back | TaskScheduler list v2 and get v3 | TaskScheduler 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.
Use it
Section titled “Use it”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.
Limits
Section titled “Limits”| Limit | Value |
|---|---|
| Minimum DSM | 7.1-42661 |
| Architectures | x86_64, aarch64 and armv7 (armv7 not verified on a NAS) |
Who can call root.run | Administrators |
Troubleshooting
Section titled “Troubleshooting”| Symptom or code | Fix |
|---|---|
internal from root.run | Every 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_required | Call root.run from an administrator’s live DSM session. |
STANDALONE_ROOT_OPS_UNUSED | root/ exists but rootOps: true is missing. Add the capability, or delete root/. |
needs-admin-approval in synopkgland status | An administrator approves again in Administrator setup. |
| Uninstall takes long | The 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.