@synopackageland/cli 0.4.0 → 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 +37 -0
- package/dist/build-spk/generator.js +3 -0
- package/dist/build-spk/notices.d.ts +5 -0
- package/dist/build-spk/notices.js +60 -0
- package/dist/cli.js +9 -2
- package/dist/error-registry.js +20 -0
- package/dist/init.d.ts +4 -0
- package/dist/init.js +20 -12
- package/dist/standalone/build.js +3 -1
- package/dist/standalone/daemon.d.ts +23 -0
- package/dist/standalone/daemon.js +114 -0
- package/dist/standalone/dsm-window.d.ts +1 -1
- package/dist/standalone/dsm-window.js +50 -10
- package/dist/standalone/helper-inventory.d.ts +16 -0
- package/dist/standalone/helper-inventory.js +2 -0
- package/dist/standalone/helper.d.ts +2 -12
- package/dist/standalone/helper.js +8 -7
- 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/inspect-helper.d.ts +6 -0
- package/dist/standalone/inspect-helper.js +88 -0
- package/dist/standalone/inspect-spk.d.ts +2 -0
- package/dist/standalone/inspect-spk.js +49 -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 +2 -0
- package/dist/standalone/manifest.js +4 -1
- package/dist/standalone/reopen-events.d.ts +2 -0
- package/dist/standalone/reopen-events.js +28 -0
- package/dist/standalone/root-messages.js +9 -0
- package/dist/standalone/root-window.d.ts +4 -3
- package/dist/standalone/root-window.js +17 -5
- package/dist/standalone/spk.d.ts +4 -3
- package/dist/standalone/spk.js +20 -33
- 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/native-go/README.md +57 -1
- package/dist/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
- package/dist/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
- package/dist/templates/native-go/backend/go.mod +4 -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/registry.go +14 -4
- package/dist/templates/native-go/backend/internal/api/server.go +4 -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/routes.go +11 -0
- package/dist/templates/native-go/backend/internal/app/routes_test.go +10 -5
- 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 +226 -21
- package/dist/templates/native-go/backend/internal/helper/control_test.go +10 -2
- 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/process_linux.go +11 -1
- 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 +44 -3
- package/dist/templates/native-go/backend/internal/helper/status.go +74 -11
- package/dist/templates/native-go/backend/internal/helper/status_test.go +83 -0
- package/dist/templates/native-go/backend/internal/helper/supervision.go +28 -5
- 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 +187 -16
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux_test.go +618 -7
- 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/ui/app.js +8 -1
- package/dist/templates/native-go-better-auth/node/build.mjs +2 -0
- package/dist/templates/native-go-vue/README.md +115 -1
- package/dist/templates/native-go-vue/frontend/DESIGN.md +1 -1
- package/dist/templates/native-go-vue/frontend/package-lock.json +132 -229
- package/dist/templates/native-go-vue/frontend/package.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/App.vue +33 -6
- package/dist/templates/native-go-vue/frontend/src/context.ts +41 -2
- package/dist/templates/native-go-vue/frontend/src/main.ts +4 -1
- 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 +17 -0
- package/dist/templates/native-go-vue/frontend/test/apps.test.ts +44 -2
- 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 -1
- package/dist/templates/native-go-vue/frontend/vite.config.ts +6 -4
- package/package.json +3 -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/native-go/README.md +57 -1
- package/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
- package/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
- package/templates/native-go/backend/go.mod +4 -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/registry.go +14 -4
- package/templates/native-go/backend/internal/api/server.go +4 -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/routes.go +11 -0
- package/templates/native-go/backend/internal/app/routes_test.go +10 -5
- 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 +226 -21
- package/templates/native-go/backend/internal/helper/control_test.go +10 -2
- 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/process_linux.go +11 -1
- 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 +44 -3
- package/templates/native-go/backend/internal/helper/status.go +74 -11
- package/templates/native-go/backend/internal/helper/status_test.go +83 -0
- package/templates/native-go/backend/internal/helper/supervision.go +28 -5
- 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 +187 -16
- package/templates/native-go/backend/internal/helper/supervisor_linux_test.go +618 -7
- 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/ui/app.js +8 -1
- package/templates/native-go-better-auth/node/build.mjs +2 -0
- package/templates/native-go-vue/README.md +115 -1
- package/templates/native-go-vue/frontend/DESIGN.md +1 -1
- package/templates/native-go-vue/frontend/package-lock.json +132 -229
- package/templates/native-go-vue/frontend/package.json +1 -1
- package/templates/native-go-vue/frontend/src/App.vue +33 -6
- package/templates/native-go-vue/frontend/src/context.ts +41 -2
- package/templates/native-go-vue/frontend/src/main.ts +4 -1
- 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 +17 -0
- package/templates/native-go-vue/frontend/test/apps.test.ts +44 -2
- 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 -1
- package/templates/native-go-vue/frontend/vite.config.ts +6 -4
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"crypto/rand"
|
|
6
|
+
"encoding/hex"
|
|
7
|
+
"encoding/json"
|
|
8
|
+
"golang.org/x/sys/unix"
|
|
9
|
+
"io"
|
|
10
|
+
"path"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
func authorizeReadOnly(ctx context.Context, o *readOnlyObject, w readOnlyWork, acl readOnlyACL) Code {
|
|
14
|
+
if code := nativeContextCode(ctx); code != "" {
|
|
15
|
+
return code
|
|
16
|
+
}
|
|
17
|
+
if acl == nil {
|
|
18
|
+
return ErrUnsupported
|
|
19
|
+
}
|
|
20
|
+
for _, fd := range []int{int(o.nodes[o.root].file.Fd()), int(o.data.Fd())} {
|
|
21
|
+
if code := nativeObservationCode(ctx, acl.Authorize(ctx, w.Action, fd)); code != "" {
|
|
22
|
+
return code
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return o.check()
|
|
26
|
+
}
|
|
27
|
+
func readOnlyUnchanged(fd int, before unix.Stat_t) Code {
|
|
28
|
+
var after unix.Stat_t
|
|
29
|
+
if code := readOnlyInspect(fd, &after); code != "" {
|
|
30
|
+
return code
|
|
31
|
+
}
|
|
32
|
+
if !sameReadOnlyObject(before, after) || before.Size != after.Size || before.Mtim != after.Mtim || before.Ctim != after.Ctim {
|
|
33
|
+
return ErrStale
|
|
34
|
+
}
|
|
35
|
+
return ""
|
|
36
|
+
}
|
|
37
|
+
func readOnlyEntry(name string, st unix.Stat_t) (Entry, Code) {
|
|
38
|
+
var id [32]byte
|
|
39
|
+
if _, err := rand.Read(id[:]); err != nil {
|
|
40
|
+
return Entry{}, ErrUnavailable
|
|
41
|
+
}
|
|
42
|
+
kind := "regular"
|
|
43
|
+
size := uint64(st.Size)
|
|
44
|
+
if st.Mode&unix.S_IFMT == unix.S_IFDIR {
|
|
45
|
+
kind = "directory"
|
|
46
|
+
size = 0
|
|
47
|
+
}
|
|
48
|
+
return Entry{EntryID: hex.EncodeToString(id[:]), Name: name, Kind: kind, Bytes: size}, ""
|
|
49
|
+
}
|
|
50
|
+
func executeReadOnly(ctx context.Context, pin *pinnedReadOnlyRoot, w readOnlyWork, acl readOnlyACL) (readOnlyResult, []byte) {
|
|
51
|
+
fail := func(c Code) (readOnlyResult, []byte) { return readOnlyResult{Code: c}, nil }
|
|
52
|
+
if c := nativeContextCode(ctx); c != "" {
|
|
53
|
+
return fail(c)
|
|
54
|
+
}
|
|
55
|
+
if c := w.validate(); c != "" {
|
|
56
|
+
return fail(c)
|
|
57
|
+
}
|
|
58
|
+
if acl == nil || w.Action == ActionReadStream {
|
|
59
|
+
return fail(ErrUnsupported)
|
|
60
|
+
}
|
|
61
|
+
timeout := MetadataTimeout
|
|
62
|
+
if w.Action == ActionRead {
|
|
63
|
+
timeout = BoundedTimeout
|
|
64
|
+
}
|
|
65
|
+
ctx, cancel := context.WithTimeout(ctx, timeout)
|
|
66
|
+
defer cancel()
|
|
67
|
+
o, c := resolveReadOnly(ctx, pin, w)
|
|
68
|
+
if c != "" {
|
|
69
|
+
return fail(c)
|
|
70
|
+
}
|
|
71
|
+
defer o.Close()
|
|
72
|
+
if c = authorizeReadOnly(ctx, o, w, acl); c != "" {
|
|
73
|
+
return fail(c)
|
|
74
|
+
}
|
|
75
|
+
result := readOnlyResult{}
|
|
76
|
+
var data []byte
|
|
77
|
+
switch w.Action {
|
|
78
|
+
case ActionRead:
|
|
79
|
+
if o.before.Mode&unix.S_IFMT != unix.S_IFREG {
|
|
80
|
+
return fail(ErrDenied)
|
|
81
|
+
}
|
|
82
|
+
if o.before.Size < 0 || uint64(o.before.Size) > w.MaxBytes {
|
|
83
|
+
return fail(ErrLimit)
|
|
84
|
+
}
|
|
85
|
+
var err error
|
|
86
|
+
data, err = io.ReadAll(io.LimitReader(o.data, int64(w.MaxBytes)+1))
|
|
87
|
+
if err != nil {
|
|
88
|
+
return fail(readOnlyError(err))
|
|
89
|
+
}
|
|
90
|
+
if uint64(len(data)) > w.MaxBytes {
|
|
91
|
+
return fail(ErrLimit)
|
|
92
|
+
}
|
|
93
|
+
result.Bytes = uint64(len(data))
|
|
94
|
+
case ActionStat:
|
|
95
|
+
e, c := readOnlyEntry(path.Base(w.RootPath), o.before)
|
|
96
|
+
if len(w.Segments) > 0 {
|
|
97
|
+
e.Name = w.Segments[len(w.Segments)-1]
|
|
98
|
+
}
|
|
99
|
+
if c != "" {
|
|
100
|
+
return fail(c)
|
|
101
|
+
}
|
|
102
|
+
result.Entry = &e
|
|
103
|
+
case ActionList:
|
|
104
|
+
if o.before.Mode&unix.S_IFMT != unix.S_IFDIR {
|
|
105
|
+
return fail(ErrDenied)
|
|
106
|
+
}
|
|
107
|
+
// No unbound cursor or unbounded sort/scan. Oversized/changed directories
|
|
108
|
+
// refuse without metadata; pagination is a separate server-bound extension.
|
|
109
|
+
names, err := o.data.Readdirnames(MaxPageEntries + 1)
|
|
110
|
+
if err != nil && err != io.EOF {
|
|
111
|
+
return fail(readOnlyError(err))
|
|
112
|
+
}
|
|
113
|
+
if len(names) > MaxPageEntries {
|
|
114
|
+
return fail(ErrLimit)
|
|
115
|
+
}
|
|
116
|
+
entries := []Entry{}
|
|
117
|
+
for _, name := range names {
|
|
118
|
+
if c := nativeContextCode(ctx); c != "" {
|
|
119
|
+
return fail(c)
|
|
120
|
+
}
|
|
121
|
+
child := w
|
|
122
|
+
child.Action = ActionStat
|
|
123
|
+
child.Limit = 0
|
|
124
|
+
child.Segments = append(append([]string{}, w.Segments...), name)
|
|
125
|
+
if child.validate() != "" {
|
|
126
|
+
continue
|
|
127
|
+
}
|
|
128
|
+
object, code := resolveReadOnly(ctx, pin, child)
|
|
129
|
+
if code == ErrDenied {
|
|
130
|
+
continue
|
|
131
|
+
}
|
|
132
|
+
if code != "" {
|
|
133
|
+
return fail(code)
|
|
134
|
+
}
|
|
135
|
+
code = authorizeReadOnly(ctx, object, w, acl)
|
|
136
|
+
if code == "" {
|
|
137
|
+
var entry Entry
|
|
138
|
+
entry, code = readOnlyEntry(name, object.before)
|
|
139
|
+
if code == "" {
|
|
140
|
+
entries = append(entries, entry)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
object.Close()
|
|
144
|
+
if code == ErrDenied {
|
|
145
|
+
continue
|
|
146
|
+
}
|
|
147
|
+
if code != "" {
|
|
148
|
+
return fail(code)
|
|
149
|
+
}
|
|
150
|
+
if len(entries) > int(w.Limit) {
|
|
151
|
+
return fail(ErrLimit)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
result.List = &ListResult{Entries: entries}
|
|
155
|
+
}
|
|
156
|
+
if c := authorizeReadOnly(ctx, o, w, acl); c != "" {
|
|
157
|
+
return fail(c)
|
|
158
|
+
}
|
|
159
|
+
if c := readOnlyUnchanged(int(o.data.Fd()), o.before); c != "" {
|
|
160
|
+
return fail(c)
|
|
161
|
+
}
|
|
162
|
+
// Metadata travels only over the private seqpacket, bulk read bytes never JSON.
|
|
163
|
+
b, err := json.Marshal(result)
|
|
164
|
+
if err != nil || len(b) > MaxControlBytes-2048 {
|
|
165
|
+
return fail(ErrLimit)
|
|
166
|
+
}
|
|
167
|
+
return result, data
|
|
168
|
+
}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"errors"
|
|
6
|
+
"golang.org/x/sys/unix"
|
|
7
|
+
"os"
|
|
8
|
+
"strings"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
type pinnedReadOnlyRoot struct {
|
|
12
|
+
path string
|
|
13
|
+
file *os.File
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
func (r *pinnedReadOnlyRoot) readOnlyRootPath() string { return r.path }
|
|
17
|
+
func (r *pinnedReadOnlyRoot) sameReadOnlyRoot(other readOnlyRootWitness) bool { return r == other }
|
|
18
|
+
|
|
19
|
+
func (r *pinnedReadOnlyRoot) Close() error { return r.file.Close() }
|
|
20
|
+
|
|
21
|
+
type readOnlyNode struct {
|
|
22
|
+
file *os.File
|
|
23
|
+
name string
|
|
24
|
+
stat unix.Stat_t
|
|
25
|
+
mount uint64
|
|
26
|
+
}
|
|
27
|
+
type readOnlyObject struct {
|
|
28
|
+
nodes []readOnlyNode
|
|
29
|
+
root int
|
|
30
|
+
data *os.File
|
|
31
|
+
before unix.Stat_t
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
func (o *readOnlyObject) Close() {
|
|
35
|
+
if o.data != nil {
|
|
36
|
+
o.data.Close()
|
|
37
|
+
}
|
|
38
|
+
for _, n := range o.nodes {
|
|
39
|
+
n.file.Close()
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
func readOnlyError(err error) Code {
|
|
43
|
+
if errors.Is(err, unix.EACCES) || errors.Is(err, unix.EPERM) {
|
|
44
|
+
return ErrDenied
|
|
45
|
+
}
|
|
46
|
+
if errors.Is(err, unix.ENOENT) || errors.Is(err, unix.ENOTDIR) || errors.Is(err, unix.ELOOP) {
|
|
47
|
+
return ErrStale
|
|
48
|
+
}
|
|
49
|
+
return ErrUnavailable
|
|
50
|
+
}
|
|
51
|
+
func readOnlyNodeAt(parent int, name string) (readOnlyNode, Code) {
|
|
52
|
+
fd, err := unix.Openat(parent, name, unix.O_PATH|unix.O_NOFOLLOW|unix.O_CLOEXEC, 0)
|
|
53
|
+
if err != nil {
|
|
54
|
+
return readOnlyNode{}, readOnlyError(err)
|
|
55
|
+
}
|
|
56
|
+
n := readOnlyNode{file: os.NewFile(uintptr(fd), "readonly-object"), name: name}
|
|
57
|
+
code := readOnlyInspect(fd, &n.stat)
|
|
58
|
+
if code == "" {
|
|
59
|
+
n.mount, code = readOnlyMountID(fd)
|
|
60
|
+
}
|
|
61
|
+
if code != "" {
|
|
62
|
+
n.file.Close()
|
|
63
|
+
return readOnlyNode{}, code
|
|
64
|
+
}
|
|
65
|
+
// O_PATH alone does not require search permission. Resolve '.' under actor
|
|
66
|
+
// credentials to require execute/search on every directory, including root.
|
|
67
|
+
if n.stat.Mode&unix.S_IFMT == unix.S_IFDIR {
|
|
68
|
+
probe, err := unix.Openat(fd, ".", unix.O_PATH|unix.O_DIRECTORY|unix.O_NOFOLLOW|unix.O_CLOEXEC, 0)
|
|
69
|
+
if err != nil {
|
|
70
|
+
n.file.Close()
|
|
71
|
+
return readOnlyNode{}, readOnlyError(err)
|
|
72
|
+
}
|
|
73
|
+
unix.Close(probe)
|
|
74
|
+
}
|
|
75
|
+
return n, ""
|
|
76
|
+
}
|
|
77
|
+
func readOnlyInspect(fd int, st *unix.Stat_t) Code {
|
|
78
|
+
if err := unix.Fstat(fd, st); err != nil {
|
|
79
|
+
return readOnlyError(err)
|
|
80
|
+
}
|
|
81
|
+
switch st.Mode & unix.S_IFMT {
|
|
82
|
+
case unix.S_IFDIR:
|
|
83
|
+
return ""
|
|
84
|
+
case unix.S_IFREG:
|
|
85
|
+
if st.Nlink != 1 {
|
|
86
|
+
return ErrDenied
|
|
87
|
+
}
|
|
88
|
+
return ""
|
|
89
|
+
}
|
|
90
|
+
return ErrDenied // never open a FIFO, device, socket or symlink for data
|
|
91
|
+
}
|
|
92
|
+
func sameReadOnlyObject(a, b unix.Stat_t) bool {
|
|
93
|
+
return a.Dev == b.Dev && a.Ino == b.Ino && a.Mode&unix.S_IFMT == b.Mode&unix.S_IFMT
|
|
94
|
+
}
|
|
95
|
+
func (o *readOnlyObject) check() Code {
|
|
96
|
+
for i, n := range o.nodes {
|
|
97
|
+
var st unix.Stat_t
|
|
98
|
+
if code := readOnlyInspect(int(n.file.Fd()), &st); code != "" {
|
|
99
|
+
return code
|
|
100
|
+
}
|
|
101
|
+
if !sameReadOnlyObject(st, n.stat) {
|
|
102
|
+
return ErrStale
|
|
103
|
+
}
|
|
104
|
+
if i == 0 {
|
|
105
|
+
continue
|
|
106
|
+
}
|
|
107
|
+
current, code := readOnlyNodeAt(int(o.nodes[i-1].file.Fd()), n.name)
|
|
108
|
+
if code != "" {
|
|
109
|
+
return code
|
|
110
|
+
}
|
|
111
|
+
match := sameReadOnlyObject(current.stat, n.stat) && current.mount == n.mount
|
|
112
|
+
current.file.Close()
|
|
113
|
+
if !match {
|
|
114
|
+
return ErrStale
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
var current unix.Stat_t
|
|
118
|
+
if code := readOnlyInspect(int(o.data.Fd()), ¤t); code != "" {
|
|
119
|
+
return code
|
|
120
|
+
}
|
|
121
|
+
target := o.nodes[len(o.nodes)-1]
|
|
122
|
+
if !sameReadOnlyObject(current, target.stat) {
|
|
123
|
+
return ErrStale
|
|
124
|
+
}
|
|
125
|
+
return ""
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// A pin is an O_PATH continuity witness, NOT a root-opened data/ACL capability.
|
|
129
|
+
// It remains live for one approved epoch only; never reconstruct it from inode.
|
|
130
|
+
func pinReadOnlyRoot(path string) (*pinnedReadOnlyRoot, Code) {
|
|
131
|
+
w := readOnlyWork{RootPath: path, Action: ActionStat, Segments: []string{}}
|
|
132
|
+
if code := w.validate(); code != "" {
|
|
133
|
+
return nil, code
|
|
134
|
+
}
|
|
135
|
+
slash, code := readOnlyNodeAt(unix.AT_FDCWD, "/")
|
|
136
|
+
if code != "" {
|
|
137
|
+
return nil, code
|
|
138
|
+
}
|
|
139
|
+
current := slash
|
|
140
|
+
for _, segment := range strings.Split(path[1:], "/") {
|
|
141
|
+
next, c := readOnlyNodeAt(int(current.file.Fd()), segment)
|
|
142
|
+
current.file.Close()
|
|
143
|
+
if c != "" {
|
|
144
|
+
return nil, c
|
|
145
|
+
}
|
|
146
|
+
current = next
|
|
147
|
+
if current.stat.Mode&unix.S_IFMT != unix.S_IFDIR {
|
|
148
|
+
current.file.Close()
|
|
149
|
+
return nil, ErrDenied
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if code := readOnlyLocalMount(int(current.file.Fd())); code != "" {
|
|
153
|
+
current.file.Close()
|
|
154
|
+
return nil, code
|
|
155
|
+
}
|
|
156
|
+
return &pinnedReadOnlyRoot{path: path, file: current.file}, ""
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Always uses the 4.4-compatible walk; openat2 is not a dependency. All ancestry
|
|
160
|
+
// FDs stay pinned. No realpath, Clean, pathname ACL-then-open or proc data alias.
|
|
161
|
+
func resolveReadOnly(ctx context.Context, pin *pinnedReadOnlyRoot, w readOnlyWork) (*readOnlyObject, Code) {
|
|
162
|
+
if code := nativeContextCode(ctx); code != "" {
|
|
163
|
+
return nil, code
|
|
164
|
+
}
|
|
165
|
+
if pin == nil || pin.file == nil || pin.path != w.RootPath {
|
|
166
|
+
return nil, ErrSuspended
|
|
167
|
+
}
|
|
168
|
+
flags, err := unix.FcntlInt(pin.file.Fd(), unix.F_GETFL, 0)
|
|
169
|
+
if err != nil || flags&unix.O_PATH == 0 {
|
|
170
|
+
return nil, ErrDenied
|
|
171
|
+
}
|
|
172
|
+
var expected unix.Stat_t
|
|
173
|
+
if unix.Fstat(int(pin.file.Fd()), &expected) != nil || expected.Mode&unix.S_IFMT != unix.S_IFDIR {
|
|
174
|
+
return nil, ErrSuspended
|
|
175
|
+
}
|
|
176
|
+
mount, code := readOnlyMountID(int(pin.file.Fd()))
|
|
177
|
+
if code != "" {
|
|
178
|
+
return nil, code
|
|
179
|
+
}
|
|
180
|
+
o := &readOnlyObject{}
|
|
181
|
+
ok := false
|
|
182
|
+
defer func() {
|
|
183
|
+
if !ok {
|
|
184
|
+
o.Close()
|
|
185
|
+
}
|
|
186
|
+
}()
|
|
187
|
+
slash, code := readOnlyNodeAt(unix.AT_FDCWD, "/")
|
|
188
|
+
if code != "" {
|
|
189
|
+
return nil, code
|
|
190
|
+
}
|
|
191
|
+
o.nodes = append(o.nodes, slash)
|
|
192
|
+
parts := strings.Split(w.RootPath[1:], "/")
|
|
193
|
+
o.root = len(parts)
|
|
194
|
+
parts = append(parts, w.Segments...)
|
|
195
|
+
for i, segment := range parts {
|
|
196
|
+
if code := nativeContextCode(ctx); code != "" {
|
|
197
|
+
return nil, code
|
|
198
|
+
}
|
|
199
|
+
parent := o.nodes[len(o.nodes)-1]
|
|
200
|
+
if parent.stat.Mode&unix.S_IFMT != unix.S_IFDIR {
|
|
201
|
+
return nil, ErrDenied
|
|
202
|
+
}
|
|
203
|
+
next, code := readOnlyNodeAt(int(parent.file.Fd()), segment)
|
|
204
|
+
if code != "" {
|
|
205
|
+
return nil, code
|
|
206
|
+
}
|
|
207
|
+
o.nodes = append(o.nodes, next)
|
|
208
|
+
if i+1 >= o.root && (next.mount != mount || next.stat.Dev != expected.Dev) {
|
|
209
|
+
return nil, ErrSuspended
|
|
210
|
+
}
|
|
211
|
+
if i+1 == o.root && !sameReadOnlyObject(next.stat, expected) {
|
|
212
|
+
return nil, ErrSuspended
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if code := readOnlyLocalMount(int(o.nodes[o.root].file.Fd())); code != "" {
|
|
216
|
+
return nil, code
|
|
217
|
+
}
|
|
218
|
+
target := o.nodes[len(o.nodes)-1]
|
|
219
|
+
parent := o.nodes[len(o.nodes)-2]
|
|
220
|
+
// Type-probe precedes nonblocking data open; compare both captured objects.
|
|
221
|
+
fd, err := unix.Openat(int(parent.file.Fd()), target.name, unix.O_RDONLY|unix.O_NONBLOCK|unix.O_NOFOLLOW|unix.O_CLOEXEC, 0)
|
|
222
|
+
if err != nil {
|
|
223
|
+
return nil, readOnlyError(err)
|
|
224
|
+
}
|
|
225
|
+
o.data = os.NewFile(uintptr(fd), "readonly-data")
|
|
226
|
+
if code := readOnlyInspect(fd, &o.before); code != "" {
|
|
227
|
+
return nil, code
|
|
228
|
+
}
|
|
229
|
+
m, code := readOnlyMountID(fd)
|
|
230
|
+
if code != "" {
|
|
231
|
+
return nil, code
|
|
232
|
+
}
|
|
233
|
+
if !sameReadOnlyObject(o.before, target.stat) || m != mount {
|
|
234
|
+
return nil, ErrStale
|
|
235
|
+
}
|
|
236
|
+
if code := o.check(); code != "" {
|
|
237
|
+
return nil, code
|
|
238
|
+
}
|
|
239
|
+
ok = true
|
|
240
|
+
return o, ""
|
|
241
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import "testing"
|
|
4
|
+
|
|
5
|
+
func TestReadOnlyWorkClosedActionsAndBounds(t *testing.T) {
|
|
6
|
+
for _, action := range []Action{ActionStat, ActionList, ActionRead} {
|
|
7
|
+
w := readOnlyWork{RootPath: "/fixture", Action: action, Segments: []string{"file"}}
|
|
8
|
+
if action == ActionList {
|
|
9
|
+
w.Limit = 10
|
|
10
|
+
}
|
|
11
|
+
if action == ActionRead {
|
|
12
|
+
w.MaxBytes = MaxBoundedBytes
|
|
13
|
+
}
|
|
14
|
+
if c := w.validate(); c != "" {
|
|
15
|
+
t.Fatal(action, c)
|
|
16
|
+
}
|
|
17
|
+
for _, name := range []string{"path", "traverse", "symlink-name", "limit", "action", "extra"} {
|
|
18
|
+
t.Run(string(action)+name, func(t *testing.T) {
|
|
19
|
+
bad := w
|
|
20
|
+
switch name {
|
|
21
|
+
case "path":
|
|
22
|
+
bad.RootPath = "relative"
|
|
23
|
+
case "traverse":
|
|
24
|
+
bad.Segments = []string{".."}
|
|
25
|
+
case "symlink-name":
|
|
26
|
+
bad.Segments = []string{"a/b"}
|
|
27
|
+
case "limit":
|
|
28
|
+
bad.MaxBytes = MaxBoundedBytes + 1
|
|
29
|
+
case "action":
|
|
30
|
+
bad.Action = ActionCreate
|
|
31
|
+
case "extra":
|
|
32
|
+
bad.Limit = MaxPageEntries + 1
|
|
33
|
+
}
|
|
34
|
+
if bad.validate() == "" {
|
|
35
|
+
t.Fatal("invalid work accepted")
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"crypto/sha256"
|
|
6
|
+
"encoding/hex"
|
|
7
|
+
"encoding/json"
|
|
8
|
+
"slices"
|
|
9
|
+
"strings"
|
|
10
|
+
"time"
|
|
11
|
+
"unicode/utf8"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
func validRelaxedIdentity(id RelaxedIdentity) bool {
|
|
15
|
+
return id.UID != 0 && id.Username != "" && len(id.Username) <= MaxSegmentBytes && utf8.ValidString(id.Username) && !strings.ContainsAny(id.Username, "\x00\r\n/\\")
|
|
16
|
+
}
|
|
17
|
+
func relaxedActorIdentity(a NativeActor) RelaxedIdentity {
|
|
18
|
+
return RelaxedIdentity{a.UID(), a.Username()}
|
|
19
|
+
}
|
|
20
|
+
func relaxedPrincipalIdentity(p Principal) RelaxedIdentity { return RelaxedIdentity{p.UID, p.Username} }
|
|
21
|
+
func relaxedRelated(a, b RelaxedIdentity) bool { return a.UID == b.UID || a.Username == b.Username }
|
|
22
|
+
func (r *relaxedProvider) resolve(ctx context.Context, c SessionCarriers, now func() time.Time) (NativeActor, Code) {
|
|
23
|
+
if r == nil || r.authority == nil || now == nil || r.adapters.Sessions == nil || r.adapters.Accounts == nil || r.adapters.Groups == nil || r.adapters.App == nil {
|
|
24
|
+
return NativeActor{}, ErrUnavailable
|
|
25
|
+
}
|
|
26
|
+
ctx, cancel := context.WithTimeout(ctx, NativeProofFreshness)
|
|
27
|
+
defer cancel()
|
|
28
|
+
if code := nativeContextCode(ctx); code != "" {
|
|
29
|
+
return NativeActor{}, code
|
|
30
|
+
}
|
|
31
|
+
if c.Cookie == "" {
|
|
32
|
+
return NativeActor{}, ErrDenied
|
|
33
|
+
}
|
|
34
|
+
if c.ClientAddress == "" {
|
|
35
|
+
return NativeActor{}, ErrUnavailable
|
|
36
|
+
}
|
|
37
|
+
s, code := r.adapters.Sessions.ValidateRelaxedSession(ctx, c)
|
|
38
|
+
if code = nativeObservationCode(ctx, code); code != "" {
|
|
39
|
+
return NativeActor{}, code
|
|
40
|
+
}
|
|
41
|
+
if !validRelaxedIdentity(RelaxedIdentity{UID: 1, Username: s.Username}) {
|
|
42
|
+
return NativeActor{}, ErrDenied
|
|
43
|
+
}
|
|
44
|
+
if !s.CSRFVerified || r.adapters.AppPrivilegeID == "" {
|
|
45
|
+
return NativeActor{}, ErrUnsupported
|
|
46
|
+
}
|
|
47
|
+
if !allReferences(s.SessionRef) {
|
|
48
|
+
return NativeActor{}, ErrUnavailable
|
|
49
|
+
}
|
|
50
|
+
if !nativeFresh(s.CheckedAt, now()) {
|
|
51
|
+
return NativeActor{}, ErrStale
|
|
52
|
+
}
|
|
53
|
+
a, code := r.adapters.Accounts.LookupRelaxedAccount(ctx, s.Username)
|
|
54
|
+
if code = nativeObservationCode(ctx, code); code != "" {
|
|
55
|
+
if code == ErrDenied {
|
|
56
|
+
if cleanup := r.invalidateName(ctx, s.Username); cleanup != "" {
|
|
57
|
+
return NativeActor{}, cleanup
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return NativeActor{}, code
|
|
61
|
+
}
|
|
62
|
+
if !nativeFresh(a.CheckedAt, now()) {
|
|
63
|
+
return NativeActor{}, ErrStale
|
|
64
|
+
}
|
|
65
|
+
if a.Kind != "local" {
|
|
66
|
+
return NativeActor{}, ErrUnsupported
|
|
67
|
+
}
|
|
68
|
+
if a.StateKnown && !a.Exists {
|
|
69
|
+
if code = r.invalidateName(ctx, s.Username); code != "" {
|
|
70
|
+
return NativeActor{}, code
|
|
71
|
+
}
|
|
72
|
+
return NativeActor{}, ErrDenied
|
|
73
|
+
}
|
|
74
|
+
if a.Identity.Username != s.Username {
|
|
75
|
+
if code = r.invalidateName(ctx, s.Username, a.Identity); code != "" {
|
|
76
|
+
return NativeActor{}, code
|
|
77
|
+
}
|
|
78
|
+
return NativeActor{}, ErrSuspended
|
|
79
|
+
}
|
|
80
|
+
if !a.StateKnown || !a.ExpiryKnown || !a.PasswordKnown || !a.PrimaryGIDKnown {
|
|
81
|
+
return NativeActor{}, ErrUnavailable
|
|
82
|
+
}
|
|
83
|
+
if !a.Exists || !a.Enabled || a.Expired || !a.PasswordUsable {
|
|
84
|
+
if code = r.invalidateName(ctx, s.Username, a.Identity); code != "" {
|
|
85
|
+
return NativeActor{}, code
|
|
86
|
+
}
|
|
87
|
+
return NativeActor{}, ErrDenied
|
|
88
|
+
}
|
|
89
|
+
if !validRelaxedIdentity(a.Identity) || a.PrimaryGID == 0 {
|
|
90
|
+
return NativeActor{}, ErrDenied
|
|
91
|
+
}
|
|
92
|
+
g, code := r.adapters.Groups.LookupRelaxedGroups(ctx, a)
|
|
93
|
+
if code = nativeObservationCode(ctx, code); code != "" {
|
|
94
|
+
return NativeActor{}, code
|
|
95
|
+
}
|
|
96
|
+
if !nativeFresh(g.CheckedAt, now()) {
|
|
97
|
+
return NativeActor{}, ErrStale
|
|
98
|
+
}
|
|
99
|
+
if g.Identity != a.Identity || g.PrimaryGID != a.PrimaryGID {
|
|
100
|
+
if code = r.invalidate(ctx, []RelaxedIdentity{a.Identity}); code != "" {
|
|
101
|
+
return NativeActor{}, code
|
|
102
|
+
}
|
|
103
|
+
return NativeActor{}, ErrSuspended
|
|
104
|
+
}
|
|
105
|
+
if g.Groups == nil || len(g.Groups) > 1024 || !g.Complete || !g.AdminKnown {
|
|
106
|
+
return NativeActor{}, ErrUnavailable
|
|
107
|
+
}
|
|
108
|
+
app, code := r.adapters.App.ValidateRelaxedApp(ctx, c, s, a, r.adapters.AppPrivilegeID)
|
|
109
|
+
if code = nativeObservationCode(ctx, code); code != "" {
|
|
110
|
+
if code == ErrDenied {
|
|
111
|
+
if cleanup := r.invalidate(ctx, []RelaxedIdentity{a.Identity}); cleanup != "" {
|
|
112
|
+
return NativeActor{}, cleanup
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return NativeActor{}, code
|
|
116
|
+
}
|
|
117
|
+
if !nativeFresh(app.CheckedAt, now()) {
|
|
118
|
+
return NativeActor{}, ErrStale
|
|
119
|
+
}
|
|
120
|
+
if app.Identity != a.Identity || app.ClientAddress != c.ClientAddress || app.AppID != r.adapters.AppPrivilegeID || app.SessionRef != s.SessionRef {
|
|
121
|
+
return NativeActor{}, ErrDenied
|
|
122
|
+
}
|
|
123
|
+
if !app.Allowed {
|
|
124
|
+
// Conservative grant revocation also stops this caller's foreign-shared work.
|
|
125
|
+
if code = r.invalidate(ctx, []RelaxedIdentity{a.Identity}); code != "" {
|
|
126
|
+
return NativeActor{}, code
|
|
127
|
+
}
|
|
128
|
+
return NativeActor{}, ErrDenied
|
|
129
|
+
}
|
|
130
|
+
oldest := s.CheckedAt
|
|
131
|
+
for _, at := range []time.Time{a.CheckedAt, g.CheckedAt, app.CheckedAt} {
|
|
132
|
+
if at.Before(oldest) {
|
|
133
|
+
oldest = at
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if !nativeFresh(oldest, now()) {
|
|
137
|
+
return NativeActor{}, ErrStale
|
|
138
|
+
}
|
|
139
|
+
principal, code := r.principal(ctx, a.Identity)
|
|
140
|
+
if code != "" {
|
|
141
|
+
return NativeActor{}, code
|
|
142
|
+
}
|
|
143
|
+
if !nativeFresh(oldest, now()) {
|
|
144
|
+
return NativeActor{}, ErrStale
|
|
145
|
+
}
|
|
146
|
+
groups := slices.Clone(g.Groups)
|
|
147
|
+
slices.Sort(groups)
|
|
148
|
+
groups = slices.Compact(groups)
|
|
149
|
+
return NativeActor{relaxed: r, account: LocalAccount{Principal: principal, Username: a.Identity.Username, Enabled: true, UID: a.Identity.UID, GID: a.PrimaryGID, Groups: groups, Admin: g.Admin, CheckedAt: oldest}, sessionRef: s.SessionRef, valid: true}, ""
|
|
150
|
+
}
|
|
151
|
+
func (r *relaxedProvider) principal(ctx context.Context, id RelaxedIdentity) (Principal, Code) {
|
|
152
|
+
a := r.authority
|
|
153
|
+
a.mu.Lock()
|
|
154
|
+
if r.blocked[id] {
|
|
155
|
+
a.mu.Unlock()
|
|
156
|
+
return Principal{}, ErrCleanupRequired
|
|
157
|
+
}
|
|
158
|
+
mismatches := map[RelaxedIdentity]bool{}
|
|
159
|
+
code := a.transaction(func(s *GrantStore) (bool, Code) {
|
|
160
|
+
for _, g := range s.Grants {
|
|
161
|
+
if g.State == GrantRevoked {
|
|
162
|
+
continue
|
|
163
|
+
}
|
|
164
|
+
for _, p := range []Principal{g.Owner, g.Issuer} {
|
|
165
|
+
if p.IdentityBasis != "uid-username" {
|
|
166
|
+
continue
|
|
167
|
+
}
|
|
168
|
+
before := relaxedPrincipalIdentity(p)
|
|
169
|
+
if before != id && relaxedRelated(before, id) {
|
|
170
|
+
mismatches[before] = true
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return false, ""
|
|
175
|
+
})
|
|
176
|
+
if code != "" {
|
|
177
|
+
a.mu.Unlock()
|
|
178
|
+
return Principal{}, code
|
|
179
|
+
}
|
|
180
|
+
if len(mismatches) > 0 {
|
|
181
|
+
// Block the prospective identity too until every old grant has Q.
|
|
182
|
+
ids := make([]RelaxedIdentity, 0, len(mismatches))
|
|
183
|
+
for key := range mismatches {
|
|
184
|
+
ids = append(ids, key)
|
|
185
|
+
}
|
|
186
|
+
if code = r.invalidateLocked(ctx, ids, id); code != "" {
|
|
187
|
+
return Principal{}, code
|
|
188
|
+
}
|
|
189
|
+
return Principal{}, ErrSuspended
|
|
190
|
+
}
|
|
191
|
+
defer a.mu.Unlock()
|
|
192
|
+
if p, ok := r.principals[id]; ok {
|
|
193
|
+
return p, ""
|
|
194
|
+
}
|
|
195
|
+
if len(r.principals) >= MaxReplayEntries {
|
|
196
|
+
return Principal{}, ErrBusy
|
|
197
|
+
}
|
|
198
|
+
ref, code := randomGrantID()
|
|
199
|
+
if code != "" {
|
|
200
|
+
return Principal{}, code
|
|
201
|
+
}
|
|
202
|
+
// The digest is an index, never a session or birth proof. InstanceRef is a
|
|
203
|
+
// per-owner random generation rotated on observed invalidation/restart.
|
|
204
|
+
b, _ := json.Marshal(struct {
|
|
205
|
+
Basis string
|
|
206
|
+
Identity RelaxedIdentity
|
|
207
|
+
}{"uid-username", id})
|
|
208
|
+
sum := sha256.Sum256(b)
|
|
209
|
+
p := Principal{Kind: "local", SubjectRef: hex.EncodeToString(sum[:]), InstanceRef: ref, IdentityBasis: "uid-username", UID: id.UID, Username: id.Username}
|
|
210
|
+
r.principals[id] = p
|
|
211
|
+
return p, ""
|
|
212
|
+
}
|
|
213
|
+
func (r *relaxedProvider) revalidate(ctx context.Context, c SessionCarriers, old NativeActor, now func() time.Time) (NativeActor, Code) {
|
|
214
|
+
if old.relaxed != r || old.managed != nil {
|
|
215
|
+
return NativeActor{}, ErrSuspended
|
|
216
|
+
}
|
|
217
|
+
current, code := r.resolve(ctx, c, now)
|
|
218
|
+
if code != "" {
|
|
219
|
+
return NativeActor{}, code
|
|
220
|
+
}
|
|
221
|
+
if relaxedActorIdentity(old) != relaxedActorIdentity(current) {
|
|
222
|
+
r.authority.mu.Lock()
|
|
223
|
+
if code = r.invalidateLocked(ctx, []RelaxedIdentity{relaxedActorIdentity(old)}, relaxedActorIdentity(current)); code != "" {
|
|
224
|
+
return NativeActor{}, code
|
|
225
|
+
}
|
|
226
|
+
return NativeActor{}, ErrSuspended
|
|
227
|
+
}
|
|
228
|
+
if old.Principal() != current.Principal() {
|
|
229
|
+
return NativeActor{}, ErrSuspended
|
|
230
|
+
}
|
|
231
|
+
if old.GID() != current.GID() || old.Admin() != current.Admin() || old.SessionRef() != current.SessionRef() || !slices.Equal(old.Groups(), current.Groups()) {
|
|
232
|
+
return NativeActor{}, ErrStale
|
|
233
|
+
}
|
|
234
|
+
return current, ""
|
|
235
|
+
}
|
|
236
|
+
func (a *GrantAuthority) relaxedActorLocked(actor NativeActor) Code {
|
|
237
|
+
if actor.relaxed == nil {
|
|
238
|
+
if a.native != nil && a.native.relaxed != nil {
|
|
239
|
+
return ErrDenied
|
|
240
|
+
}
|
|
241
|
+
return ""
|
|
242
|
+
}
|
|
243
|
+
if a.native == nil || a.native.relaxed != actor.relaxed || actor.managed != nil {
|
|
244
|
+
return ErrDenied
|
|
245
|
+
}
|
|
246
|
+
r := actor.relaxed
|
|
247
|
+
id := relaxedActorIdentity(actor)
|
|
248
|
+
if r.blocked[id] || r.principals[id] != actor.Principal() {
|
|
249
|
+
return ErrSuspended
|
|
250
|
+
}
|
|
251
|
+
return ""
|
|
252
|
+
}
|