@synopackageland/cli 0.6.1 → 0.7.1
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 +846 -0
- package/README.md +81 -89
- package/dist/add.d.ts +4 -1
- package/dist/add.js +45 -17
- package/dist/build-spk/delegate-scope.d.ts +6 -0
- package/dist/build-spk/delegate-scope.js +34 -0
- package/dist/build-spk/dsm-arch.d.ts +7 -1
- package/dist/build-spk/dsm-arch.js +24 -28
- package/dist/build-spk/dsm-platforms.json +42 -0
- package/dist/build-spk/dsm-version.d.ts +11 -0
- package/dist/build-spk/dsm-version.js +17 -0
- package/dist/build-spk/gateway.js +8 -4
- package/dist/build-spk/generator.js +30 -5
- package/dist/build-spk/go-toolchain.d.ts +20 -0
- package/dist/build-spk/go-toolchain.js +44 -0
- package/dist/build-spk/notices.js +4 -1
- package/dist/build-spk/resource-worker.js +3 -0
- package/dist/build-spk/wizard-messages.d.ts +66 -0
- package/dist/build-spk/wizard-messages.js +75 -9
- package/dist/cli.js +28 -14
- package/dist/contract/schema-validate.js +8 -0
- package/dist/contract/validate.js +30 -0
- package/dist/deploy/deploy.d.ts +1 -1
- package/dist/deploy/deploy.js +8 -0
- package/dist/deploy/native-install-values.d.ts +17 -0
- package/dist/deploy/native-install-values.js +32 -0
- package/dist/deploy/plan.d.ts +6 -2
- package/dist/deploy/plan.js +58 -7
- package/dist/deploy/spk-version.js +1 -1
- package/dist/error-registry.js +54 -20
- package/dist/host/dsm-client.d.ts +8 -4
- package/dist/host/dsm-client.js +63 -21
- package/dist/host/dsm-http.js +24 -2
- package/dist/host/types.d.ts +3 -1
- package/dist/info.js +45 -10
- package/dist/init.d.ts +3 -0
- package/dist/init.js +50 -19
- package/dist/package-metadata.d.ts +21 -0
- package/dist/package-metadata.js +101 -0
- package/dist/portal/alias.d.ts +25 -0
- package/dist/portal/alias.js +48 -0
- package/dist/portal/package.d.ts +33 -0
- package/dist/portal/package.js +116 -0
- package/dist/runtime/delegate-contract.d.ts +79 -0
- package/dist/runtime/delegate-contract.js +27 -0
- package/dist/runtime/dsm-version.d.ts +6 -0
- package/dist/runtime/dsm-version.js +8 -0
- package/dist/runtime/executor-build.js +10 -6
- package/dist/runtime/executor-inspect.d.ts +3 -0
- package/dist/runtime/executor-inspect.js +11 -5
- package/dist/runtime/executor-policy.d.ts +12 -0
- package/dist/runtime/executor-policy.js +43 -3
- package/dist/runtime/executor-scope-task.d.ts +4 -0
- package/dist/runtime/executor-scope-task.js +21 -0
- package/dist/runtime/executor-tasks.d.ts +2 -1
- package/dist/runtime/executor-tasks.js +4 -4
- package/dist/skill.js +1 -0
- package/dist/standalone/api-permissions.d.ts +10 -0
- package/dist/standalone/api-permissions.js +19 -2
- package/dist/standalone/background.d.ts +16 -0
- package/dist/standalone/background.js +69 -2
- package/dist/standalone/binary.d.ts +1 -1
- package/dist/standalone/binary.js +22 -8
- package/dist/standalone/build.d.ts +1 -1
- package/dist/standalone/build.js +38 -8
- package/dist/standalone/daemon.d.ts +1 -0
- package/dist/standalone/daemon.js +10 -5
- package/dist/standalone/dsm-window.d.ts +3 -1
- package/dist/standalone/dsm-window.js +78 -49
- package/dist/standalone/inspect-spk.d.ts +8 -0
- package/dist/standalone/inspect-spk.js +110 -27
- package/dist/standalone/lifecycle.js +86 -8
- package/dist/standalone/manifest.d.ts +13 -0
- package/dist/standalone/manifest.js +57 -8
- package/dist/standalone/native-authorization-window.d.ts +1 -1
- package/dist/standalone/native-authorization-window.js +9 -1
- package/dist/standalone/native-layout.d.ts +3 -0
- package/dist/standalone/native-layout.js +37 -5
- package/dist/standalone/native-root-window.d.ts +4 -2
- package/dist/standalone/native-root-window.js +33 -18
- package/dist/standalone/portal-window.d.ts +21 -0
- package/dist/standalone/portal-window.js +155 -0
- package/dist/standalone/portal.d.ts +4 -0
- package/dist/standalone/portal.js +4 -0
- package/dist/standalone/resource.d.ts +5 -3
- package/dist/standalone/resource.js +6 -3
- package/dist/standalone/root-window.d.ts +4 -1
- package/dist/standalone/root-window.js +193 -36
- package/dist/standalone/spk.d.ts +1 -1
- package/dist/standalone/spk.js +25 -7
- package/dist/templates/_daemon/go.mod +1 -1
- package/dist/templates/_daemon/main.go +6 -3
- package/dist/templates/_daemon/main_test.go +82 -9
- package/dist/templates/_daemon/testdata/child.go +3 -0
- package/dist/templates/_executor/README.md +130 -16
- package/dist/templates/_executor/anchor.go +156 -0
- package/dist/templates/_executor/anchor_test.go +161 -0
- package/dist/templates/_executor/apppriv_review_test.go +1 -1
- package/dist/templates/_executor/cancel_contract_test.go +236 -0
- package/dist/templates/_executor/copy.go +64 -0
- package/dist/templates/_executor/copy_test.go +88 -0
- package/dist/templates/_executor/digest_review_test.go +2 -2
- package/dist/templates/_executor/dsm.go +63 -13
- package/dist/templates/_executor/dsm_test.go +95 -1
- package/dist/templates/_executor/executor.go +260 -49
- package/dist/templates/_executor/executor_test.go +36 -6
- package/dist/templates/_executor/go.mod +2 -0
- package/dist/templates/_executor/identity.go +27 -1
- package/dist/templates/_executor/identity_kernel_linux_test.go +60 -0
- package/dist/templates/_executor/identity_linux.go +82 -0
- package/dist/templates/_executor/identity_security_test.go +43 -0
- package/dist/templates/_executor/internal/lifecycle/lifecycle.go +5 -0
- package/dist/templates/_executor/internal/lifecycle/lifecycle_test.go +61 -3
- package/dist/templates/_executor/internal/taskscript/boot.sh +9 -9
- package/dist/templates/_executor/internal/taskscript/cmd/main.go +2 -2
- package/dist/templates/_executor/internal/taskscript/control.sh +15 -10
- package/dist/templates/_executor/internal/taskscript/tasks.go +5 -3
- package/dist/templates/_executor/lifecycle_test.go +11 -0
- package/dist/templates/_executor/link_linux.go +28 -0
- package/dist/templates/_executor/long_running_test.go +530 -0
- package/dist/templates/_executor/main.go +83 -25
- package/dist/templates/_executor/managed.go +3 -3
- package/dist/templates/_executor/managed_test.go +3 -3
- package/dist/templates/_executor/move_linux.go +490 -0
- package/dist/templates/_executor/move_linux_test.go +460 -0
- package/dist/templates/_executor/move_validation.go +46 -0
- package/dist/templates/_executor/move_validation_test.go +187 -0
- package/dist/templates/_executor/operations.go +926 -0
- package/dist/templates/_executor/path_test.go +18 -0
- package/dist/templates/_executor/pid.go +37 -0
- package/dist/templates/_executor/pid_test.go +113 -0
- package/dist/templates/_executor/platform_linux.go +24 -173
- package/dist/templates/_executor/platform_linux_test.go +9 -65
- package/dist/templates/_executor/platform_other.go +38 -4
- package/dist/templates/_executor/process.go +3 -0
- package/dist/templates/_executor/purge_log.go +18 -0
- package/dist/templates/_executor/records.go +242 -0
- package/dist/templates/_executor/scope_cancel_contract_test.go +91 -0
- package/dist/templates/_executor/scope_client.go +37 -0
- package/dist/templates/_executor/scope_contract.go +12 -0
- package/dist/templates/_executor/selected_scope.go +146 -0
- package/dist/templates/_executor/selected_scope_test.go +186 -0
- package/dist/templates/_executor/status_disabled_test.go +33 -0
- package/dist/templates/_executor/store.go +4 -3
- package/dist/templates/_executor/supervise.go +109 -0
- package/dist/templates/_executor/supervise_test.go +130 -0
- package/dist/templates/_executor/task_race_review_test.go +1 -1
- package/dist/templates/_executor/tasks.go +52 -15
- package/dist/templates/_executor/tasks_dsm71_test.go +114 -0
- package/dist/templates/_executor/tasks_review_test.go +1 -1
- package/dist/templates/_executor/tasks_test.go +62 -5
- package/dist/templates/_executor/upgrade_watch_test.go +13 -5
- package/dist/templates/_executor/watch.go +8 -0
- package/dist/templates/_executor/watch_test.go +23 -2
- package/dist/templates/_executor/write_review_linux_test.go +4 -12
- package/dist/templates/_gateway/go.mod +2 -0
- package/dist/templates/_shared/AGENTS.md +129 -0
- package/dist/templates/binary/dsm-package.yaml +24 -0
- package/dist/templates/binary/i18n/messages/de.json +4 -0
- package/dist/templates/binary/i18n/messages/en.json +4 -0
- package/dist/templates/binary/i18n/messages/es.json +4 -0
- package/dist/templates/binary/i18n/messages/fr.json +4 -0
- package/dist/templates/binary/i18n/messages/it.json +4 -0
- package/dist/templates/binary/i18n/messages/ja.json +4 -0
- package/dist/templates/binary/i18n/messages/ko.json +4 -0
- package/dist/templates/binary/i18n/messages/zh-CN.json +4 -0
- package/dist/templates/binary/i18n/messages/zh-TW.json +4 -0
- package/dist/templates/binary/ui/app.js +19 -4
- package/dist/templates/native-authorization/AuthorizationGate.vue +5 -3
- package/dist/templates/native-authorization/i18n/de.json +1 -0
- package/dist/templates/native-authorization/i18n/en.json +1 -0
- package/dist/templates/native-authorization/i18n/es.json +2 -1
- package/dist/templates/native-authorization/i18n/fr.json +1 -0
- package/dist/templates/native-authorization/i18n/it.json +11 -10
- package/dist/templates/native-authorization/i18n/ja.json +1 -0
- package/dist/templates/native-authorization/i18n/ko.json +10 -9
- package/dist/templates/native-authorization/i18n/zh-CN.json +6 -5
- package/dist/templates/native-authorization/i18n/zh-TW.json +6 -5
- package/dist/templates/native-go/README.md +43 -10
- package/dist/templates/native-go/backend/cmd/app/main.go +27 -7
- package/dist/templates/native-go/backend/go.mod +1 -1
- package/dist/templates/native-go/backend/internal/api/entry_test.go +47 -0
- package/dist/templates/native-go/backend/internal/api/permissions_test.go +3 -3
- package/dist/templates/native-go/backend/internal/api/registry.go +11 -0
- package/dist/templates/native-go/backend/internal/api/sdk-permissions.json +14 -1
- package/dist/templates/native-go/backend/internal/api/server.go +18 -5
- package/dist/templates/native-go/backend/internal/app/delegate_config.go +57 -0
- package/dist/templates/native-go/backend/internal/app/delegate_config_test.go +28 -0
- package/dist/templates/native-go/backend/internal/app/portal.go +30 -0
- package/dist/templates/native-go/backend/internal/app/portal_test.go +55 -0
- package/dist/templates/native-go/backend/internal/app/routes.go +8 -2
- package/dist/templates/native-go/backend/internal/background/runner.go +1 -1
- package/dist/templates/native-go/backend/internal/background/store.go +16 -14
- package/dist/templates/native-go/backend/internal/dsm/admin.go +8 -2
- package/dist/templates/native-go/backend/internal/dsm/admin_linux.go +43 -13
- package/dist/templates/native-go/backend/internal/dsm/admin_linux_test.go +56 -0
- package/dist/templates/native-go/backend/internal/dsm/admin_other.go +4 -1
- package/dist/templates/native-go/backend/internal/dsm/apppriv.go +30 -0
- package/dist/templates/native-go/backend/internal/dsm/bridge_file.go +75 -0
- package/dist/templates/native-go/backend/internal/dsm/bridge_file_test.go +57 -0
- package/dist/templates/native-go/backend/internal/dsm/entry.go +177 -0
- package/dist/templates/native-go/backend/internal/dsm/entry_test.go +315 -0
- package/dist/templates/native-go/backend/internal/dsm/native/admin-armv7.elf +0 -0
- package/dist/templates/native-go/backend/internal/dsm/native/apppriv-aarch64.elf +0 -0
- package/dist/templates/native-go/backend/internal/dsm/native/apppriv-armv7.elf +0 -0
- package/dist/templates/native-go/backend/internal/dsm/native/apppriv-x86_64.elf +0 -0
- package/dist/templates/native-go/backend/internal/dsm/native/apppriv_check.c +33 -0
- package/dist/templates/native-go/backend/internal/dsm/native/build.sh +13 -4
- package/dist/templates/native-go/backend/internal/dsm/native/provenance.json +9 -3
- package/dist/templates/native-go/backend/internal/filestation/check_permission.go +71 -0
- package/dist/templates/native-go/backend/internal/filestation/check_permission_test.go +77 -0
- package/dist/templates/native-go/backend/internal/filestation/client.go +39 -3
- package/dist/templates/native-go/backend/internal/filestation/download_dsm71_test.go +82 -0
- package/dist/templates/native-go/backend/internal/filestation/sdk_policy_test.go +39 -0
- package/dist/templates/native-go/backend/internal/filestation/service.go +1 -1
- package/dist/templates/native-go/backend/internal/identity/README.md +5 -1
- package/dist/templates/native-go/backend/internal/identity/dsm.go +24 -5
- package/dist/templates/native-go/backend/internal/identity/http.go +1 -1
- package/dist/templates/native-go/backend/internal/identity/identity_test.go +48 -1
- package/dist/templates/native-go/backend/internal/identity/service.go +1 -1
- package/dist/templates/native-go/backend/internal/portal/portal.go +138 -0
- package/dist/templates/native-go/backend/internal/portal/portal_test.go +89 -0
- package/dist/templates/native-go/dsm-package.yaml +20 -1
- package/dist/templates/native-go/i18n/glossary.json +2 -1
- package/dist/templates/native-go/i18n/messages/de.json +1 -0
- package/dist/templates/native-go/i18n/messages/en.json +1 -0
- package/dist/templates/native-go/i18n/messages/es.json +1 -0
- package/dist/templates/native-go/i18n/messages/fr.json +1 -0
- package/dist/templates/native-go/i18n/messages/it.json +1 -0
- package/dist/templates/native-go/i18n/messages/ja.json +1 -0
- package/dist/templates/native-go/i18n/messages/ko.json +1 -0
- package/dist/templates/native-go/i18n/messages/zh-CN.json +1 -0
- package/dist/templates/native-go/i18n/messages/zh-TW.json +1 -0
- package/dist/templates/native-go/ui/app.css +10 -0
- package/dist/templates/native-go/ui/app.js +11 -1
- package/dist/templates/native-go-delegate/DELEGATE.md +126 -5
- package/dist/templates/native-go-delegate/backend/cmd/background-worker/main.go +7 -0
- package/dist/templates/native-go-delegate/backend/internal/app/delegate.go +11 -1
- package/dist/templates/native-go-delegate/backend/internal/app/delegate_routes_test.go +14 -0
- package/dist/templates/native-go-delegate/backend/internal/background/delegated_moves.go +270 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/admission_recovery_test.go +410 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/cancel_contract_test.go +95 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/client.go +8 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/destination.go +110 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/destination_state.go +117 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/destination_state_test.go +60 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/destination_test.go +116 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/example.go +81 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/example_test.go +91 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/executor_contract_test.go +511 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/files.go +1 -1
- package/dist/templates/native-go-delegate/backend/internal/delegate/long_running_routes.go +92 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/long_running_routes_test.go +99 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/move.go +348 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/move_test.go +351 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/operations_list.go +65 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/operations_list_test.go +114 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/retry_test.go +1 -1
- package/dist/templates/native-go-delegate/backend/internal/delegate/service.go +58 -17
- package/dist/templates/native-go-delegate/backend/internal/delegate/staging.go +121 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/status_disabled_test.go +51 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/testdata/executor_contract.txt +112 -0
- package/dist/templates/native-go-delegate/backend/internal/delegate/transient_contract_test.go +137 -0
- package/dist/templates/native-go-delegate/backend/internal/filestation/files.go +1 -31
- package/dist/templates/native-go-delegate/frontend/src/CapabilityPanels.vue +30 -3
- package/dist/templates/native-go-delegate/frontend/src/delegate/BackgroundSavePanel.vue +113 -0
- package/dist/templates/native-go-delegate/frontend/src/delegate/copy.ts +5 -6
- package/dist/templates/native-go-delegate/frontend/test/background-save.test.ts +121 -0
- package/dist/templates/native-go-delegate/frontend/test/delegate.test.ts +15 -0
- package/dist/templates/native-go-delegate/frontend/test/scope-settings.test.ts +49 -0
- package/dist/templates/native-go-delegate/test.sh +1 -0
- package/dist/templates/native-go-jobs/frontend/src/background/i18n/de.json +2 -2
- package/dist/templates/native-go-jobs/frontend/src/background/i18n/en.json +2 -2
- package/dist/templates/native-go-jobs/frontend/src/background/i18n/es.json +12 -12
- package/dist/templates/native-go-jobs/frontend/src/background/i18n/fr.json +4 -4
- package/dist/templates/native-go-jobs/frontend/src/background/i18n/it.json +17 -17
- package/dist/templates/native-go-jobs/frontend/src/background/i18n/ja.json +7 -7
- package/dist/templates/native-go-jobs/frontend/src/background/i18n/ko.json +15 -15
- package/dist/templates/native-go-jobs/frontend/src/background/i18n/zh-CN.json +3 -3
- package/dist/templates/native-go-jobs/frontend/src/background/i18n/zh-TW.json +2 -2
- package/dist/templates/native-go-jobs/frontend/test/background.test.ts +25 -28
- package/dist/templates/native-go-root-ops/backend/internal/app/executor.go +30 -2
- package/dist/templates/native-go-root-ops/backend/internal/app/executor_test.go +64 -0
- package/dist/templates/native-go-vue/README.md +4 -0
- package/dist/templates/native-go-vue/frontend/package-lock.json +4 -4
- package/dist/templates/native-go-vue/frontend/package.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/App.vue +18 -13
- package/dist/templates/native-go-vue/frontend/src/context.ts +31 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/ExecutorSettings.vue +54 -9
- package/dist/templates/native-go-vue/frontend/src/delegate/catalogs.ts +11 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/copy.test.ts +12 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/copy.ts +4 -4
- package/dist/templates/native-go-vue/frontend/src/delegate/executor-settings.test.ts +23 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/executor-setup.ts +8 -2
- package/dist/templates/native-go-vue/frontend/src/delegate/facade.test.ts +100 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/facade.ts +85 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/de.json +47 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/en.json +13 -2
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/es.json +47 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/fr.json +47 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/it.json +47 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/ja.json +47 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/ko.json +47 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/save/de.json +42 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/save/en.json +42 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/save/es.json +42 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/save/fr.json +42 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/save/it.json +42 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/save/ja.json +42 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/save/ko.json +42 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/save/zh-CN.json +42 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/save/zh-TW.json +42 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/zh-CN.json +47 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/i18n/zh-TW.json +16 -5
- package/dist/templates/native-go-vue/frontend/src/delegate/long-running.ts +57 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/save-copy.test.ts +12 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/save-copy.ts +24 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/scoped-picker.test.ts +12 -0
- package/dist/templates/native-go-vue/frontend/src/delegate/scoped-picker.ts +21 -0
- package/dist/templates/native-go-vue/frontend/src/files/files.test.ts +7 -0
- package/dist/templates/native-go-vue/frontend/src/i18n/de.json +20 -0
- package/dist/templates/native-go-vue/frontend/src/i18n/en.json +20 -0
- package/dist/templates/native-go-vue/frontend/src/i18n/es.json +20 -0
- package/dist/templates/native-go-vue/frontend/src/i18n/fr.json +20 -0
- package/dist/templates/native-go-vue/frontend/src/i18n/it.json +20 -0
- package/dist/templates/native-go-vue/frontend/src/i18n/ja.json +20 -0
- package/dist/templates/native-go-vue/frontend/src/i18n/ko.json +20 -0
- package/dist/templates/native-go-vue/frontend/src/i18n/zh-CN.json +20 -0
- package/dist/templates/native-go-vue/frontend/src/i18n/zh-TW.json +20 -0
- package/dist/templates/native-go-vue/frontend/src/i18n.ts +13 -0
- package/dist/templates/native-go-vue/frontend/src/identity/LoginPage.vue +16 -14
- package/dist/templates/native-go-vue/frontend/src/identity/i18n/de.json +27 -0
- package/dist/templates/native-go-vue/frontend/src/identity/i18n/en.json +27 -0
- package/dist/templates/native-go-vue/frontend/src/identity/i18n/es.json +27 -0
- package/dist/templates/native-go-vue/frontend/src/identity/i18n/fr.json +27 -0
- package/dist/templates/native-go-vue/frontend/src/identity/i18n/it.json +27 -0
- package/dist/templates/native-go-vue/frontend/src/identity/i18n/ja.json +27 -0
- package/dist/templates/native-go-vue/frontend/src/identity/i18n/ko.json +27 -0
- package/dist/templates/native-go-vue/frontend/src/identity/i18n/zh-CN.json +27 -0
- package/dist/templates/native-go-vue/frontend/src/identity/i18n/zh-TW.json +27 -0
- package/dist/templates/native-go-vue/frontend/src/identity/i18n.ts +14 -0
- package/dist/templates/native-go-vue/frontend/src/identity/session.test.ts +4 -0
- package/dist/templates/native-go-vue/frontend/src/identity/session.ts +9 -8
- package/dist/templates/native-go-vue/frontend/src/nas/NasPicker.vue +31 -12
- package/dist/templates/native-go-vue/frontend/src/nas/destination.test.ts +48 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/files/de.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/files/en.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/files/es.json +10 -10
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/files/fr.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/files/it.json +12 -12
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/files/ja.json +15 -15
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/files/ko.json +12 -12
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/files/zh-CN.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/files/zh-TW.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/portal/PortalSettings.vue +39 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/fr.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/ja.json +1 -1
- package/dist/templates/native-go-vue/frontend/test/apps.test.ts +14 -0
- package/dist/templates/native-go-vue/frontend/test/portal-settings.test.ts +71 -0
- package/dist/templates/native-go-vue/frontend/test/shell-i18n.test.ts +50 -0
- package/package.json +5 -1
- package/schema/package-metadata.schema.json +101 -0
- package/schema/synology-app.schema.json +112 -0
- package/skills/SKILL.md +106 -4
- package/skills/reference/create.md +101 -2
- package/skills/reference/deploy.md +2 -2
- package/skills/reference/files.md +113 -2
- package/skills/reference/identity.md +70 -1
- package/skills/reference/portal.md +17 -0
- package/skills/reference/ui-vue.md +12 -0
- package/templates/_daemon/go.mod +1 -1
- package/templates/_daemon/main.go +6 -3
- package/templates/_daemon/main_test.go +82 -9
- package/templates/_daemon/testdata/child.go +3 -0
- package/templates/_executor/README.md +130 -16
- package/templates/_executor/anchor.go +156 -0
- package/templates/_executor/anchor_test.go +161 -0
- package/templates/_executor/apppriv_review_test.go +1 -1
- package/templates/_executor/cancel_contract_test.go +236 -0
- package/templates/_executor/copy.go +64 -0
- package/templates/_executor/copy_test.go +88 -0
- package/templates/_executor/digest_review_test.go +2 -2
- package/templates/_executor/dsm.go +63 -13
- package/templates/_executor/dsm_test.go +95 -1
- package/templates/_executor/executor.go +260 -49
- package/templates/_executor/executor_test.go +36 -6
- package/templates/_executor/go.mod +2 -0
- package/templates/_executor/identity.go +27 -1
- package/templates/_executor/identity_kernel_linux_test.go +60 -0
- package/templates/_executor/identity_linux.go +82 -0
- package/templates/_executor/identity_security_test.go +43 -0
- package/templates/_executor/internal/lifecycle/lifecycle.go +5 -0
- package/templates/_executor/internal/lifecycle/lifecycle_test.go +61 -3
- package/templates/_executor/internal/taskscript/boot.sh +9 -9
- package/templates/_executor/internal/taskscript/cmd/main.go +2 -2
- package/templates/_executor/internal/taskscript/control.sh +15 -10
- package/templates/_executor/internal/taskscript/tasks.go +5 -3
- package/templates/_executor/lifecycle_test.go +11 -0
- package/templates/_executor/link_linux.go +28 -0
- package/templates/_executor/long_running_test.go +530 -0
- package/templates/_executor/main.go +83 -25
- package/templates/_executor/managed.go +3 -3
- package/templates/_executor/managed_test.go +3 -3
- package/templates/_executor/move_linux.go +490 -0
- package/templates/_executor/move_linux_test.go +460 -0
- package/templates/_executor/move_validation.go +46 -0
- package/templates/_executor/move_validation_test.go +187 -0
- package/templates/_executor/operations.go +926 -0
- package/templates/_executor/path_test.go +18 -0
- package/templates/_executor/pid.go +37 -0
- package/templates/_executor/pid_test.go +113 -0
- package/templates/_executor/platform_linux.go +24 -173
- package/templates/_executor/platform_linux_test.go +9 -65
- package/templates/_executor/platform_other.go +38 -4
- package/templates/_executor/process.go +3 -0
- package/templates/_executor/purge_log.go +18 -0
- package/templates/_executor/records.go +242 -0
- package/templates/_executor/scope_cancel_contract_test.go +91 -0
- package/templates/_executor/scope_client.go +37 -0
- package/templates/_executor/scope_contract.go +12 -0
- package/templates/_executor/selected_scope.go +146 -0
- package/templates/_executor/selected_scope_test.go +186 -0
- package/templates/_executor/status_disabled_test.go +33 -0
- package/templates/_executor/store.go +4 -3
- package/templates/_executor/supervise.go +109 -0
- package/templates/_executor/supervise_test.go +130 -0
- package/templates/_executor/task_race_review_test.go +1 -1
- package/templates/_executor/tasks.go +52 -15
- package/templates/_executor/tasks_dsm71_test.go +114 -0
- package/templates/_executor/tasks_review_test.go +1 -1
- package/templates/_executor/tasks_test.go +62 -5
- package/templates/_executor/upgrade_watch_test.go +13 -5
- package/templates/_executor/watch.go +8 -0
- package/templates/_executor/watch_test.go +23 -2
- package/templates/_executor/write_review_linux_test.go +4 -12
- package/templates/_gateway/go.mod +2 -0
- package/templates/_shared/AGENTS.md +129 -0
- package/templates/binary/dsm-package.yaml +24 -0
- package/templates/binary/i18n/messages/de.json +4 -0
- package/templates/binary/i18n/messages/en.json +4 -0
- package/templates/binary/i18n/messages/es.json +4 -0
- package/templates/binary/i18n/messages/fr.json +4 -0
- package/templates/binary/i18n/messages/it.json +4 -0
- package/templates/binary/i18n/messages/ja.json +4 -0
- package/templates/binary/i18n/messages/ko.json +4 -0
- package/templates/binary/i18n/messages/zh-CN.json +4 -0
- package/templates/binary/i18n/messages/zh-TW.json +4 -0
- package/templates/binary/ui/app.js +19 -4
- package/templates/native-authorization/AuthorizationGate.vue +5 -3
- package/templates/native-authorization/i18n/de.json +1 -0
- package/templates/native-authorization/i18n/en.json +1 -0
- package/templates/native-authorization/i18n/es.json +2 -1
- package/templates/native-authorization/i18n/fr.json +1 -0
- package/templates/native-authorization/i18n/it.json +11 -10
- package/templates/native-authorization/i18n/ja.json +1 -0
- package/templates/native-authorization/i18n/ko.json +10 -9
- package/templates/native-authorization/i18n/zh-CN.json +6 -5
- package/templates/native-authorization/i18n/zh-TW.json +6 -5
- package/templates/native-go/README.md +43 -10
- package/templates/native-go/backend/cmd/app/main.go +27 -7
- package/templates/native-go/backend/go.mod +1 -1
- package/templates/native-go/backend/internal/api/entry_test.go +47 -0
- package/templates/native-go/backend/internal/api/permissions_test.go +3 -3
- package/templates/native-go/backend/internal/api/registry.go +11 -0
- package/templates/native-go/backend/internal/api/sdk-permissions.json +14 -1
- package/templates/native-go/backend/internal/api/server.go +18 -5
- package/templates/native-go/backend/internal/app/delegate_config.go +57 -0
- package/templates/native-go/backend/internal/app/delegate_config_test.go +28 -0
- package/templates/native-go/backend/internal/app/portal.go +30 -0
- package/templates/native-go/backend/internal/app/portal_test.go +55 -0
- package/templates/native-go/backend/internal/app/routes.go +8 -2
- package/templates/native-go/backend/internal/background/runner.go +1 -1
- package/templates/native-go/backend/internal/background/store.go +16 -14
- package/templates/native-go/backend/internal/dsm/admin.go +8 -2
- package/templates/native-go/backend/internal/dsm/admin_linux.go +43 -13
- package/templates/native-go/backend/internal/dsm/admin_linux_test.go +56 -0
- package/templates/native-go/backend/internal/dsm/admin_other.go +4 -1
- package/templates/native-go/backend/internal/dsm/apppriv.go +30 -0
- package/templates/native-go/backend/internal/dsm/bridge_file.go +75 -0
- package/templates/native-go/backend/internal/dsm/bridge_file_test.go +57 -0
- package/templates/native-go/backend/internal/dsm/entry.go +177 -0
- package/templates/native-go/backend/internal/dsm/entry_test.go +315 -0
- package/templates/native-go/backend/internal/dsm/native/admin-armv7.elf +0 -0
- package/templates/native-go/backend/internal/dsm/native/apppriv-aarch64.elf +0 -0
- package/templates/native-go/backend/internal/dsm/native/apppriv-armv7.elf +0 -0
- package/templates/native-go/backend/internal/dsm/native/apppriv-x86_64.elf +0 -0
- package/templates/native-go/backend/internal/dsm/native/apppriv_check.c +33 -0
- package/templates/native-go/backend/internal/dsm/native/build.sh +13 -4
- package/templates/native-go/backend/internal/dsm/native/provenance.json +9 -3
- package/templates/native-go/backend/internal/filestation/check_permission.go +71 -0
- package/templates/native-go/backend/internal/filestation/check_permission_test.go +77 -0
- package/templates/native-go/backend/internal/filestation/client.go +39 -3
- package/templates/native-go/backend/internal/filestation/download_dsm71_test.go +82 -0
- package/templates/native-go/backend/internal/filestation/sdk_policy_test.go +39 -0
- package/templates/native-go/backend/internal/filestation/service.go +1 -1
- package/templates/native-go/backend/internal/identity/README.md +5 -1
- package/templates/native-go/backend/internal/identity/dsm.go +24 -5
- package/templates/native-go/backend/internal/identity/http.go +1 -1
- package/templates/native-go/backend/internal/identity/identity_test.go +48 -1
- package/templates/native-go/backend/internal/identity/service.go +1 -1
- package/templates/native-go/backend/internal/portal/portal.go +138 -0
- package/templates/native-go/backend/internal/portal/portal_test.go +89 -0
- package/templates/native-go/dsm-package.yaml +20 -1
- package/templates/native-go/i18n/glossary.json +2 -1
- package/templates/native-go/i18n/messages/de.json +1 -0
- package/templates/native-go/i18n/messages/en.json +1 -0
- package/templates/native-go/i18n/messages/es.json +1 -0
- package/templates/native-go/i18n/messages/fr.json +1 -0
- package/templates/native-go/i18n/messages/it.json +1 -0
- package/templates/native-go/i18n/messages/ja.json +1 -0
- package/templates/native-go/i18n/messages/ko.json +1 -0
- package/templates/native-go/i18n/messages/zh-CN.json +1 -0
- package/templates/native-go/i18n/messages/zh-TW.json +1 -0
- package/templates/native-go/ui/app.css +10 -0
- package/templates/native-go/ui/app.js +11 -1
- package/templates/native-go-delegate/DELEGATE.md +126 -5
- package/templates/native-go-delegate/backend/cmd/background-worker/main.go +7 -0
- package/templates/native-go-delegate/backend/internal/app/delegate.go +11 -1
- package/templates/native-go-delegate/backend/internal/app/delegate_routes_test.go +14 -0
- package/templates/native-go-delegate/backend/internal/background/delegated_moves.go +270 -0
- package/templates/native-go-delegate/backend/internal/delegate/admission_recovery_test.go +410 -0
- package/templates/native-go-delegate/backend/internal/delegate/cancel_contract_test.go +95 -0
- package/templates/native-go-delegate/backend/internal/delegate/client.go +8 -0
- package/templates/native-go-delegate/backend/internal/delegate/destination.go +110 -0
- package/templates/native-go-delegate/backend/internal/delegate/destination_state.go +117 -0
- package/templates/native-go-delegate/backend/internal/delegate/destination_state_test.go +60 -0
- package/templates/native-go-delegate/backend/internal/delegate/destination_test.go +116 -0
- package/templates/native-go-delegate/backend/internal/delegate/example.go +81 -0
- package/templates/native-go-delegate/backend/internal/delegate/example_test.go +91 -0
- package/templates/native-go-delegate/backend/internal/delegate/executor_contract_test.go +511 -0
- package/templates/native-go-delegate/backend/internal/delegate/files.go +1 -1
- package/templates/native-go-delegate/backend/internal/delegate/long_running_routes.go +92 -0
- package/templates/native-go-delegate/backend/internal/delegate/long_running_routes_test.go +99 -0
- package/templates/native-go-delegate/backend/internal/delegate/move.go +348 -0
- package/templates/native-go-delegate/backend/internal/delegate/move_test.go +351 -0
- package/templates/native-go-delegate/backend/internal/delegate/operations_list.go +65 -0
- package/templates/native-go-delegate/backend/internal/delegate/operations_list_test.go +114 -0
- package/templates/native-go-delegate/backend/internal/delegate/retry_test.go +1 -1
- package/templates/native-go-delegate/backend/internal/delegate/service.go +58 -17
- package/templates/native-go-delegate/backend/internal/delegate/staging.go +121 -0
- package/templates/native-go-delegate/backend/internal/delegate/status_disabled_test.go +51 -0
- package/templates/native-go-delegate/backend/internal/delegate/testdata/executor_contract.txt +112 -0
- package/templates/native-go-delegate/backend/internal/delegate/transient_contract_test.go +137 -0
- package/templates/native-go-delegate/backend/internal/filestation/files.go +1 -31
- package/templates/native-go-delegate/frontend/src/CapabilityPanels.vue +30 -3
- package/templates/native-go-delegate/frontend/src/delegate/BackgroundSavePanel.vue +113 -0
- package/templates/native-go-delegate/frontend/src/delegate/copy.ts +5 -6
- package/templates/native-go-delegate/frontend/test/background-save.test.ts +121 -0
- package/templates/native-go-delegate/frontend/test/delegate.test.ts +15 -0
- package/templates/native-go-delegate/frontend/test/scope-settings.test.ts +49 -0
- package/templates/native-go-delegate/test.sh +1 -0
- package/templates/native-go-jobs/frontend/src/background/i18n/de.json +2 -2
- package/templates/native-go-jobs/frontend/src/background/i18n/en.json +2 -2
- package/templates/native-go-jobs/frontend/src/background/i18n/es.json +12 -12
- package/templates/native-go-jobs/frontend/src/background/i18n/fr.json +4 -4
- package/templates/native-go-jobs/frontend/src/background/i18n/it.json +17 -17
- package/templates/native-go-jobs/frontend/src/background/i18n/ja.json +7 -7
- package/templates/native-go-jobs/frontend/src/background/i18n/ko.json +15 -15
- package/templates/native-go-jobs/frontend/src/background/i18n/zh-CN.json +3 -3
- package/templates/native-go-jobs/frontend/src/background/i18n/zh-TW.json +2 -2
- package/templates/native-go-jobs/frontend/test/background.test.ts +25 -28
- package/templates/native-go-root-ops/backend/internal/app/executor.go +30 -2
- package/templates/native-go-root-ops/backend/internal/app/executor_test.go +64 -0
- package/templates/native-go-vue/README.md +4 -0
- package/templates/native-go-vue/frontend/package-lock.json +4 -4
- package/templates/native-go-vue/frontend/package.json +1 -1
- package/templates/native-go-vue/frontend/src/App.vue +18 -13
- package/templates/native-go-vue/frontend/src/context.ts +31 -0
- package/templates/native-go-vue/frontend/src/delegate/ExecutorSettings.vue +54 -9
- package/templates/native-go-vue/frontend/src/delegate/catalogs.ts +11 -0
- package/templates/native-go-vue/frontend/src/delegate/copy.test.ts +12 -0
- package/templates/native-go-vue/frontend/src/delegate/copy.ts +4 -4
- package/templates/native-go-vue/frontend/src/delegate/executor-settings.test.ts +23 -0
- package/templates/native-go-vue/frontend/src/delegate/executor-setup.ts +8 -2
- package/templates/native-go-vue/frontend/src/delegate/facade.test.ts +100 -0
- package/templates/native-go-vue/frontend/src/delegate/facade.ts +85 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/de.json +47 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/en.json +13 -2
- package/templates/native-go-vue/frontend/src/delegate/i18n/es.json +47 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/fr.json +47 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/it.json +47 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/ja.json +47 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/ko.json +47 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/save/de.json +42 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/save/en.json +42 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/save/es.json +42 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/save/fr.json +42 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/save/it.json +42 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/save/ja.json +42 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/save/ko.json +42 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/save/zh-CN.json +42 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/save/zh-TW.json +42 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/zh-CN.json +47 -0
- package/templates/native-go-vue/frontend/src/delegate/i18n/zh-TW.json +16 -5
- package/templates/native-go-vue/frontend/src/delegate/long-running.ts +57 -0
- package/templates/native-go-vue/frontend/src/delegate/save-copy.test.ts +12 -0
- package/templates/native-go-vue/frontend/src/delegate/save-copy.ts +24 -0
- package/templates/native-go-vue/frontend/src/delegate/scoped-picker.test.ts +12 -0
- package/templates/native-go-vue/frontend/src/delegate/scoped-picker.ts +21 -0
- package/templates/native-go-vue/frontend/src/files/files.test.ts +7 -0
- package/templates/native-go-vue/frontend/src/i18n/de.json +20 -0
- package/templates/native-go-vue/frontend/src/i18n/en.json +20 -0
- package/templates/native-go-vue/frontend/src/i18n/es.json +20 -0
- package/templates/native-go-vue/frontend/src/i18n/fr.json +20 -0
- package/templates/native-go-vue/frontend/src/i18n/it.json +20 -0
- package/templates/native-go-vue/frontend/src/i18n/ja.json +20 -0
- package/templates/native-go-vue/frontend/src/i18n/ko.json +20 -0
- package/templates/native-go-vue/frontend/src/i18n/zh-CN.json +20 -0
- package/templates/native-go-vue/frontend/src/i18n/zh-TW.json +20 -0
- package/templates/native-go-vue/frontend/src/i18n.ts +13 -0
- package/templates/native-go-vue/frontend/src/identity/LoginPage.vue +16 -14
- package/templates/native-go-vue/frontend/src/identity/i18n/de.json +27 -0
- package/templates/native-go-vue/frontend/src/identity/i18n/en.json +27 -0
- package/templates/native-go-vue/frontend/src/identity/i18n/es.json +27 -0
- package/templates/native-go-vue/frontend/src/identity/i18n/fr.json +27 -0
- package/templates/native-go-vue/frontend/src/identity/i18n/it.json +27 -0
- package/templates/native-go-vue/frontend/src/identity/i18n/ja.json +27 -0
- package/templates/native-go-vue/frontend/src/identity/i18n/ko.json +27 -0
- package/templates/native-go-vue/frontend/src/identity/i18n/zh-CN.json +27 -0
- package/templates/native-go-vue/frontend/src/identity/i18n/zh-TW.json +27 -0
- package/templates/native-go-vue/frontend/src/identity/i18n.ts +14 -0
- package/templates/native-go-vue/frontend/src/identity/session.test.ts +4 -0
- package/templates/native-go-vue/frontend/src/identity/session.ts +9 -8
- package/templates/native-go-vue/frontend/src/nas/NasPicker.vue +31 -12
- package/templates/native-go-vue/frontend/src/nas/destination.test.ts +48 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/files/de.json +1 -1
- package/templates/native-go-vue/frontend/src/nas/i18n/files/en.json +1 -1
- package/templates/native-go-vue/frontend/src/nas/i18n/files/es.json +10 -10
- package/templates/native-go-vue/frontend/src/nas/i18n/files/fr.json +1 -1
- package/templates/native-go-vue/frontend/src/nas/i18n/files/it.json +12 -12
- package/templates/native-go-vue/frontend/src/nas/i18n/files/ja.json +15 -15
- package/templates/native-go-vue/frontend/src/nas/i18n/files/ko.json +12 -12
- package/templates/native-go-vue/frontend/src/nas/i18n/files/zh-CN.json +1 -1
- package/templates/native-go-vue/frontend/src/nas/i18n/files/zh-TW.json +1 -1
- package/templates/native-go-vue/frontend/src/portal/PortalSettings.vue +39 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/fr.json +1 -1
- package/templates/native-go-vue/frontend/src/shell/i18n/ja.json +1 -1
- package/templates/native-go-vue/frontend/test/apps.test.ts +14 -0
- package/templates/native-go-vue/frontend/test/portal-settings.test.ts +71 -0
- package/templates/native-go-vue/frontend/test/shell-i18n.test.ts +50 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"crypto/sha256"
|
|
5
|
+
"encoding/hex"
|
|
6
|
+
"encoding/json"
|
|
7
|
+
"errors"
|
|
8
|
+
"os"
|
|
9
|
+
"path/filepath"
|
|
10
|
+
"strings"
|
|
11
|
+
"time"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
const maxJournalBytes int64 = 10 << 20
|
|
15
|
+
const maxAuditBytes int64 = 50 << 20
|
|
16
|
+
const maxMoveBytes int64 = 16 << 30
|
|
17
|
+
const maxQueued = 16
|
|
18
|
+
|
|
19
|
+
type directoryIdentity struct {
|
|
20
|
+
Device uint64 `json:"dev"`
|
|
21
|
+
Inode uint64 `json:"ino"`
|
|
22
|
+
}
|
|
23
|
+
type Operation struct {
|
|
24
|
+
Version int `json:"v"`
|
|
25
|
+
Package string `json:"package"`
|
|
26
|
+
ID string `json:"delegation_id"`
|
|
27
|
+
Job string `json:"job_id"`
|
|
28
|
+
Subject Subject `json:"subject"`
|
|
29
|
+
Staging string `json:"staging"`
|
|
30
|
+
Name string `json:"name"`
|
|
31
|
+
Size int64 `json:"size"`
|
|
32
|
+
State string `json:"state"`
|
|
33
|
+
Path string `json:"path,omitempty"`
|
|
34
|
+
Code string `json:"code,omitempty"`
|
|
35
|
+
Reason string `json:"reason,omitempty"`
|
|
36
|
+
Part *partMetadata `json:"part,omitempty"`
|
|
37
|
+
PublishIntent bool `json:"publish_intent,omitempty"`
|
|
38
|
+
// CancelRequested durably keeps an acknowledged cancel of a copy in flight.
|
|
39
|
+
CancelRequested string `json:"cancel_requested,omitempty"`
|
|
40
|
+
Updated time.Time `json:"updated_at"`
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// canceledBeforeAdmission marks the tombstone of a cancel that found no
|
|
44
|
+
// operation; admitted operations always carry their staging name.
|
|
45
|
+
func (op Operation) canceledBeforeAdmission() bool {
|
|
46
|
+
return op.State == "canceled" && op.Staging == ""
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
type MoveReceipt struct {
|
|
50
|
+
Path string `json:"path,omitempty"`
|
|
51
|
+
CleanupPending bool `json:"cleanup_pending,omitempty"`
|
|
52
|
+
}
|
|
53
|
+
type AuditEvent struct {
|
|
54
|
+
At time.Time `json:"at"`
|
|
55
|
+
Package string `json:"package"`
|
|
56
|
+
Username string `json:"username"`
|
|
57
|
+
UID int `json:"uid"`
|
|
58
|
+
Operation string `json:"operation"`
|
|
59
|
+
Job string `json:"job_id,omitempty"`
|
|
60
|
+
Path string `json:"path,omitempty"`
|
|
61
|
+
Result string `json:"result"`
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
func recordKey(job string) string { h := sha256.Sum256([]byte(job)); return hex.EncodeToString(h[:]) }
|
|
65
|
+
func (s *Store) atomic(name string, b []byte) error {
|
|
66
|
+
f, err := os.CreateTemp(s.Dir, ".record-")
|
|
67
|
+
if err != nil {
|
|
68
|
+
return err
|
|
69
|
+
}
|
|
70
|
+
defer os.Remove(f.Name())
|
|
71
|
+
defer f.Close()
|
|
72
|
+
if err = f.Chmod(0600); err != nil {
|
|
73
|
+
return err
|
|
74
|
+
}
|
|
75
|
+
if _, err = f.Write(b); err != nil {
|
|
76
|
+
return err
|
|
77
|
+
}
|
|
78
|
+
if err = f.Sync(); err != nil {
|
|
79
|
+
return err
|
|
80
|
+
}
|
|
81
|
+
if err = f.Close(); err != nil {
|
|
82
|
+
return err
|
|
83
|
+
}
|
|
84
|
+
if err = os.Rename(f.Name(), filepath.Join(s.Dir, name)); err != nil {
|
|
85
|
+
return err
|
|
86
|
+
}
|
|
87
|
+
dir, err := os.Open(s.Dir)
|
|
88
|
+
if err != nil {
|
|
89
|
+
return err
|
|
90
|
+
}
|
|
91
|
+
defer dir.Close()
|
|
92
|
+
return dir.Sync()
|
|
93
|
+
}
|
|
94
|
+
func (s *Store) record(name string, v any) error {
|
|
95
|
+
info, err := os.Lstat(filepath.Join(s.Dir, name))
|
|
96
|
+
if err != nil {
|
|
97
|
+
return err
|
|
98
|
+
}
|
|
99
|
+
if !info.Mode().IsRegular() || info.Mode().Perm() != 0600 || info.Size() > maxRequest {
|
|
100
|
+
return errors.New("record mode")
|
|
101
|
+
}
|
|
102
|
+
b, err := os.ReadFile(filepath.Join(s.Dir, name))
|
|
103
|
+
if err != nil {
|
|
104
|
+
return err
|
|
105
|
+
}
|
|
106
|
+
return strictJSON(b, v)
|
|
107
|
+
}
|
|
108
|
+
func (s *Store) Disabled() (bool, error) {
|
|
109
|
+
var b struct {
|
|
110
|
+
Disabled bool `json:"disabled"`
|
|
111
|
+
}
|
|
112
|
+
err := s.record("disabled.record", &b)
|
|
113
|
+
if os.IsNotExist(err) {
|
|
114
|
+
return false, nil
|
|
115
|
+
}
|
|
116
|
+
return b.Disabled, err
|
|
117
|
+
}
|
|
118
|
+
func (s *Store) SetDisabled(disabled bool) error {
|
|
119
|
+
b, _ := json.Marshal(map[string]bool{"disabled": disabled})
|
|
120
|
+
return s.atomic("disabled.record", b)
|
|
121
|
+
}
|
|
122
|
+
func (s *Store) PutOperation(op Operation) error {
|
|
123
|
+
if op.Version != 1 || !tokenRE.MatchString(op.Job) || !idRE.MatchString(op.ID) || !validState(op.State) {
|
|
124
|
+
return errors.New("operation")
|
|
125
|
+
}
|
|
126
|
+
b, err := json.Marshal(op)
|
|
127
|
+
if err != nil || len(b) > maxRequest {
|
|
128
|
+
return errors.New("operation size")
|
|
129
|
+
}
|
|
130
|
+
entries, err := os.ReadDir(s.Dir)
|
|
131
|
+
if err != nil {
|
|
132
|
+
return err
|
|
133
|
+
}
|
|
134
|
+
var total int64
|
|
135
|
+
name := "operation-" + recordKey(op.Job) + ".record"
|
|
136
|
+
for _, ent := range entries {
|
|
137
|
+
if strings.HasPrefix(ent.Name(), "operation-") && ent.Name() != name {
|
|
138
|
+
info, err := ent.Info()
|
|
139
|
+
if err != nil {
|
|
140
|
+
return err
|
|
141
|
+
}
|
|
142
|
+
total += info.Size()
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if total+int64(len(b)) > maxJournalBytes {
|
|
146
|
+
return errors.New("journal full")
|
|
147
|
+
}
|
|
148
|
+
return s.atomic(name, b)
|
|
149
|
+
}
|
|
150
|
+
func validState(state string) bool {
|
|
151
|
+
return contains([]string{"queued", "copying", "committed", "canceled", "interrupted", "uncertain"}, state)
|
|
152
|
+
}
|
|
153
|
+
func (s *Store) GetOperation(job string) (Operation, error) {
|
|
154
|
+
var op Operation
|
|
155
|
+
if !tokenRE.MatchString(job) {
|
|
156
|
+
return op, errors.New("job")
|
|
157
|
+
}
|
|
158
|
+
err := s.record("operation-"+recordKey(job)+".record", &op)
|
|
159
|
+
if err != nil {
|
|
160
|
+
return op, err
|
|
161
|
+
}
|
|
162
|
+
if op.Version != 1 || op.Job != job || !idRE.MatchString(op.ID) || !validState(op.State) {
|
|
163
|
+
return op, errors.New("operation schema")
|
|
164
|
+
}
|
|
165
|
+
return op, nil
|
|
166
|
+
}
|
|
167
|
+
func (s *Store) Operations() ([]Operation, error) {
|
|
168
|
+
entries, err := os.ReadDir(s.Dir)
|
|
169
|
+
if err != nil {
|
|
170
|
+
return nil, err
|
|
171
|
+
}
|
|
172
|
+
out := []Operation{}
|
|
173
|
+
for _, ent := range entries {
|
|
174
|
+
if !strings.HasPrefix(ent.Name(), "operation-") || !strings.HasSuffix(ent.Name(), ".record") {
|
|
175
|
+
continue
|
|
176
|
+
}
|
|
177
|
+
var op Operation
|
|
178
|
+
if err = s.record(ent.Name(), &op); err != nil {
|
|
179
|
+
return nil, err
|
|
180
|
+
}
|
|
181
|
+
if ent.Name() != "operation-"+recordKey(op.Job)+".record" || op.Version != 1 || !validState(op.State) || !idRE.MatchString(op.ID) {
|
|
182
|
+
return nil, errors.New("operation schema")
|
|
183
|
+
}
|
|
184
|
+
out = append(out, op)
|
|
185
|
+
}
|
|
186
|
+
return out, nil
|
|
187
|
+
}
|
|
188
|
+
func (s *Store) Audit(event AuditEvent) error {
|
|
189
|
+
path := filepath.Join(s.Dir, "audit.jsonl")
|
|
190
|
+
b, err := json.Marshal(event)
|
|
191
|
+
if err != nil {
|
|
192
|
+
return err
|
|
193
|
+
}
|
|
194
|
+
b = append(b, '\n')
|
|
195
|
+
info, err := os.Lstat(path)
|
|
196
|
+
if err != nil && !os.IsNotExist(err) {
|
|
197
|
+
return err
|
|
198
|
+
}
|
|
199
|
+
if err == nil {
|
|
200
|
+
if !info.Mode().IsRegular() || info.Mode().Perm() != 0600 {
|
|
201
|
+
return errors.New("audit mode")
|
|
202
|
+
}
|
|
203
|
+
if info.Size()+int64(len(b)) > maxAuditBytes/2 {
|
|
204
|
+
if err = os.Rename(path, filepath.Join(s.Dir, "audit.previous")); err != nil {
|
|
205
|
+
return err
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600)
|
|
210
|
+
if err != nil {
|
|
211
|
+
return err
|
|
212
|
+
}
|
|
213
|
+
defer f.Close()
|
|
214
|
+
if _, err = f.Write(b); err != nil {
|
|
215
|
+
return err
|
|
216
|
+
}
|
|
217
|
+
if err = f.Sync(); err != nil {
|
|
218
|
+
return err
|
|
219
|
+
}
|
|
220
|
+
dir, err := os.Open(s.Dir)
|
|
221
|
+
if err != nil {
|
|
222
|
+
return err
|
|
223
|
+
}
|
|
224
|
+
defer dir.Close()
|
|
225
|
+
return dir.Sync()
|
|
226
|
+
}
|
|
227
|
+
func (e *Executor) auditLocked(s Subject, operation, job, path, result string) error {
|
|
228
|
+
return e.Store.Audit(AuditEvent{At: e.Now().UTC(), Package: e.Policy.Package, Username: s.Username, UID: s.UID, Operation: operation, Job: job, Path: path, Result: result})
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
type partMetadata struct {
|
|
232
|
+
Temporary string `json:"temporary"`
|
|
233
|
+
Directory directoryIdentity `json:"directory"`
|
|
234
|
+
Part directoryIdentity `json:"part"`
|
|
235
|
+
Destination string `json:"destination"`
|
|
236
|
+
}
|
|
237
|
+
type partRecordKey struct{}
|
|
238
|
+
type legacyPublishKey struct{}
|
|
239
|
+
|
|
240
|
+
type publishRejectedError struct{ Code string }
|
|
241
|
+
|
|
242
|
+
func (e publishRejectedError) Error() string { return e.Code }
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"errors"
|
|
6
|
+
"testing"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
// killedChildWriter models the subprocess writer: its child dies with the
|
|
10
|
+
// context and the copy ends with a transport error, before any publish guard.
|
|
11
|
+
type killedChildWriter struct{ copying chan struct{} }
|
|
12
|
+
|
|
13
|
+
func (w killedChildWriter) Write(context.Context, Subject, string, string, string, string) error {
|
|
14
|
+
return nil
|
|
15
|
+
}
|
|
16
|
+
func (w killedChildWriter) Move(ctx context.Context, _ Subject, _ Operation, _ Delegation, _ func(func() (MoveReceipt, error)) (MoveReceipt, error)) (MoveReceipt, error) {
|
|
17
|
+
close(w.copying)
|
|
18
|
+
<-ctx.Done()
|
|
19
|
+
return MoveReceipt{}, errors.New("child copy")
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
func TestStopDuringCopySettlesExecutorPausedNotWriteFailed(t *testing.T) {
|
|
23
|
+
e, _, _ := setup(t)
|
|
24
|
+
id := longGrant(t, e)
|
|
25
|
+
w := killedChildWriter{copying: make(chan struct{})}
|
|
26
|
+
e.Writer = w
|
|
27
|
+
if err := e.startOperations(context.Background()); err != nil {
|
|
28
|
+
t.Fatal(err)
|
|
29
|
+
}
|
|
30
|
+
if r := offline(e, "files.moveFromStaging", moveParams(id, "job")); !r.OK {
|
|
31
|
+
t.Fatal(r)
|
|
32
|
+
}
|
|
33
|
+
<-w.copying
|
|
34
|
+
e.stopOperations()
|
|
35
|
+
if err := e.startOperations(context.Background()); err != nil {
|
|
36
|
+
t.Fatal(err)
|
|
37
|
+
}
|
|
38
|
+
defer e.stopOperations()
|
|
39
|
+
// An executor stop is not an I/O failure of the destination.
|
|
40
|
+
wantOperation(t, offline(e, "files.operationStatus", map[string]any{"delegation_id": id, "job_id": "job"}), "interrupted", "EXECUTOR_PAUSED", "")
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
func TestScopeChangeCancelsCopyDurablyAcrossStop(t *testing.T) {
|
|
44
|
+
e, _ := selectedExecutor(t)
|
|
45
|
+
if r := selectScope(e, "home", 0); !r.OK {
|
|
46
|
+
t.Fatal(r)
|
|
47
|
+
}
|
|
48
|
+
d := selectedGrant(t, e, "/home")
|
|
49
|
+
w := newStubbornWriter()
|
|
50
|
+
e.Writer = w
|
|
51
|
+
startedCopy(t, e, w, d.ID, "job")
|
|
52
|
+
if r := selectScope(e, "shared:reports", 0); !r.OK {
|
|
53
|
+
t.Fatal(r)
|
|
54
|
+
}
|
|
55
|
+
ref := map[string]any{"delegation_id": d.ID, "job_id": "job"}
|
|
56
|
+
wantOperation(t, offline(e, "files.operationStatus", ref), "copying", "CANCEL_REQUESTED", "scope-changed")
|
|
57
|
+
stopped := make(chan struct{})
|
|
58
|
+
go func() { e.stopOperations(); close(stopped) }()
|
|
59
|
+
w.let()
|
|
60
|
+
<-stopped
|
|
61
|
+
if err := e.startOperations(context.Background()); err != nil {
|
|
62
|
+
t.Fatal(err)
|
|
63
|
+
}
|
|
64
|
+
defer e.stopOperations()
|
|
65
|
+
wantOperation(t, offline(e, "files.operationStatus", ref), "canceled", "OPERATION_CANCELED", "scope-changed")
|
|
66
|
+
select {
|
|
67
|
+
case <-w.published:
|
|
68
|
+
t.Fatal("published to a revoked destination")
|
|
69
|
+
default:
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
func TestScopeChangeCancelRecordedBeforeCrashSettlesCanceled(t *testing.T) {
|
|
74
|
+
e, _ := selectedExecutor(t)
|
|
75
|
+
if r := selectScope(e, "home", 0); !r.OK {
|
|
76
|
+
t.Fatal(r)
|
|
77
|
+
}
|
|
78
|
+
d := selectedGrant(t, e, "/home")
|
|
79
|
+
w := newStubbornWriter()
|
|
80
|
+
e.Writer = w
|
|
81
|
+
startedCopy(t, e, w, d.ID, "job")
|
|
82
|
+
if r := selectScope(e, "shared:reports", 0); !r.OK {
|
|
83
|
+
t.Fatal(r)
|
|
84
|
+
}
|
|
85
|
+
e.commitMu.Lock()
|
|
86
|
+
op, err := e.Store.GetOperation("job")
|
|
87
|
+
e.commitMu.Unlock()
|
|
88
|
+
if err != nil || op.CancelRequested != "scope-changed" {
|
|
89
|
+
t.Fatal("scope cancellation not durable before the writer stops", op, err)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bufio"
|
|
5
|
+
"encoding/json"
|
|
6
|
+
"errors"
|
|
7
|
+
"net"
|
|
8
|
+
"path/filepath"
|
|
9
|
+
"time"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
// This command runs from the protected, pinned binary via the DSM root task.
|
|
13
|
+
// It asks the live executor to serialize selection with admission and publish;
|
|
14
|
+
// a second process must never write the authority file around that fence.
|
|
15
|
+
func rootSelectScope(pkg, scope, actor string, expectedGeneration uint64) error {
|
|
16
|
+
c, err := net.DialTimeout("unix", filepath.Join(socketBase, pkg, "executor.sock"), 5*time.Second)
|
|
17
|
+
if err != nil {
|
|
18
|
+
return errors.New("scope executor unavailable")
|
|
19
|
+
}
|
|
20
|
+
defer c.Close()
|
|
21
|
+
if err = c.SetDeadline(time.Now().Add(30 * time.Second)); err != nil {
|
|
22
|
+
return err
|
|
23
|
+
}
|
|
24
|
+
if err = json.NewEncoder(c).Encode(map[string]any{"v": 1, "op": "delegate.setScope", "auth": map[string]string{}, "params": map[string]any{"scope": scope, "actor": actor, "expected_generation": expectedGeneration}}); err != nil {
|
|
25
|
+
return err
|
|
26
|
+
}
|
|
27
|
+
scan := bufio.NewScanner(c)
|
|
28
|
+
scan.Buffer(make([]byte, 4096), maxRequest)
|
|
29
|
+
if !scan.Scan() {
|
|
30
|
+
return errors.New("scope response unavailable")
|
|
31
|
+
}
|
|
32
|
+
var out Response
|
|
33
|
+
if strictJSON(scan.Bytes(), &out) != nil || !out.OK {
|
|
34
|
+
return errors.New("scope selection refused")
|
|
35
|
+
}
|
|
36
|
+
return nil
|
|
37
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
// The immutable policy opts into administrator-selected scope. Only the
|
|
4
|
+
// password-confirmed root task may populate the protected runtime selection.
|
|
5
|
+
const installSelectedScope = "install-selected"
|
|
6
|
+
const maxScopeGeneration = uint64(1<<53 - 1)
|
|
7
|
+
|
|
8
|
+
type SelectedScope struct {
|
|
9
|
+
Schema int `json:"schema"`
|
|
10
|
+
Scope string `json:"scope"`
|
|
11
|
+
Generation uint64 `json:"generation"`
|
|
12
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"encoding/json"
|
|
6
|
+
"errors"
|
|
7
|
+
"os"
|
|
8
|
+
"strings"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
func validSelectedScope(scope string) bool {
|
|
12
|
+
if scope == "home" {
|
|
13
|
+
return true
|
|
14
|
+
}
|
|
15
|
+
if !strings.HasPrefix(scope, "shared:") {
|
|
16
|
+
return false
|
|
17
|
+
}
|
|
18
|
+
name := strings.TrimPrefix(scope, "shared:")
|
|
19
|
+
return validName(name) && name != "." && strings.TrimSpace(name) == name && !strings.ContainsAny(name, "\\:%") && !strings.EqualFold(name, "home") && !strings.EqualFold(name, "homes")
|
|
20
|
+
}
|
|
21
|
+
func (s *Store) SelectedScope() (SelectedScope, error) {
|
|
22
|
+
var out SelectedScope
|
|
23
|
+
if err := s.record("selected-scope.record", &out); err != nil {
|
|
24
|
+
return out, err
|
|
25
|
+
}
|
|
26
|
+
if out.Schema != 1 || !validSelectedScope(out.Scope) || out.Generation == 0 || out.Generation > maxScopeGeneration {
|
|
27
|
+
return SelectedScope{}, errors.New("selected scope state")
|
|
28
|
+
}
|
|
29
|
+
return out, nil
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Caller holds commitMu; root selection and publish share the same fence.
|
|
33
|
+
func (e *Executor) selectionLocked() (SelectedScope, string) {
|
|
34
|
+
if e.Policy.Scope != installSelectedScope {
|
|
35
|
+
return SelectedScope{Schema: 1, Scope: e.Policy.Scope}, ""
|
|
36
|
+
}
|
|
37
|
+
state, err := e.Store.SelectedScope()
|
|
38
|
+
if os.IsNotExist(err) {
|
|
39
|
+
return SelectedScope{}, "needs-scope-confirmation"
|
|
40
|
+
}
|
|
41
|
+
if err != nil {
|
|
42
|
+
return SelectedScope{}, "STORAGE_ERROR"
|
|
43
|
+
}
|
|
44
|
+
return state, ""
|
|
45
|
+
}
|
|
46
|
+
func (e *Executor) selection() (SelectedScope, string) {
|
|
47
|
+
e.commitMu.Lock()
|
|
48
|
+
defer e.commitMu.Unlock()
|
|
49
|
+
return e.selectionLocked()
|
|
50
|
+
}
|
|
51
|
+
func (e *Executor) scopeMatchesLocked(d Delegation) bool {
|
|
52
|
+
state, code := e.selectionLocked()
|
|
53
|
+
return code == "" && state.Scope == d.Scope && state.Generation == d.ScopeGeneration
|
|
54
|
+
}
|
|
55
|
+
func (e *Executor) scopeMatches(d Delegation) bool {
|
|
56
|
+
e.commitMu.Lock()
|
|
57
|
+
defer e.commitMu.Unlock()
|
|
58
|
+
return e.scopeMatchesLocked(d)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Only a kernel-verified root peer can reach this operation. It is absent from
|
|
62
|
+
// the public wire allowlist, even when a package supplies an administrator SID.
|
|
63
|
+
func (e *Executor) handlePeer(ctx context.Context, r Request, peerUID, packageUID int) Response {
|
|
64
|
+
if peerUID == 0 && r.Op == "delegate.setScope" {
|
|
65
|
+
if r.Version != 1 || r.Auth.hasKeys || r.Auth.Cookie != "" || r.Auth.SynoToken != "" {
|
|
66
|
+
return deny("INVALID_REQUEST")
|
|
67
|
+
}
|
|
68
|
+
return e.setSelectedScope(ctx, r.Params)
|
|
69
|
+
}
|
|
70
|
+
if peerUID != packageUID {
|
|
71
|
+
return deny("PEER_DENIED")
|
|
72
|
+
}
|
|
73
|
+
return e.Handle(ctx, r)
|
|
74
|
+
}
|
|
75
|
+
func (e *Executor) setSelectedScope(ctx context.Context, raw json.RawMessage) Response {
|
|
76
|
+
if ctx.Err() != nil {
|
|
77
|
+
return deny("EXECUTOR_PAUSED")
|
|
78
|
+
}
|
|
79
|
+
if e.Policy.Scope != installSelectedScope || e.Policy.Lifetime != "until-revoked" {
|
|
80
|
+
return deny("POLICY_DENIED")
|
|
81
|
+
}
|
|
82
|
+
var in struct {
|
|
83
|
+
Scope string `json:"scope"`
|
|
84
|
+
Actor string `json:"actor"`
|
|
85
|
+
ExpectedGeneration *uint64 `json:"expected_generation"`
|
|
86
|
+
}
|
|
87
|
+
if strictJSON(raw, &in) != nil || !validSelectedScope(in.Scope) || in.Actor == "" || in.ExpectedGeneration == nil || *in.ExpectedGeneration > maxScopeGeneration {
|
|
88
|
+
return deny("INVALID_REQUEST")
|
|
89
|
+
}
|
|
90
|
+
actor, err := e.DSM.Account(ctx, in.Actor)
|
|
91
|
+
if err != nil || actor.Username != in.Actor || !actor.Admin || actor.Expired != "normal" || actor.UID < 1024 {
|
|
92
|
+
return deny("ADMIN_REQUIRED")
|
|
93
|
+
}
|
|
94
|
+
if e.DSM.Allow(ctx, actor, e.Policy.App, e.Policy.Entry) != nil {
|
|
95
|
+
return deny("APP_DENIED")
|
|
96
|
+
}
|
|
97
|
+
// Scope selection grants no data permission. Resolve existence only; each
|
|
98
|
+
// destination and subsequent write still checks its owner's current ACL/UID.
|
|
99
|
+
if in.Scope != "home" {
|
|
100
|
+
if _, err = e.DSM.ScopeRoot(ctx, actor, in.Scope); err != nil {
|
|
101
|
+
return deny("SCOPE_DENIED")
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
e.commitMu.Lock()
|
|
105
|
+
defer e.commitMu.Unlock()
|
|
106
|
+
old, err := e.Store.SelectedScope()
|
|
107
|
+
if err != nil && !os.IsNotExist(err) {
|
|
108
|
+
return deny("STORAGE_ERROR")
|
|
109
|
+
}
|
|
110
|
+
if old.Generation != *in.ExpectedGeneration {
|
|
111
|
+
return deny("SCOPE_APPROVAL_STALE")
|
|
112
|
+
}
|
|
113
|
+
if err == nil && old.Scope == in.Scope {
|
|
114
|
+
return success(old)
|
|
115
|
+
}
|
|
116
|
+
if old.Generation >= maxScopeGeneration {
|
|
117
|
+
return deny("STORAGE_ERROR")
|
|
118
|
+
}
|
|
119
|
+
next := SelectedScope{Schema: 1, Scope: in.Scope, Generation: old.Generation + 1}
|
|
120
|
+
if e.auditLocked(actor, "delegate.scope.confirm", "", scopeVirtual(in.Scope), "admitting") != nil {
|
|
121
|
+
return deny("STORAGE_ERROR")
|
|
122
|
+
}
|
|
123
|
+
b, _ := json.Marshal(next)
|
|
124
|
+
if e.Store.atomic("selected-scope.record", b) != nil {
|
|
125
|
+
return deny("STORAGE_ERROR")
|
|
126
|
+
}
|
|
127
|
+
// New generation is already authoritative if cleanup fails. Old grants fail
|
|
128
|
+
// admission/publish before acknowledgement, and switching back cannot revive them.
|
|
129
|
+
grants, err := e.Store.List()
|
|
130
|
+
if err != nil {
|
|
131
|
+
return deny("STORAGE_ERROR")
|
|
132
|
+
}
|
|
133
|
+
for _, d := range grants {
|
|
134
|
+
if d.Package == e.Policy.Package && !d.Revoked {
|
|
135
|
+
d.Revoked = true
|
|
136
|
+
if e.Store.Put(d) != nil {
|
|
137
|
+
return deny("STORAGE_ERROR")
|
|
138
|
+
}
|
|
139
|
+
e.cancelGrantLocked(d.ID, "scope-changed")
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if e.auditLocked(actor, "delegate.scope.confirm", "", scopeVirtual(in.Scope), "confirmed") != nil {
|
|
143
|
+
return deny("STORAGE_ERROR")
|
|
144
|
+
}
|
|
145
|
+
return success(next)
|
|
146
|
+
}
|