@synopackageland/cli 0.3.10 → 0.4.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/LICENSE +21 -0
- package/README.md +57 -9
- package/dist/bin.js +1 -2
- package/dist/build-spk/generator.d.ts +0 -3
- package/dist/build-spk/generator.js +138 -287
- package/dist/build-spk/native-lifecycle.js +0 -3
- package/dist/build-spk/native-payload.js +0 -1
- package/dist/build-spk/notices.d.ts +5 -0
- package/dist/build-spk/notices.js +60 -0
- package/dist/cli.js +178 -151
- package/dist/compose/analyze.d.ts +1 -2
- package/dist/compose/analyze.js +5 -48
- package/dist/contract/unsupported-types.d.ts +10 -0
- package/dist/contract/unsupported-types.js +49 -0
- package/dist/contract/validate.js +25 -2
- package/dist/contract/web-launch.js +0 -2
- package/dist/deploy/deploy.d.ts +1 -4
- package/dist/deploy/deploy.js +45 -156
- package/dist/deploy/homes-values.js +1 -1
- package/dist/deploy/plan.d.ts +18 -0
- package/dist/deploy/plan.js +54 -0
- package/dist/deploy/spk-version.d.ts +2 -14
- package/dist/deploy/spk-version.js +25 -111
- package/dist/dev.d.ts +1 -3
- package/dist/dev.js +14 -28
- package/dist/error-registry.js +830 -862
- package/dist/host/dsm-client.js +12 -272
- package/dist/host/dsm-port-profile.d.ts +0 -1
- package/dist/host/dsm-port-profile.js +0 -2
- package/dist/host/types.d.ts +1 -83
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -6
- package/dist/info.d.ts +0 -1
- package/dist/info.js +3 -10
- package/dist/init.d.ts +15 -1
- package/dist/init.js +128 -12
- package/dist/log.js +2 -3
- package/dist/native/validate.js +0 -1
- package/dist/standalone/binary.d.ts +9 -0
- package/dist/standalone/binary.js +67 -0
- package/dist/standalone/build.d.ts +25 -0
- package/dist/standalone/build.js +110 -0
- package/dist/standalone/daemon.d.ts +23 -0
- package/dist/standalone/daemon.js +114 -0
- package/dist/standalone/dsm-window.d.ts +26 -0
- package/dist/standalone/dsm-window.js +291 -0
- package/dist/standalone/helper-inventory.d.ts +16 -0
- package/dist/standalone/helper-inventory.js +2 -0
- package/dist/standalone/helper.d.ts +21 -0
- package/dist/standalone/helper.js +105 -0
- package/dist/standalone/host-adapter.d.ts +5 -0
- package/dist/standalone/host-adapter.js +148 -0
- package/dist/standalone/host-platform.d.ts +13 -0
- package/dist/standalone/host-platform.js +42 -0
- package/dist/standalone/host-types.d.ts +49 -0
- package/dist/standalone/host-types.js +1 -0
- package/dist/standalone/i18n.d.ts +28 -0
- package/dist/standalone/i18n.js +161 -0
- package/dist/standalone/inspect-helper.d.ts +6 -0
- package/dist/standalone/inspect-helper.js +88 -0
- package/dist/standalone/inspect-spk.d.ts +23 -0
- package/dist/standalone/inspect-spk.js +209 -0
- package/dist/standalone/lifecycle-helper.d.ts +2 -0
- package/dist/standalone/lifecycle-helper.js +12 -0
- package/dist/standalone/lifecycle.d.ts +3 -0
- package/dist/standalone/lifecycle.js +53 -0
- package/dist/standalone/manifest.d.ts +73 -0
- package/dist/standalone/manifest.js +279 -0
- package/dist/standalone/reopen-events.d.ts +2 -0
- package/dist/standalone/reopen-events.js +28 -0
- package/dist/standalone/root-messages.d.ts +7 -0
- package/dist/standalone/root-messages.js +259 -0
- package/dist/standalone/root-ops.d.ts +42 -0
- package/dist/standalone/root-ops.js +101 -0
- package/dist/standalone/root-window.d.ts +36 -0
- package/dist/standalone/root-window.js +302 -0
- package/dist/standalone/spk.d.ts +23 -0
- package/dist/standalone/spk.js +192 -0
- package/dist/template-paths.d.ts +2 -0
- package/dist/template-paths.js +9 -0
- package/dist/templates/_daemon/fixture_linux_test.go +15 -0
- package/dist/templates/_daemon/fixture_other_test.go +7 -0
- package/dist/templates/_daemon/go.mod +3 -0
- package/dist/templates/_daemon/main.go +608 -0
- package/dist/templates/_daemon/main_test.go +242 -0
- package/dist/templates/_daemon/process_linux.go +55 -0
- package/dist/templates/_daemon/process_linux_test.go +161 -0
- package/dist/templates/_daemon/process_other.go +14 -0
- package/dist/templates/_daemon/testdata/child.go +41 -0
- package/dist/templates/_shared/GO-LICENSE +27 -0
- package/dist/templates/_shared/GO-PATENTS +22 -0
- package/dist/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
- package/dist/templates/_shared/notice-overrides/index.json +14 -0
- package/dist/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
- package/dist/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
- package/dist/templates/_shared/third-party-notices.mjs +51 -0
- package/dist/templates/binary/synology-app.yaml +7 -0
- package/dist/templates/hello-files/compose.yaml +0 -1
- package/dist/templates/hello-web/compose.yaml +13 -10
- package/dist/templates/hello-web/html/app.js +1 -23
- package/dist/templates/hello-web/html/index.html +1 -3
- package/dist/templates/hello-web-page/compose.yaml +13 -10
- package/dist/templates/hello-web-page/html/app.js +1 -23
- package/dist/templates/hello-web-page/html/index.html +1 -3
- package/dist/templates/native-go/README.md +324 -0
- package/dist/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
- package/dist/templates/native-go/backend/cmd/app/main.go +49 -0
- package/dist/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
- package/dist/templates/native-go/backend/cmd/helper/main.go +38 -0
- package/dist/templates/native-go/backend/go.mod +7 -0
- package/dist/templates/native-go/backend/go.sum +4 -0
- package/dist/templates/native-go/backend/internal/api/binary.go +154 -0
- package/dist/templates/native-go/backend/internal/api/binary_test.go +165 -0
- package/dist/templates/native-go/backend/internal/api/errors.go +33 -0
- package/dist/templates/native-go/backend/internal/api/registry.go +104 -0
- package/dist/templates/native-go/backend/internal/api/registry_test.go +329 -0
- package/dist/templates/native-go/backend/internal/api/server.go +159 -0
- package/dist/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
- package/dist/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
- package/dist/templates/native-go/backend/internal/app/root_none.go +9 -0
- package/dist/templates/native-go/backend/internal/app/routes.go +138 -0
- package/dist/templates/native-go/backend/internal/app/routes_test.go +172 -0
- package/dist/templates/native-go/backend/internal/dsm/auth.go +118 -0
- package/dist/templates/native-go/backend/internal/dsm/auth_test.go +139 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
- package/dist/templates/native-go/backend/internal/helper/cohort.go +393 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
- package/dist/templates/native-go/backend/internal/helper/control.go +424 -0
- package/dist/templates/native-go/backend/internal/helper/control_test.go +250 -0
- package/dist/templates/native-go/backend/internal/helper/data_contract.go +242 -0
- package/dist/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
- package/dist/templates/native-go/backend/internal/helper/data_decode.go +184 -0
- package/dist/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
- package/dist/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
- package/dist/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
- package/dist/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
- package/dist/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
- package/dist/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
- package/dist/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
- package/dist/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
- package/dist/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
- package/dist/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
- package/dist/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
- package/dist/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
- package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
- package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
- package/dist/templates/native-go/backend/internal/helper/lease.go +112 -0
- package/dist/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
- package/dist/templates/native-go/backend/internal/helper/lease_other.go +8 -0
- package/dist/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
- package/dist/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
- package/dist/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
- package/dist/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
- package/dist/templates/native-go/backend/internal/helper/native_identity.go +89 -0
- package/dist/templates/native-go/backend/internal/helper/native_provider.go +159 -0
- package/dist/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
- package/dist/templates/native-go/backend/internal/helper/observation.go +204 -0
- package/dist/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
- package/dist/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
- package/dist/templates/native-go/backend/internal/helper/observation_test.go +196 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
- package/dist/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
- package/dist/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
- package/dist/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
- package/dist/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
- package/dist/templates/native-go/backend/internal/helper/peer_linux.go +44 -0
- package/dist/templates/native-go/backend/internal/helper/peer_other.go +7 -0
- package/dist/templates/native-go/backend/internal/helper/process_linux.go +177 -0
- package/dist/templates/native-go/backend/internal/helper/process_other.go +5 -0
- package/dist/templates/native-go/backend/internal/helper/publication_test.go +178 -0
- package/dist/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
- package/dist/templates/native-go/backend/internal/helper/readonly.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
- package/dist/templates/native-go/backend/internal/helper/repair.go +132 -0
- package/dist/templates/native-go/backend/internal/helper/repair_test.go +271 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
- package/dist/templates/native-go/backend/internal/helper/server_linux.go +124 -0
- package/dist/templates/native-go/backend/internal/helper/status.go +334 -0
- package/dist/templates/native-go/backend/internal/helper/status_test.go +288 -0
- package/dist/templates/native-go/backend/internal/helper/supervision.go +107 -0
- package/dist/templates/native-go/backend/internal/helper/supervision_test.go +124 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux.go +363 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux_test.go +913 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
- package/dist/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
- package/dist/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
- package/dist/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
- package/dist/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
- package/dist/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
- package/dist/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
- package/dist/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
- package/dist/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
- package/dist/templates/native-go/backend/internal/helper/write.go +77 -0
- package/dist/templates/native-go/backend/internal/helper/write_admission.go +260 -0
- package/dist/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
- package/dist/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
- package/dist/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
- package/dist/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
- package/dist/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
- package/dist/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
- package/dist/templates/native-go/backend/internal/helper/write_test.go +53 -0
- package/dist/templates/native-go/dsm-package.yaml +58 -0
- package/dist/templates/native-go/gitignore +1 -0
- package/dist/templates/native-go/i18n/glossary.json +662 -0
- package/dist/templates/native-go/i18n/messages/de.json +28 -0
- package/dist/templates/native-go/i18n/messages/en.json +28 -0
- package/dist/templates/native-go/i18n/messages/es.json +28 -0
- package/dist/templates/native-go/i18n/messages/fr.json +28 -0
- package/dist/templates/native-go/i18n/messages/it.json +28 -0
- package/dist/templates/native-go/i18n/messages/ja.json +28 -0
- package/dist/templates/native-go/i18n/messages/ko.json +28 -0
- package/dist/templates/native-go/i18n/messages/zh-CN.json +28 -0
- package/dist/templates/native-go/i18n/messages/zh-TW.json +28 -0
- package/dist/templates/native-go/ui/app.css +35 -0
- package/dist/templates/native-go/ui/app.js +101 -0
- package/dist/templates/native-go-better-auth/backend/internal/app/identity.go +208 -0
- package/dist/templates/native-go-better-auth/backend/internal/app/identity_test.go +113 -0
- package/dist/templates/native-go-better-auth/node/app.mjs +72 -0
- package/dist/templates/native-go-better-auth/node/build.mjs +4 -0
- package/dist/templates/native-go-better-auth/node/package-lock.json +862 -0
- package/dist/templates/native-go-better-auth/node/package.json +1 -0
- package/dist/templates/native-go-better-auth/node/test/auth.test.mjs +31 -0
- package/dist/templates/native-go-integration/backend/internal/app/identity_none.go +6 -0
- package/dist/templates/native-go-integration/backend/internal/app/personal.go +203 -0
- package/dist/templates/native-go-integration/backend/internal/app/personal_test.go +119 -0
- package/dist/templates/native-go-root/backend/internal/app/root.go +107 -0
- package/dist/templates/native-go-root/backend/internal/app/root_test.go +124 -0
- package/dist/templates/native-go-root/root/whoami.sh +6 -0
- package/dist/templates/native-go-vue/README.md +224 -0
- package/dist/templates/native-go-vue/frontend/DESIGN.md +78 -0
- package/dist/templates/native-go-vue/frontend/package-lock.json +2410 -0
- package/dist/templates/native-go-vue/frontend/package.json +6 -0
- package/dist/templates/native-go-vue/frontend/src/App.vue +159 -0
- package/dist/templates/native-go-vue/frontend/src/context.ts +56 -0
- package/dist/templates/native-go-vue/frontend/src/main.ts +29 -0
- package/dist/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
- package/dist/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
- package/dist/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
- package/dist/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
- package/dist/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
- package/dist/templates/native-go-vue/frontend/src/style.css +31 -0
- package/dist/templates/native-go-vue/frontend/test/apps.test.ts +190 -0
- package/dist/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
- package/dist/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
- package/dist/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
- package/dist/templates/native-go-vue/frontend/tsconfig.json +1 -0
- package/dist/templates/native-go-vue/frontend/vite.config.ts +10 -0
- package/dist/templates/native-go-vue/gitignore +2 -0
- package/dist/types.d.ts +1 -1
- package/dist/validate.js +11 -7
- package/package.json +5 -8
- package/schema/synology-app.schema.json +36 -37
- package/skills/SKILL.md +4 -48
- package/skills/reference/create.md +11 -83
- package/skills/reference/deploy.md +7 -78
- package/skills/reference/diagnose.md +4 -101
- package/skills/reference/files.md +5 -41
- package/skills/reference/identity.md +3 -29
- package/skills/reference/wrap.md +0 -2
- package/templates/_daemon/fixture_linux_test.go +15 -0
- package/templates/_daemon/fixture_other_test.go +7 -0
- package/templates/_daemon/go.mod +3 -0
- package/templates/_daemon/main.go +608 -0
- package/templates/_daemon/main_test.go +242 -0
- package/templates/_daemon/process_linux.go +55 -0
- package/templates/_daemon/process_linux_test.go +161 -0
- package/templates/_daemon/process_other.go +14 -0
- package/templates/_daemon/testdata/child.go +41 -0
- package/templates/_shared/GO-LICENSE +27 -0
- package/templates/_shared/GO-PATENTS +22 -0
- package/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
- package/templates/_shared/notice-overrides/index.json +14 -0
- package/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
- package/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
- package/templates/_shared/third-party-notices.mjs +51 -0
- package/templates/binary/synology-app.yaml +7 -0
- package/templates/hello-files/compose.yaml +0 -1
- package/templates/hello-web/compose.yaml +13 -10
- package/templates/hello-web/html/app.js +1 -23
- package/templates/hello-web/html/index.html +1 -3
- package/templates/hello-web-page/compose.yaml +13 -10
- package/templates/hello-web-page/html/app.js +1 -23
- package/templates/hello-web-page/html/index.html +1 -3
- package/templates/native-go/README.md +324 -0
- package/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
- package/templates/native-go/backend/cmd/app/main.go +49 -0
- package/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
- package/templates/native-go/backend/cmd/helper/main.go +38 -0
- package/templates/native-go/backend/go.mod +7 -0
- package/templates/native-go/backend/go.sum +4 -0
- package/templates/native-go/backend/internal/api/binary.go +154 -0
- package/templates/native-go/backend/internal/api/binary_test.go +165 -0
- package/templates/native-go/backend/internal/api/errors.go +33 -0
- package/templates/native-go/backend/internal/api/registry.go +104 -0
- package/templates/native-go/backend/internal/api/registry_test.go +329 -0
- package/templates/native-go/backend/internal/api/server.go +159 -0
- package/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
- package/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
- package/templates/native-go/backend/internal/app/root_none.go +9 -0
- package/templates/native-go/backend/internal/app/routes.go +138 -0
- package/templates/native-go/backend/internal/app/routes_test.go +172 -0
- package/templates/native-go/backend/internal/dsm/auth.go +118 -0
- package/templates/native-go/backend/internal/dsm/auth_test.go +139 -0
- package/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
- package/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
- package/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
- package/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
- package/templates/native-go/backend/internal/helper/cohort.go +393 -0
- package/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
- package/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
- package/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
- package/templates/native-go/backend/internal/helper/control.go +424 -0
- package/templates/native-go/backend/internal/helper/control_test.go +250 -0
- package/templates/native-go/backend/internal/helper/data_contract.go +242 -0
- package/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
- package/templates/native-go/backend/internal/helper/data_decode.go +184 -0
- package/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
- package/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
- package/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
- package/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
- package/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
- package/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
- package/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
- package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
- package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
- package/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
- package/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
- package/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
- package/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
- package/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
- package/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
- package/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
- package/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
- package/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
- package/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
- package/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
- package/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
- package/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
- package/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
- package/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
- package/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
- package/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
- package/templates/native-go/backend/internal/helper/lease.go +112 -0
- package/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
- package/templates/native-go/backend/internal/helper/lease_other.go +8 -0
- package/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
- package/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
- package/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
- package/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
- package/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
- package/templates/native-go/backend/internal/helper/native_identity.go +89 -0
- package/templates/native-go/backend/internal/helper/native_provider.go +159 -0
- package/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
- package/templates/native-go/backend/internal/helper/observation.go +204 -0
- package/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
- package/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
- package/templates/native-go/backend/internal/helper/observation_test.go +196 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
- package/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
- package/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
- package/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
- package/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
- package/templates/native-go/backend/internal/helper/peer_linux.go +44 -0
- package/templates/native-go/backend/internal/helper/peer_other.go +7 -0
- package/templates/native-go/backend/internal/helper/process_linux.go +177 -0
- package/templates/native-go/backend/internal/helper/process_other.go +5 -0
- package/templates/native-go/backend/internal/helper/publication_test.go +178 -0
- package/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
- package/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
- package/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
- package/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
- package/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
- package/templates/native-go/backend/internal/helper/readonly.go +105 -0
- package/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
- package/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
- package/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
- package/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
- package/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
- package/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
- package/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
- package/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
- package/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
- package/templates/native-go/backend/internal/helper/repair.go +132 -0
- package/templates/native-go/backend/internal/helper/repair_test.go +271 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
- package/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
- package/templates/native-go/backend/internal/helper/server_linux.go +124 -0
- package/templates/native-go/backend/internal/helper/status.go +334 -0
- package/templates/native-go/backend/internal/helper/status_test.go +288 -0
- package/templates/native-go/backend/internal/helper/supervision.go +107 -0
- package/templates/native-go/backend/internal/helper/supervision_test.go +124 -0
- package/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
- package/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
- package/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
- package/templates/native-go/backend/internal/helper/supervisor_linux.go +363 -0
- package/templates/native-go/backend/internal/helper/supervisor_linux_test.go +913 -0
- package/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
- package/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
- package/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
- package/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
- package/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
- package/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
- package/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
- package/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
- package/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
- package/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
- package/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
- package/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
- package/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
- package/templates/native-go/backend/internal/helper/write.go +77 -0
- package/templates/native-go/backend/internal/helper/write_admission.go +260 -0
- package/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
- package/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
- package/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
- package/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
- package/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
- package/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
- package/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
- package/templates/native-go/backend/internal/helper/write_test.go +53 -0
- package/templates/native-go/dsm-package.yaml +58 -0
- package/templates/native-go/gitignore +1 -0
- package/templates/native-go/i18n/glossary.json +662 -0
- package/templates/native-go/i18n/messages/de.json +28 -0
- package/templates/native-go/i18n/messages/en.json +28 -0
- package/templates/native-go/i18n/messages/es.json +28 -0
- package/templates/native-go/i18n/messages/fr.json +28 -0
- package/templates/native-go/i18n/messages/it.json +28 -0
- package/templates/native-go/i18n/messages/ja.json +28 -0
- package/templates/native-go/i18n/messages/ko.json +28 -0
- package/templates/native-go/i18n/messages/zh-CN.json +28 -0
- package/templates/native-go/i18n/messages/zh-TW.json +28 -0
- package/templates/native-go/ui/app.css +35 -0
- package/templates/native-go/ui/app.js +101 -0
- package/templates/native-go-better-auth/backend/internal/app/identity.go +208 -0
- package/templates/native-go-better-auth/backend/internal/app/identity_test.go +113 -0
- package/templates/native-go-better-auth/node/app.mjs +72 -0
- package/templates/native-go-better-auth/node/build.mjs +4 -0
- package/templates/native-go-better-auth/node/package-lock.json +862 -0
- package/templates/native-go-better-auth/node/package.json +1 -0
- package/templates/native-go-better-auth/node/test/auth.test.mjs +31 -0
- package/templates/native-go-integration/backend/internal/app/identity_none.go +6 -0
- package/templates/native-go-integration/backend/internal/app/personal.go +203 -0
- package/templates/native-go-integration/backend/internal/app/personal_test.go +119 -0
- package/templates/native-go-root/backend/internal/app/root.go +107 -0
- package/templates/native-go-root/backend/internal/app/root_test.go +124 -0
- package/templates/native-go-root/root/whoami.sh +6 -0
- package/templates/native-go-vue/README.md +224 -0
- package/templates/native-go-vue/frontend/DESIGN.md +78 -0
- package/templates/native-go-vue/frontend/package-lock.json +2410 -0
- package/templates/native-go-vue/frontend/package.json +6 -0
- package/templates/native-go-vue/frontend/src/App.vue +159 -0
- package/templates/native-go-vue/frontend/src/context.ts +56 -0
- package/templates/native-go-vue/frontend/src/main.ts +29 -0
- package/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
- package/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
- package/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
- package/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
- package/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
- package/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
- package/templates/native-go-vue/frontend/src/style.css +31 -0
- package/templates/native-go-vue/frontend/test/apps.test.ts +190 -0
- package/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
- package/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
- package/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
- package/templates/native-go-vue/frontend/tsconfig.json +1 -0
- package/templates/native-go-vue/frontend/vite.config.ts +10 -0
- package/templates/native-go-vue/gitignore +2 -0
- package/dist/attestation/app-package.d.ts +0 -86
- package/dist/attestation/app-package.js +0 -206
- package/dist/attestation/install-on-host.d.ts +0 -14
- package/dist/attestation/install-on-host.js +0 -52
- package/dist/attestation/keyring.d.ts +0 -21
- package/dist/attestation/keyring.js +0 -168
- package/dist/attestation/platform-service.d.ts +0 -70
- package/dist/attestation/platform-service.js +0 -250
- package/dist/build-spk/broker-glue.d.ts +0 -16
- package/dist/build-spk/broker-glue.js +0 -40
- package/dist/deploy/catalog-publish.d.ts +0 -3
- package/dist/deploy/catalog-publish.js +0 -7
- package/dist/doctor.d.ts +0 -22
- package/dist/doctor.js +0 -822
- package/dist/error-collector.d.ts +0 -2
- package/dist/error-collector.js +0 -46
- package/dist/host/broker-paths.d.ts +0 -1
- package/dist/host/broker-paths.js +0 -1
- package/dist/host/broker-upgrade-preflight.d.ts +0 -61
- package/dist/host/broker-upgrade-preflight.js +0 -156
- package/dist/host/digests.d.ts +0 -5
- package/dist/host/digests.js +0 -63
- package/dist/host/fake-nas.d.ts +0 -49
- package/dist/host/fake-nas.js +0 -193
- package/dist/mock-broker/bootstrap.d.ts +0 -2
- package/dist/mock-broker/bootstrap.js +0 -8
- package/dist/mock-broker/files.d.ts +0 -60
- package/dist/mock-broker/files.js +0 -408
- package/dist/mock-broker/oidc.d.ts +0 -31
- package/dist/mock-broker/oidc.js +0 -161
- package/dist/mock-broker/path.d.ts +0 -9
- package/dist/mock-broker/path.js +0 -50
- package/dist/mock-broker/server.d.ts +0 -19
- package/dist/mock-broker/server.js +0 -350
- package/dist/publish/build-ledger.d.ts +0 -22
- package/dist/publish/build-ledger.js +0 -26
- package/dist/publish/community-path.d.ts +0 -6
- package/dist/publish/community-path.js +0 -41
- package/dist/publish/curated-release.d.ts +0 -78
- package/dist/publish/curated-release.js +0 -883
- package/dist/publish/file-build-ledger.d.ts +0 -18
- package/dist/publish/file-build-ledger.js +0 -268
- package/dist/publish/github-pr.d.ts +0 -25
- package/dist/publish/github-pr.js +0 -85
- package/dist/publish/github-repo.d.ts +0 -8
- package/dist/publish/github-repo.js +0 -21
- package/dist/publish/platform-service-release.d.ts +0 -60
- package/dist/publish/platform-service-release.js +0 -333
- package/dist/publish/preflight.d.ts +0 -24
- package/dist/publish/preflight.js +0 -138
- package/dist/publish/publish.d.ts +0 -27
- package/dist/publish/publish.js +0 -136
- package/dist/publish/sync-definition.d.ts +0 -4
- package/dist/publish/sync-definition.js +0 -48
- package/dist/release-bin.d.ts +0 -2
- package/dist/release-bin.js +0 -23
- package/dist/templates/hello-web/html/sdk.js +0 -68
- package/dist/templates/hello-web-page/html/sdk.js +0 -68
- package/dist/templates/native/synology-app.yaml +0 -7
- package/dist/test-host.d.ts +0 -15
- package/dist/test-host.js +0 -37
- package/templates/hello-web/html/sdk.js +0 -68
- package/templates/hello-web-page/html/sdk.js +0 -68
- package/templates/native/synology-app.yaml +0 -7
- /package/dist/templates/{native → binary}/native.yaml +0 -0
- /package/templates/{native → binary}/native.yaml +0 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
// Disposable Linux VM fixtures only. No account lookup or ACL adapter is
|
|
4
|
+
// installed into the shipped helper, and no business FD is opened by the parent.
|
|
5
|
+
import (
|
|
6
|
+
"bytes"
|
|
7
|
+
"context"
|
|
8
|
+
"encoding/json"
|
|
9
|
+
"fmt"
|
|
10
|
+
"os"
|
|
11
|
+
"os/exec"
|
|
12
|
+
"runtime"
|
|
13
|
+
"strings"
|
|
14
|
+
"syscall"
|
|
15
|
+
"testing"
|
|
16
|
+
"time"
|
|
17
|
+
|
|
18
|
+
"golang.org/x/sys/unix"
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
const (
|
|
22
|
+
s1rAlice = 23001
|
|
23
|
+
s1rBob = 23002
|
|
24
|
+
s1rAliceGID = 24001
|
|
25
|
+
s1rBobGID = 24002
|
|
26
|
+
s1rShared = 24003
|
|
27
|
+
s1rExtra = 24004
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
func s1rMust(t *testing.T, err error) {
|
|
31
|
+
t.Helper()
|
|
32
|
+
if err != nil {
|
|
33
|
+
t.Fatal(err)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
func s1rACL(t *testing.T, path, acl string) {
|
|
38
|
+
t.Helper()
|
|
39
|
+
b, err := exec.Command("/usr/bin/setfacl", "-m", acl, path).CombinedOutput()
|
|
40
|
+
if err != nil {
|
|
41
|
+
t.Fatalf("setfacl %s: %v %s", path, err, b)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
func s1rFixture(t *testing.T) string {
|
|
46
|
+
t.Helper()
|
|
47
|
+
root, err := os.MkdirTemp("/tmp", "s1r-vm-")
|
|
48
|
+
s1rMust(t, err)
|
|
49
|
+
t.Cleanup(func() { s1rMust(t, os.RemoveAll(root)) })
|
|
50
|
+
s1rMust(t, os.Chmod(root, 0755))
|
|
51
|
+
for _, name := range []string{"alice", "bob", "supplementary", "acl-allow", "acl-mask", "acl-file-mask", "acl-group", "acl-group-mask", "inherit", "readonly", "race"} {
|
|
52
|
+
dir := root + "/" + name
|
|
53
|
+
s1rMust(t, os.Mkdir(dir, 0700))
|
|
54
|
+
s1rMust(t, os.WriteFile(dir+"/file", []byte("canary:"+name), 0600))
|
|
55
|
+
}
|
|
56
|
+
for _, p := range []struct {
|
|
57
|
+
name string
|
|
58
|
+
uid, gid int
|
|
59
|
+
}{{"alice", s1rAlice, s1rAliceGID}, {"bob", s1rBob, s1rBobGID}, {"race", s1rAlice, s1rAliceGID}} {
|
|
60
|
+
for _, path := range []string{root + "/" + p.name, root + "/" + p.name + "/file"} {
|
|
61
|
+
s1rMust(t, os.Chown(path, p.uid, p.gid))
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
for _, path := range []string{root + "/supplementary", root + "/supplementary/file"} {
|
|
65
|
+
s1rMust(t, os.Chown(path, 0, s1rShared))
|
|
66
|
+
}
|
|
67
|
+
s1rMust(t, unix.Chmod(root+"/supplementary", 02770))
|
|
68
|
+
s1rMust(t, os.Chmod(root+"/supplementary/file", 0660))
|
|
69
|
+
for _, name := range []string{"acl-allow", "acl-file-mask", "inherit"} {
|
|
70
|
+
s1rACL(t, root+"/"+name, fmt.Sprintf("u:%d:rwx,m::rwx", s1rAlice))
|
|
71
|
+
s1rACL(t, root+"/"+name+"/file", fmt.Sprintf("u:%d:rw-,m::rw-", s1rAlice))
|
|
72
|
+
}
|
|
73
|
+
s1rACL(t, root+"/acl-mask", fmt.Sprintf("u:%d:rwx,m::---", s1rAlice))
|
|
74
|
+
s1rACL(t, root+"/acl-mask/file", fmt.Sprintf("u:%d:rw-,m::---", s1rAlice))
|
|
75
|
+
s1rACL(t, root+"/acl-file-mask/file", "m::---")
|
|
76
|
+
for _, name := range []string{"acl-group", "acl-group-mask"} {
|
|
77
|
+
s1rACL(t, root+"/"+name, fmt.Sprintf("g:%d:rwx,m::rwx", s1rShared))
|
|
78
|
+
s1rACL(t, root+"/"+name+"/file", fmt.Sprintf("g:%d:rw-,m::rw-", s1rShared))
|
|
79
|
+
}
|
|
80
|
+
s1rACL(t, root+"/acl-group-mask", "m::r-x")
|
|
81
|
+
s1rACL(t, root+"/acl-group-mask/file", "m::r--")
|
|
82
|
+
s1rACL(t, root+"/inherit", fmt.Sprintf("u:%d:r-x,d:u::rwx,d:u:%d:rwx,d:u:%d:r-x,d:g::---,d:m::rwx,d:o::---", s1rBob, s1rAlice, s1rBob))
|
|
83
|
+
s1rACL(t, root+"/inherit/file", fmt.Sprintf("u:%d:r--,m::rw-", s1rBob))
|
|
84
|
+
s1rMust(t, os.Chmod(root+"/readonly", 0555))
|
|
85
|
+
s1rMust(t, os.Chmod(root+"/readonly/file", 0444))
|
|
86
|
+
return root
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
type s1rActorSpec struct {
|
|
90
|
+
UID, GID uint32
|
|
91
|
+
Groups []uint32
|
|
92
|
+
Root, Scenario string
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Run a fresh test process as root, invoke the REAL permanent drop routine, and
|
|
96
|
+
// proxy ONLY mount metadata using the production packet/FD routines. The parent
|
|
97
|
+
// pins the child's proc directory before permitting its credential transition.
|
|
98
|
+
func s1rRunActor(t *testing.T, spec s1rActorSpec) {
|
|
99
|
+
t.Helper()
|
|
100
|
+
pair, err := syscall.Socketpair(syscall.AF_UNIX, syscall.SOCK_SEQPACKET|syscall.SOCK_CLOEXEC, 0)
|
|
101
|
+
s1rMust(t, err)
|
|
102
|
+
left := os.NewFile(uintptr(pair[0]), "s1r-parent")
|
|
103
|
+
right := os.NewFile(uintptr(pair[1]), "s1r-child")
|
|
104
|
+
defer left.Close()
|
|
105
|
+
defer right.Close()
|
|
106
|
+
control, err := operationSocket(left)
|
|
107
|
+
s1rMust(t, err)
|
|
108
|
+
defer control.Close()
|
|
109
|
+
s1rMust(t, enableCredentials(control))
|
|
110
|
+
exe, err := os.Executable()
|
|
111
|
+
s1rMust(t, err)
|
|
112
|
+
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
113
|
+
defer cancel()
|
|
114
|
+
cmd := exec.CommandContext(ctx, exe, "-test.run=^TestS1RActorProcess$", "-test.v")
|
|
115
|
+
b, err := json.Marshal(spec)
|
|
116
|
+
s1rMust(t, err)
|
|
117
|
+
cmd.Env = append(os.Environ(), "S1R_ACTOR_SPEC="+string(b))
|
|
118
|
+
cmd.ExtraFiles = []*os.File{right}
|
|
119
|
+
// Deliberately inherit unrelated/root/supplementary groups. The production
|
|
120
|
+
// Setgroups call must replace these, including when the requested set is empty.
|
|
121
|
+
cmd.SysProcAttr = &syscall.SysProcAttr{Credential: &syscall.Credential{Uid: 0, Gid: 0, Groups: []uint32{0, s1rShared, 24005}}}
|
|
122
|
+
var out bytes.Buffer
|
|
123
|
+
cmd.Stdout = &out
|
|
124
|
+
cmd.Stderr = &out
|
|
125
|
+
s1rMust(t, cmd.Start())
|
|
126
|
+
defer func() {
|
|
127
|
+
if cmd.ProcessState == nil {
|
|
128
|
+
cmd.Process.Kill()
|
|
129
|
+
cmd.Wait()
|
|
130
|
+
}
|
|
131
|
+
}()
|
|
132
|
+
info, err := openOperationFDInfo(cmd.Process.Pid)
|
|
133
|
+
s1rMust(t, err)
|
|
134
|
+
defer info.Close()
|
|
135
|
+
s1rMust(t, writeOperationPacket(control, true))
|
|
136
|
+
done := make(chan error, 1)
|
|
137
|
+
go func() {
|
|
138
|
+
var sequence uint64
|
|
139
|
+
for {
|
|
140
|
+
var packet readOnlyPacket
|
|
141
|
+
cred, err := readOperationPacketBound(control, &packet, MaxControlBytes, 30*time.Second)
|
|
142
|
+
if err != nil {
|
|
143
|
+
done <- nil
|
|
144
|
+
return
|
|
145
|
+
} // process exit closes the private socket
|
|
146
|
+
if cred == nil || int(cred.Pid) != cmd.Process.Pid || cred.Uid != spec.UID || cred.Gid != spec.GID || packet.Token != strings.Repeat("a", 64) || packet.MountFD == nil || packet.MountSequence != sequence+1 {
|
|
147
|
+
done <- fmt.Errorf("invalid actor mount query")
|
|
148
|
+
return
|
|
149
|
+
}
|
|
150
|
+
sequence++
|
|
151
|
+
id, code := operationFDInfoMount(info, *packet.MountFD)
|
|
152
|
+
if err := writeOperationPacket(control, readOnlyMountReply{Token: packet.Token, Sequence: sequence, Mount: id, Code: code}); err != nil {
|
|
153
|
+
done <- err
|
|
154
|
+
return
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}()
|
|
158
|
+
err = cmd.Wait()
|
|
159
|
+
control.Close()
|
|
160
|
+
proxyErr := <-done
|
|
161
|
+
if err != nil || proxyErr != nil {
|
|
162
|
+
t.Fatalf("actor %s: %v proxy=%v\n%s", spec.Scenario, err, proxyErr, out.String())
|
|
163
|
+
}
|
|
164
|
+
t.Log(out.String())
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
func s1rDropActor(t *testing.T, spec s1rActorSpec) {
|
|
168
|
+
t.Helper()
|
|
169
|
+
runtime.LockOSThread() // like operationChildLinux; subprocess exits when finished
|
|
170
|
+
f := os.NewFile(3, "s1r-control")
|
|
171
|
+
defer f.Close()
|
|
172
|
+
control, err := operationSocket(f)
|
|
173
|
+
s1rMust(t, err)
|
|
174
|
+
t.Cleanup(func() { control.Close() })
|
|
175
|
+
var ready bool
|
|
176
|
+
_, err = readOperationPacketBound(control, &ready, MaxHealthBytes, 5*time.Second)
|
|
177
|
+
s1rMust(t, err)
|
|
178
|
+
if !ready {
|
|
179
|
+
t.Fatal("parent did not pin proc witness")
|
|
180
|
+
}
|
|
181
|
+
boot := operationBootstrap{UID: spec.UID, GID: spec.GID, Groups: spec.Groups, Token: strings.Repeat("a", 64)}
|
|
182
|
+
s1rMust(t, dropOperationCredentials(os.Getppid(), boot))
|
|
183
|
+
operationMountIDFallback = operationMountIDProxy(control, boot)
|
|
184
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"os"
|
|
6
|
+
"strings"
|
|
7
|
+
"testing"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
func s1rActorRaces(t *testing.T, spec s1rActorSpec, kind string) {
|
|
11
|
+
root := spec.Root + "/race"
|
|
12
|
+
pin, code := pinReadOnlyRoot(root)
|
|
13
|
+
if code != "" {
|
|
14
|
+
t.Fatal(code)
|
|
15
|
+
}
|
|
16
|
+
defer pin.Close()
|
|
17
|
+
ctx := context.Background()
|
|
18
|
+
switch kind {
|
|
19
|
+
case "symlink":
|
|
20
|
+
for _, link := range []struct{ name, target string }{{"inside-link", "file"}, {"outside-link", "../bob/file"}, {"dir-link", "../bob"}} {
|
|
21
|
+
s1rMust(t, os.Symlink(link.target, root+"/"+link.name))
|
|
22
|
+
}
|
|
23
|
+
for _, action := range []Action{ActionStat, ActionRead, ActionList, ActionReadStream} {
|
|
24
|
+
segments := []string{"outside-link"}
|
|
25
|
+
if action == ActionList {
|
|
26
|
+
segments = []string{"dir-link"}
|
|
27
|
+
}
|
|
28
|
+
work := readWork(pin, segments...)
|
|
29
|
+
work.Action = action
|
|
30
|
+
if action == ActionList {
|
|
31
|
+
work.MaxBytes = 0
|
|
32
|
+
work.Limit = 20
|
|
33
|
+
}
|
|
34
|
+
if action == ActionStat {
|
|
35
|
+
work.MaxBytes = 0
|
|
36
|
+
}
|
|
37
|
+
if action == ActionReadStream {
|
|
38
|
+
x, r := openActorReadTransfer(ctx, pin, work, fixtureReadOnlyACL{})
|
|
39
|
+
if x != nil {
|
|
40
|
+
x.Close()
|
|
41
|
+
}
|
|
42
|
+
if r.Code != ErrDenied || r.Bytes != 0 {
|
|
43
|
+
t.Fatal("symlink stream", r)
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
r, b := executeReadOnly(ctx, pin, work, fixtureReadOnlyACL{})
|
|
47
|
+
if r.Code != ErrDenied || len(b) > 0 || r.Entry != nil || r.List != nil {
|
|
48
|
+
t.Fatal("symlink metadata/read", action, r)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
r, b := executeReadOnly(ctx, pin, readWork(pin, "inside-link"), fixtureReadOnlyACL{})
|
|
53
|
+
if r.Code != ErrDenied || len(b) > 0 {
|
|
54
|
+
t.Fatal("internal symlink followed", r)
|
|
55
|
+
}
|
|
56
|
+
r, _ = executeReadOnly(ctx, pin, readOnlyWork{RootPath: root, Action: ActionList, Segments: []string{}, Limit: 20}, fixtureReadOnlyACL{})
|
|
57
|
+
if r.Code != "" || r.List == nil || len(r.List.Entries) != 1 || r.List.Entries[0].Name != "file" {
|
|
58
|
+
t.Fatal("symlink names leaked by list", r)
|
|
59
|
+
}
|
|
60
|
+
for _, segments := range [][]string{{"outside-link"}, {"dir-link", "new"}} {
|
|
61
|
+
x, c := openActorWriteTransfer(ctx, pin, writeWork{RootPath: root, Action: ActionCreate, Segments: segments, MaxBytes: 3}, fixtureReadOnlyACL{})
|
|
62
|
+
if x != nil {
|
|
63
|
+
x.Close()
|
|
64
|
+
}
|
|
65
|
+
if c != ErrDenied {
|
|
66
|
+
t.Fatal("symlink create", c)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
t.Log("stat/list/read/stream/create reject symlinks; list filters symlink names")
|
|
70
|
+
case "stat-rename", "list-rename", "read-rename":
|
|
71
|
+
s1rMust(t, os.Mkdir(root+"/sub", 0700))
|
|
72
|
+
s1rMust(t, os.WriteFile(root+"/sub/file", []byte("original"), 0600))
|
|
73
|
+
mutated := false
|
|
74
|
+
acl := fixtureReadOnlyACL{hook: func() {
|
|
75
|
+
if mutated {
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
mutated = true
|
|
79
|
+
s1rMust(t, os.Rename(root+"/sub", root+"/moved"))
|
|
80
|
+
s1rMust(t, os.Mkdir(root+"/sub", 0700))
|
|
81
|
+
s1rMust(t, os.WriteFile(root+"/sub/file", []byte("foreign"), 0600))
|
|
82
|
+
}}
|
|
83
|
+
work := readWork(pin, "sub", "file")
|
|
84
|
+
if kind == "stat-rename" {
|
|
85
|
+
work.Action = ActionStat
|
|
86
|
+
work.MaxBytes = 0
|
|
87
|
+
}
|
|
88
|
+
if kind == "list-rename" {
|
|
89
|
+
work.Action = ActionList
|
|
90
|
+
work.MaxBytes = 0
|
|
91
|
+
work.Segments = []string{"sub"}
|
|
92
|
+
work.Limit = 20
|
|
93
|
+
}
|
|
94
|
+
r, b := executeReadOnly(ctx, pin, work, acl)
|
|
95
|
+
if r.Code != ErrStale || len(b) != 0 || r.Entry != nil || r.List != nil {
|
|
96
|
+
t.Fatal("renamed ancestry released bytes", r, string(b))
|
|
97
|
+
}
|
|
98
|
+
t.Log(kind + ": replacement after resolver open refuses bytes and metadata with stale")
|
|
99
|
+
case "stream-rename":
|
|
100
|
+
work := readWork(pin, "file")
|
|
101
|
+
work.Action = ActionReadStream
|
|
102
|
+
x, r := openActorReadTransfer(ctx, pin, work, fixtureReadOnlyACL{})
|
|
103
|
+
if r.Code != "" {
|
|
104
|
+
t.Fatal(r)
|
|
105
|
+
}
|
|
106
|
+
defer x.Close()
|
|
107
|
+
b, c := x.ReadChunk(ctx, 3)
|
|
108
|
+
if c != "" || string(b) != "can" {
|
|
109
|
+
t.Fatal(c, string(b))
|
|
110
|
+
}
|
|
111
|
+
s1rMust(t, os.Rename(root+"/file", root+"/old"))
|
|
112
|
+
s1rMust(t, os.Symlink("../bob/file", root+"/file"))
|
|
113
|
+
b, c = x.ReadChunk(ctx, 3)
|
|
114
|
+
if c != ErrDenied || len(b) != 0 {
|
|
115
|
+
t.Fatal("stream followed replacement", c, string(b))
|
|
116
|
+
}
|
|
117
|
+
t.Log("first fixed-FD stream chunk succeeds; symlink replacement refuses next chunk")
|
|
118
|
+
case "create-rename", "publish-rename", "publish-symlink":
|
|
119
|
+
s1rMust(t, os.Mkdir(root+"/sub", 0700))
|
|
120
|
+
staged := kind != "create-rename"
|
|
121
|
+
work := writeWork{RootPath: root, Action: ActionCreate, Segments: []string{"sub", "result"}, MaxBytes: 6}
|
|
122
|
+
if staged {
|
|
123
|
+
work.Action = ActionWriteStream
|
|
124
|
+
work.Staged = true
|
|
125
|
+
}
|
|
126
|
+
x, c := openActorWriteTransfer(ctx, pin, work, fixtureReadOnlyACL{})
|
|
127
|
+
if c != "" {
|
|
128
|
+
t.Fatal(c)
|
|
129
|
+
}
|
|
130
|
+
defer x.Close()
|
|
131
|
+
receipt, c := x.WriteChunk(ctx, []byte("abc"))
|
|
132
|
+
if c != "" || receipt.BytesWritten != 3 {
|
|
133
|
+
t.Fatal(receipt, c)
|
|
134
|
+
}
|
|
135
|
+
if kind == "publish-symlink" {
|
|
136
|
+
s1rMust(t, os.Symlink("../file", root+"/sub/result"))
|
|
137
|
+
receipt, c = x.Commit(ctx)
|
|
138
|
+
if c != ErrDenied || receipt.Published || receipt.Committed {
|
|
139
|
+
t.Fatal("publish replaced symlink", receipt, c)
|
|
140
|
+
}
|
|
141
|
+
target, e := os.Readlink(root + "/sub/result")
|
|
142
|
+
s1rMust(t, e)
|
|
143
|
+
if target != "../file" {
|
|
144
|
+
t.Fatal(target)
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
s1rMust(t, os.Rename(root+"/sub", root+"/moved"))
|
|
148
|
+
s1rMust(t, os.Mkdir(root+"/sub", 0700))
|
|
149
|
+
s1rMust(t, os.WriteFile(root+"/sub/result", []byte("foreign"), 0600))
|
|
150
|
+
if staged {
|
|
151
|
+
receipt, c = x.Commit(ctx)
|
|
152
|
+
if c != ErrStale || receipt.Published {
|
|
153
|
+
t.Fatal("publish after rename", receipt, c)
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
receipt, c = x.WriteChunk(ctx, []byte("def"))
|
|
157
|
+
if c != ErrPartial || receipt.BytesWritten != 3 {
|
|
158
|
+
t.Fatal("write after rename", receipt, c)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
b, e := os.ReadFile(root + "/sub/result")
|
|
162
|
+
s1rMust(t, e)
|
|
163
|
+
if string(b) != "foreign" {
|
|
164
|
+
t.Fatal("foreign destination overwritten", string(b))
|
|
165
|
+
}
|
|
166
|
+
if staged {
|
|
167
|
+
if _, e := os.Stat(root + "/moved/result"); !os.IsNotExist(e) {
|
|
168
|
+
t.Fatal("anonymous stage became visible", e)
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
b, e = os.ReadFile(root + "/moved/result")
|
|
172
|
+
s1rMust(t, e)
|
|
173
|
+
if string(b) != "abc" {
|
|
174
|
+
t.Fatal("partial bytes changed", string(b))
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
t.Logf("%s: refusal=%s receipt=%+v; foreign destination preserved", kind, c, receipt)
|
|
179
|
+
case "publish-permission-loss":
|
|
180
|
+
work := writeWork{RootPath: root, Action: ActionWriteStream, Segments: []string{"result"}, MaxBytes: 3, Staged: true}
|
|
181
|
+
x, c := openActorWriteTransfer(ctx, pin, work, fixtureReadOnlyACL{})
|
|
182
|
+
if c != "" {
|
|
183
|
+
t.Fatal(c)
|
|
184
|
+
}
|
|
185
|
+
defer x.Close()
|
|
186
|
+
_, c = x.WriteChunk(ctx, []byte("abc"))
|
|
187
|
+
if c != "" {
|
|
188
|
+
t.Fatal(c)
|
|
189
|
+
}
|
|
190
|
+
s1rMust(t, os.Chmod(root, 0500))
|
|
191
|
+
defer os.Chmod(root, 0700)
|
|
192
|
+
r, c := x.Commit(ctx)
|
|
193
|
+
// Current S7 maps linkat EACCES to unsupported; require the exact behavior,
|
|
194
|
+
// report it, and preserve the fail-closed publish gate.
|
|
195
|
+
if c != ErrUnsupported || r.Published || r.Committed || r.BytesWritten != 3 {
|
|
196
|
+
t.Fatal("publish after parent chmod", r, c)
|
|
197
|
+
}
|
|
198
|
+
if _, e := os.Stat(root + "/result"); !os.IsNotExist(e) {
|
|
199
|
+
t.Fatal("publish wrote forbidden directory", e)
|
|
200
|
+
}
|
|
201
|
+
t.Log("parent write permission removed: kernel denies linkat; receipt retains staged bytes, published=false")
|
|
202
|
+
case "open-fd-write-permission-loss":
|
|
203
|
+
work := writeWork{RootPath: root, Action: ActionCreate, Segments: []string{"result"}, MaxBytes: 6}
|
|
204
|
+
x, c := openActorWriteTransfer(ctx, pin, work, fixtureReadOnlyACL{})
|
|
205
|
+
if c != "" {
|
|
206
|
+
t.Fatal(c)
|
|
207
|
+
}
|
|
208
|
+
defer x.Close()
|
|
209
|
+
r, c := x.WriteChunk(ctx, []byte("abc"))
|
|
210
|
+
if c != "" {
|
|
211
|
+
t.Fatal(c)
|
|
212
|
+
}
|
|
213
|
+
s1rMust(t, x.file.Chmod(0000))
|
|
214
|
+
defer x.file.Chmod(0600)
|
|
215
|
+
r, c = x.WriteChunk(ctx, []byte("def"))
|
|
216
|
+
if c != "" || r.BytesWritten != 6 {
|
|
217
|
+
t.Fatal("Linux open-FD semantics", r, c)
|
|
218
|
+
}
|
|
219
|
+
r, c = x.Commit(ctx)
|
|
220
|
+
if c != "" || !r.Committed {
|
|
221
|
+
t.Fatal(r, c)
|
|
222
|
+
}
|
|
223
|
+
b, e := os.ReadFile(root + "/result")
|
|
224
|
+
if !os.IsPermission(e) || len(b) != 0 {
|
|
225
|
+
t.Fatal("new open bypassed chmod", e, string(b))
|
|
226
|
+
}
|
|
227
|
+
t.Log("chmod 000 denies a new open; previously opened writer FD still writes/commits under Linux semantics")
|
|
228
|
+
default:
|
|
229
|
+
t.Fatal("unknown race", strings.TrimSpace(kind))
|
|
230
|
+
}
|
|
231
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"os"
|
|
5
|
+
"testing"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
func TestS1RFixtureContract(t *testing.T) {
|
|
9
|
+
if os.Geteuid() != 0 {
|
|
10
|
+
t.Skip("disposable root VM only")
|
|
11
|
+
}
|
|
12
|
+
root := s1rFixture(t)
|
|
13
|
+
for _, name := range []string{"alice", "bob", "supplementary", "acl-allow", "acl-mask", "acl-file-mask", "inherit", "readonly", "race"} {
|
|
14
|
+
if _, err := os.Stat(root + "/" + name + "/file"); err != nil {
|
|
15
|
+
t.Fatal(name, err)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"crypto/rand"
|
|
5
|
+
"encoding/hex"
|
|
6
|
+
"encoding/json"
|
|
7
|
+
"io"
|
|
8
|
+
"net"
|
|
9
|
+
"os"
|
|
10
|
+
"os/user"
|
|
11
|
+
"path/filepath"
|
|
12
|
+
"strconv"
|
|
13
|
+
"time"
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
func serveLinux(c Client) error {
|
|
17
|
+
r, err := readRecord(c.StateDir, 0)
|
|
18
|
+
if err != nil || !r.Enabled || r.Inventory != c.Expected || r.Lifecycle == nil || r.Lifecycle.Phase != "running" {
|
|
19
|
+
return errTrust
|
|
20
|
+
}
|
|
21
|
+
// Only the supervisor writes process.json.
|
|
22
|
+
// The package group can connect; ordinary users reach only the authenticated
|
|
23
|
+
// CGI status route. SO_PEERCRED also checks the package's current numeric UID.
|
|
24
|
+
u, err := user.Lookup(c.Expected.Package)
|
|
25
|
+
if err != nil {
|
|
26
|
+
return err
|
|
27
|
+
}
|
|
28
|
+
uid, err := strconv.ParseUint(u.Uid, 10, 32)
|
|
29
|
+
if err != nil {
|
|
30
|
+
return err
|
|
31
|
+
}
|
|
32
|
+
group, err := user.LookupGroup(c.Expected.Package)
|
|
33
|
+
if err != nil {
|
|
34
|
+
return err
|
|
35
|
+
}
|
|
36
|
+
gid, err := strconv.Atoi(group.Gid)
|
|
37
|
+
if err != nil {
|
|
38
|
+
return err
|
|
39
|
+
}
|
|
40
|
+
socket := filepath.Join(c.RunDir, "helper.sock")
|
|
41
|
+
l, err := net.ListenUnix("unix", &net.UnixAddr{Name: socket, Net: "unix"})
|
|
42
|
+
if err != nil {
|
|
43
|
+
return err
|
|
44
|
+
}
|
|
45
|
+
l.SetUnlinkOnClose(false)
|
|
46
|
+
defer l.Close()
|
|
47
|
+
if err := os.Chown(socket, 0, gid); err != nil {
|
|
48
|
+
return err
|
|
49
|
+
}
|
|
50
|
+
if err := os.Chmod(socket, 0660); err != nil {
|
|
51
|
+
return err
|
|
52
|
+
}
|
|
53
|
+
// Bound concurrency and each frame's size/time. No privileged mutations are
|
|
54
|
+
// accepted over this socket; lifecycle control remains fixed admin tasks.
|
|
55
|
+
slots := make(chan struct{}, 8)
|
|
56
|
+
for {
|
|
57
|
+
conn, err := l.AcceptUnix()
|
|
58
|
+
if err != nil {
|
|
59
|
+
return err
|
|
60
|
+
}
|
|
61
|
+
select {
|
|
62
|
+
case slots <- struct{}{}:
|
|
63
|
+
default:
|
|
64
|
+
conn.Close()
|
|
65
|
+
continue
|
|
66
|
+
}
|
|
67
|
+
go func() {
|
|
68
|
+
defer func() { conn.Close(); <-slots }()
|
|
69
|
+
peer, err := peerUID(conn)
|
|
70
|
+
if err != nil || (peer != 0 && peer != uint32(uid)) {
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
conn.SetDeadline(time.Now().Add(time.Second))
|
|
74
|
+
var req Request
|
|
75
|
+
d := json.NewDecoder(io.LimitReader(conn, 4097))
|
|
76
|
+
d.DisallowUnknownFields()
|
|
77
|
+
if d.Decode(&req) != nil {
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
r, err := readRecord(c.StateDir, 0)
|
|
81
|
+
readiness := "fenced"
|
|
82
|
+
if err == nil && r.Enabled && r.Inventory == c.Expected && r.Lifecycle != nil && r.Lifecycle.Phase == "running" {
|
|
83
|
+
readiness = parentReadiness(c)
|
|
84
|
+
}
|
|
85
|
+
res := Respond(c.Expected, readiness != "ready", req)
|
|
86
|
+
if readiness != "ready" {
|
|
87
|
+
res.Error = readiness
|
|
88
|
+
}
|
|
89
|
+
json.NewEncoder(conn).Encode(res)
|
|
90
|
+
}()
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// No lifecycle mutations: only the exact owned child can request admission.
|
|
95
|
+
func parentReadiness(c Client) string {
|
|
96
|
+
p, err := readProcess(c.RunDir, 0)
|
|
97
|
+
if err != nil || p.PID != os.Getppid() {
|
|
98
|
+
return "fenced"
|
|
99
|
+
}
|
|
100
|
+
actual, err := inspectSupervisor(p.PID, c.Expected)
|
|
101
|
+
if err != nil || actual != p {
|
|
102
|
+
return "fenced"
|
|
103
|
+
}
|
|
104
|
+
conn, err := net.DialTimeout("unix", filepath.Join(c.RunDir, "supervisor.sock"), 100*time.Millisecond)
|
|
105
|
+
if err != nil {
|
|
106
|
+
return "fenced"
|
|
107
|
+
}
|
|
108
|
+
defer conn.Close()
|
|
109
|
+
peer, err := peerCredentials(conn.(*net.UnixConn))
|
|
110
|
+
if err != nil || peer.Uid != 0 || int(peer.Pid) != p.PID {
|
|
111
|
+
return "fenced"
|
|
112
|
+
}
|
|
113
|
+
conn.SetDeadline(time.Now().Add(200 * time.Millisecond))
|
|
114
|
+
var nonce [32]byte
|
|
115
|
+
if _, err := rand.Read(nonce[:]); err != nil {
|
|
116
|
+
return "fenced"
|
|
117
|
+
}
|
|
118
|
+
req := supervisorRequest{Process: p, Op: "admit", Nonce: hex.EncodeToString(nonce[:])}
|
|
119
|
+
if json.NewEncoder(conn).Encode(req) != nil {
|
|
120
|
+
return "fenced"
|
|
121
|
+
}
|
|
122
|
+
res, err := decodeSupervisorReply(conn, c.Expected, req.Nonce)
|
|
123
|
+
return supervisorReadiness(res, err)
|
|
124
|
+
}
|