@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.
Files changed (438) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -0
  3. package/dist/build-spk/generator.js +3 -0
  4. package/dist/build-spk/notices.d.ts +5 -0
  5. package/dist/build-spk/notices.js +60 -0
  6. package/dist/cli.js +9 -2
  7. package/dist/error-registry.js +20 -0
  8. package/dist/init.d.ts +4 -0
  9. package/dist/init.js +20 -12
  10. package/dist/standalone/build.js +3 -1
  11. package/dist/standalone/daemon.d.ts +23 -0
  12. package/dist/standalone/daemon.js +114 -0
  13. package/dist/standalone/dsm-window.d.ts +1 -1
  14. package/dist/standalone/dsm-window.js +50 -10
  15. package/dist/standalone/helper-inventory.d.ts +16 -0
  16. package/dist/standalone/helper-inventory.js +2 -0
  17. package/dist/standalone/helper.d.ts +2 -12
  18. package/dist/standalone/helper.js +8 -7
  19. package/dist/standalone/host-adapter.d.ts +5 -0
  20. package/dist/standalone/host-adapter.js +148 -0
  21. package/dist/standalone/host-platform.d.ts +13 -0
  22. package/dist/standalone/host-platform.js +42 -0
  23. package/dist/standalone/host-types.d.ts +49 -0
  24. package/dist/standalone/host-types.js +1 -0
  25. package/dist/standalone/inspect-helper.d.ts +6 -0
  26. package/dist/standalone/inspect-helper.js +88 -0
  27. package/dist/standalone/inspect-spk.d.ts +2 -0
  28. package/dist/standalone/inspect-spk.js +49 -0
  29. package/dist/standalone/lifecycle-helper.d.ts +2 -0
  30. package/dist/standalone/lifecycle-helper.js +12 -0
  31. package/dist/standalone/lifecycle.d.ts +3 -0
  32. package/dist/standalone/lifecycle.js +53 -0
  33. package/dist/standalone/manifest.d.ts +2 -0
  34. package/dist/standalone/manifest.js +4 -1
  35. package/dist/standalone/reopen-events.d.ts +2 -0
  36. package/dist/standalone/reopen-events.js +28 -0
  37. package/dist/standalone/root-messages.js +9 -0
  38. package/dist/standalone/root-window.d.ts +4 -3
  39. package/dist/standalone/root-window.js +17 -5
  40. package/dist/standalone/spk.d.ts +4 -3
  41. package/dist/standalone/spk.js +20 -33
  42. package/dist/template-paths.d.ts +2 -0
  43. package/dist/template-paths.js +9 -0
  44. package/dist/templates/_daemon/fixture_linux_test.go +15 -0
  45. package/dist/templates/_daemon/fixture_other_test.go +7 -0
  46. package/dist/templates/_daemon/go.mod +3 -0
  47. package/dist/templates/_daemon/main.go +608 -0
  48. package/dist/templates/_daemon/main_test.go +242 -0
  49. package/dist/templates/_daemon/process_linux.go +55 -0
  50. package/dist/templates/_daemon/process_linux_test.go +161 -0
  51. package/dist/templates/_daemon/process_other.go +14 -0
  52. package/dist/templates/_daemon/testdata/child.go +41 -0
  53. package/dist/templates/_shared/GO-LICENSE +27 -0
  54. package/dist/templates/_shared/GO-PATENTS +22 -0
  55. package/dist/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
  56. package/dist/templates/_shared/notice-overrides/index.json +14 -0
  57. package/dist/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
  58. package/dist/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
  59. package/dist/templates/_shared/third-party-notices.mjs +51 -0
  60. package/dist/templates/native-go/README.md +57 -1
  61. package/dist/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
  62. package/dist/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
  63. package/dist/templates/native-go/backend/go.mod +4 -0
  64. package/dist/templates/native-go/backend/go.sum +4 -0
  65. package/dist/templates/native-go/backend/internal/api/binary.go +154 -0
  66. package/dist/templates/native-go/backend/internal/api/binary_test.go +165 -0
  67. package/dist/templates/native-go/backend/internal/api/registry.go +14 -4
  68. package/dist/templates/native-go/backend/internal/api/server.go +4 -0
  69. package/dist/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
  70. package/dist/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
  71. package/dist/templates/native-go/backend/internal/app/routes.go +11 -0
  72. package/dist/templates/native-go/backend/internal/app/routes_test.go +10 -5
  73. package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
  74. package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
  75. package/dist/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
  76. package/dist/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
  77. package/dist/templates/native-go/backend/internal/helper/cohort.go +393 -0
  78. package/dist/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
  79. package/dist/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
  80. package/dist/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
  81. package/dist/templates/native-go/backend/internal/helper/control.go +226 -21
  82. package/dist/templates/native-go/backend/internal/helper/control_test.go +10 -2
  83. package/dist/templates/native-go/backend/internal/helper/data_contract.go +242 -0
  84. package/dist/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
  85. package/dist/templates/native-go/backend/internal/helper/data_decode.go +184 -0
  86. package/dist/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
  87. package/dist/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
  88. package/dist/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
  89. package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
  90. package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
  91. package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
  92. package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
  93. package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
  94. package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
  95. package/dist/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
  96. package/dist/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
  97. package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
  98. package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
  99. package/dist/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
  100. package/dist/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
  101. package/dist/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
  102. package/dist/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
  103. package/dist/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
  104. package/dist/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
  105. package/dist/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
  106. package/dist/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
  107. package/dist/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
  108. package/dist/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
  109. package/dist/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
  110. package/dist/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
  111. package/dist/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
  112. package/dist/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
  113. package/dist/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
  114. package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
  115. package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
  116. package/dist/templates/native-go/backend/internal/helper/lease.go +112 -0
  117. package/dist/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
  118. package/dist/templates/native-go/backend/internal/helper/lease_other.go +8 -0
  119. package/dist/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
  120. package/dist/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
  121. package/dist/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
  122. package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
  123. package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
  124. package/dist/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
  125. package/dist/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
  126. package/dist/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
  127. package/dist/templates/native-go/backend/internal/helper/native_identity.go +89 -0
  128. package/dist/templates/native-go/backend/internal/helper/native_provider.go +159 -0
  129. package/dist/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
  130. package/dist/templates/native-go/backend/internal/helper/observation.go +204 -0
  131. package/dist/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
  132. package/dist/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
  133. package/dist/templates/native-go/backend/internal/helper/observation_test.go +196 -0
  134. package/dist/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
  135. package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
  136. package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
  137. package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
  138. package/dist/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
  139. package/dist/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
  140. package/dist/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
  141. package/dist/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
  142. package/dist/templates/native-go/backend/internal/helper/process_linux.go +11 -1
  143. package/dist/templates/native-go/backend/internal/helper/publication_test.go +178 -0
  144. package/dist/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
  145. package/dist/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
  146. package/dist/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
  147. package/dist/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
  148. package/dist/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
  149. package/dist/templates/native-go/backend/internal/helper/readonly.go +105 -0
  150. package/dist/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
  151. package/dist/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
  152. package/dist/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
  153. package/dist/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
  154. package/dist/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
  155. package/dist/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
  156. package/dist/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
  157. package/dist/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
  158. package/dist/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
  159. package/dist/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
  160. package/dist/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
  161. package/dist/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
  162. package/dist/templates/native-go/backend/internal/helper/repair.go +132 -0
  163. package/dist/templates/native-go/backend/internal/helper/repair_test.go +271 -0
  164. package/dist/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
  165. package/dist/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
  166. package/dist/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
  167. package/dist/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
  168. package/dist/templates/native-go/backend/internal/helper/server_linux.go +44 -3
  169. package/dist/templates/native-go/backend/internal/helper/status.go +74 -11
  170. package/dist/templates/native-go/backend/internal/helper/status_test.go +83 -0
  171. package/dist/templates/native-go/backend/internal/helper/supervision.go +28 -5
  172. package/dist/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
  173. package/dist/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
  174. package/dist/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
  175. package/dist/templates/native-go/backend/internal/helper/supervisor_linux.go +187 -16
  176. package/dist/templates/native-go/backend/internal/helper/supervisor_linux_test.go +618 -7
  177. package/dist/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
  178. package/dist/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
  179. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
  180. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
  181. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
  182. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
  183. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
  184. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
  185. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
  186. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
  187. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
  188. package/dist/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
  189. package/dist/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
  190. package/dist/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
  191. package/dist/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
  192. package/dist/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
  193. package/dist/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
  194. package/dist/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
  195. package/dist/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
  196. package/dist/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
  197. package/dist/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
  198. package/dist/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
  199. package/dist/templates/native-go/backend/internal/helper/write.go +77 -0
  200. package/dist/templates/native-go/backend/internal/helper/write_admission.go +260 -0
  201. package/dist/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
  202. package/dist/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
  203. package/dist/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
  204. package/dist/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
  205. package/dist/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
  206. package/dist/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
  207. package/dist/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
  208. package/dist/templates/native-go/backend/internal/helper/write_test.go +53 -0
  209. package/dist/templates/native-go/ui/app.js +8 -1
  210. package/dist/templates/native-go-better-auth/node/build.mjs +2 -0
  211. package/dist/templates/native-go-vue/README.md +115 -1
  212. package/dist/templates/native-go-vue/frontend/DESIGN.md +1 -1
  213. package/dist/templates/native-go-vue/frontend/package-lock.json +132 -229
  214. package/dist/templates/native-go-vue/frontend/package.json +1 -1
  215. package/dist/templates/native-go-vue/frontend/src/App.vue +33 -6
  216. package/dist/templates/native-go-vue/frontend/src/context.ts +41 -2
  217. package/dist/templates/native-go-vue/frontend/src/main.ts +4 -1
  218. package/dist/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
  219. package/dist/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
  220. package/dist/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
  221. package/dist/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
  222. package/dist/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
  223. package/dist/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
  224. package/dist/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
  225. package/dist/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
  226. package/dist/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
  227. package/dist/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
  228. package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
  229. package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
  230. package/dist/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
  231. package/dist/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
  232. package/dist/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
  233. package/dist/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
  234. package/dist/templates/native-go-vue/frontend/src/style.css +17 -0
  235. package/dist/templates/native-go-vue/frontend/test/apps.test.ts +44 -2
  236. package/dist/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
  237. package/dist/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
  238. package/dist/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
  239. package/dist/templates/native-go-vue/frontend/tsconfig.json +1 -1
  240. package/dist/templates/native-go-vue/frontend/vite.config.ts +6 -4
  241. package/package.json +3 -2
  242. package/templates/_daemon/fixture_linux_test.go +15 -0
  243. package/templates/_daemon/fixture_other_test.go +7 -0
  244. package/templates/_daemon/go.mod +3 -0
  245. package/templates/_daemon/main.go +608 -0
  246. package/templates/_daemon/main_test.go +242 -0
  247. package/templates/_daemon/process_linux.go +55 -0
  248. package/templates/_daemon/process_linux_test.go +161 -0
  249. package/templates/_daemon/process_other.go +14 -0
  250. package/templates/_daemon/testdata/child.go +41 -0
  251. package/templates/_shared/GO-LICENSE +27 -0
  252. package/templates/_shared/GO-PATENTS +22 -0
  253. package/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
  254. package/templates/_shared/notice-overrides/index.json +14 -0
  255. package/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
  256. package/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
  257. package/templates/_shared/third-party-notices.mjs +51 -0
  258. package/templates/native-go/README.md +57 -1
  259. package/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
  260. package/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
  261. package/templates/native-go/backend/go.mod +4 -0
  262. package/templates/native-go/backend/go.sum +4 -0
  263. package/templates/native-go/backend/internal/api/binary.go +154 -0
  264. package/templates/native-go/backend/internal/api/binary_test.go +165 -0
  265. package/templates/native-go/backend/internal/api/registry.go +14 -4
  266. package/templates/native-go/backend/internal/api/server.go +4 -0
  267. package/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
  268. package/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
  269. package/templates/native-go/backend/internal/app/routes.go +11 -0
  270. package/templates/native-go/backend/internal/app/routes_test.go +10 -5
  271. package/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
  272. package/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
  273. package/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
  274. package/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
  275. package/templates/native-go/backend/internal/helper/cohort.go +393 -0
  276. package/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
  277. package/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
  278. package/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
  279. package/templates/native-go/backend/internal/helper/control.go +226 -21
  280. package/templates/native-go/backend/internal/helper/control_test.go +10 -2
  281. package/templates/native-go/backend/internal/helper/data_contract.go +242 -0
  282. package/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
  283. package/templates/native-go/backend/internal/helper/data_decode.go +184 -0
  284. package/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
  285. package/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
  286. package/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
  287. package/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
  288. package/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
  289. package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
  290. package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
  291. package/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
  292. package/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
  293. package/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
  294. package/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
  295. package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
  296. package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
  297. package/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
  298. package/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
  299. package/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
  300. package/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
  301. package/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
  302. package/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
  303. package/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
  304. package/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
  305. package/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
  306. package/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
  307. package/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
  308. package/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
  309. package/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
  310. package/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
  311. package/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
  312. package/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
  313. package/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
  314. package/templates/native-go/backend/internal/helper/lease.go +112 -0
  315. package/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
  316. package/templates/native-go/backend/internal/helper/lease_other.go +8 -0
  317. package/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
  318. package/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
  319. package/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
  320. package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
  321. package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
  322. package/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
  323. package/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
  324. package/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
  325. package/templates/native-go/backend/internal/helper/native_identity.go +89 -0
  326. package/templates/native-go/backend/internal/helper/native_provider.go +159 -0
  327. package/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
  328. package/templates/native-go/backend/internal/helper/observation.go +204 -0
  329. package/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
  330. package/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
  331. package/templates/native-go/backend/internal/helper/observation_test.go +196 -0
  332. package/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
  333. package/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
  334. package/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
  335. package/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
  336. package/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
  337. package/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
  338. package/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
  339. package/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
  340. package/templates/native-go/backend/internal/helper/process_linux.go +11 -1
  341. package/templates/native-go/backend/internal/helper/publication_test.go +178 -0
  342. package/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
  343. package/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
  344. package/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
  345. package/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
  346. package/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
  347. package/templates/native-go/backend/internal/helper/readonly.go +105 -0
  348. package/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
  349. package/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
  350. package/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
  351. package/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
  352. package/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
  353. package/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
  354. package/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
  355. package/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
  356. package/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
  357. package/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
  358. package/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
  359. package/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
  360. package/templates/native-go/backend/internal/helper/repair.go +132 -0
  361. package/templates/native-go/backend/internal/helper/repair_test.go +271 -0
  362. package/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
  363. package/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
  364. package/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
  365. package/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
  366. package/templates/native-go/backend/internal/helper/server_linux.go +44 -3
  367. package/templates/native-go/backend/internal/helper/status.go +74 -11
  368. package/templates/native-go/backend/internal/helper/status_test.go +83 -0
  369. package/templates/native-go/backend/internal/helper/supervision.go +28 -5
  370. package/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
  371. package/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
  372. package/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
  373. package/templates/native-go/backend/internal/helper/supervisor_linux.go +187 -16
  374. package/templates/native-go/backend/internal/helper/supervisor_linux_test.go +618 -7
  375. package/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
  376. package/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
  377. package/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
  378. package/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
  379. package/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
  380. package/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
  381. package/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
  382. package/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
  383. package/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
  384. package/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
  385. package/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
  386. package/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
  387. package/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
  388. package/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
  389. package/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
  390. package/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
  391. package/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
  392. package/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
  393. package/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
  394. package/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
  395. package/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
  396. package/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
  397. package/templates/native-go/backend/internal/helper/write.go +77 -0
  398. package/templates/native-go/backend/internal/helper/write_admission.go +260 -0
  399. package/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
  400. package/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
  401. package/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
  402. package/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
  403. package/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
  404. package/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
  405. package/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
  406. package/templates/native-go/backend/internal/helper/write_test.go +53 -0
  407. package/templates/native-go/ui/app.js +8 -1
  408. package/templates/native-go-better-auth/node/build.mjs +2 -0
  409. package/templates/native-go-vue/README.md +115 -1
  410. package/templates/native-go-vue/frontend/DESIGN.md +1 -1
  411. package/templates/native-go-vue/frontend/package-lock.json +132 -229
  412. package/templates/native-go-vue/frontend/package.json +1 -1
  413. package/templates/native-go-vue/frontend/src/App.vue +33 -6
  414. package/templates/native-go-vue/frontend/src/context.ts +41 -2
  415. package/templates/native-go-vue/frontend/src/main.ts +4 -1
  416. package/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
  417. package/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
  418. package/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
  419. package/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
  420. package/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
  421. package/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
  422. package/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
  423. package/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
  424. package/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
  425. package/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
  426. package/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
  427. package/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
  428. package/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
  429. package/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
  430. package/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
  431. package/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
  432. package/templates/native-go-vue/frontend/src/style.css +17 -0
  433. package/templates/native-go-vue/frontend/test/apps.test.ts +44 -2
  434. package/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
  435. package/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
  436. package/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
  437. package/templates/native-go-vue/frontend/tsconfig.json +1 -1
  438. package/templates/native-go-vue/frontend/vite.config.ts +6 -4
@@ -0,0 +1,242 @@
1
+ package main
2
+
3
+ import (
4
+ "context"
5
+ "encoding/json"
6
+ "os"
7
+ "os/exec"
8
+ "os/user"
9
+ "path/filepath"
10
+ "runtime"
11
+ "strings"
12
+ "syscall"
13
+ "testing"
14
+ "time"
15
+ )
16
+
17
+ func fixture(t *testing.T, mode string) (string, string, string) {
18
+ t.Helper()
19
+ root, err := os.MkdirTemp("/tmp", "c1-runtime-")
20
+ if err != nil {
21
+ t.Fatal(err)
22
+ }
23
+ t.Cleanup(func() { os.RemoveAll(root) })
24
+ dest, data := filepath.Join(root, "target"), filepath.Join(root, "var")
25
+ if err := os.MkdirAll(filepath.Join(dest, "daemon/payload"), 0755); err != nil {
26
+ t.Fatal(err)
27
+ }
28
+ if err := os.Mkdir(data, 0700); err != nil {
29
+ t.Fatal(err)
30
+ }
31
+ control, child := os.Getenv("DAEMON_CONTROL_BIN"), os.Getenv("DAEMON_CHILD_BIN")
32
+ if control == "" {
33
+ control, child = filepath.Join(root, "control"), filepath.Join(root, "child")
34
+ for _, spec := range [][]string{{"build", "-o", control, "."}, {"build", "-o", child, "./testdata/child.go"}} {
35
+ if raw, err := exec.Command("go", spec...).CombinedOutput(); err != nil {
36
+ t.Fatalf("%v: %s", err, raw)
37
+ }
38
+ }
39
+ }
40
+ raw, err := os.ReadFile(child)
41
+ if err != nil {
42
+ t.Fatal(err)
43
+ }
44
+ if err := os.WriteFile(filepath.Join(dest, "daemon/payload/app"), raw, 0755); err != nil {
45
+ t.Fatal(err)
46
+ }
47
+ cfg := config{Package: "DaemonFixture", Exec: "app", Args: []string{"${SYNOPKG_PKGVAR}/a space", "$(touch BAD)'", "${SYNOPKG_PKGDEST}"}, Env: map[string]string{"APP_MODE": mode}, Timeouts: deadlines{Start: 2, Stop: 2, Status: 1}}
48
+ if os.Geteuid() == 0 {
49
+ cfg.Package = "nobody"
50
+ } else {
51
+ u, err := user.Current()
52
+ if err != nil {
53
+ t.Fatal(err)
54
+ }
55
+ cfg.Package = u.Username
56
+ }
57
+ raw, _ = json.Marshal(cfg)
58
+ if err := os.WriteFile(filepath.Join(dest, "daemon/config.json"), raw, 0644); err != nil {
59
+ t.Fatal(err)
60
+ }
61
+ if os.Geteuid() == 0 {
62
+ // Only inside the disposable root VM: run the shipped manager as nobody.
63
+ if runtime.GOOS != "linux" {
64
+ t.Fatal("root fixture requires Linux VM")
65
+ }
66
+ filepath.Walk(root, func(path string, _ os.FileInfo, err error) error {
67
+ if err == nil {
68
+ return os.Chown(path, 65534, 65534)
69
+ }
70
+ return err
71
+ })
72
+ os.Chmod(root, 0755)
73
+ }
74
+ t.Cleanup(func() { runControl(control, "stop", dest, data) })
75
+ return control, dest, data
76
+ }
77
+
78
+ func runControl(control, action, dest, data string) (int, string) {
79
+ ctx, cancel := context.WithTimeout(context.Background(), 8*time.Second)
80
+ defer cancel()
81
+ cmd := exec.CommandContext(ctx, control, action, dest, data)
82
+ cmd.Env = append(os.Environ(), "UNLISTED_SECRET=must-not-leak", "LD_PRELOAD=must-not-leak")
83
+ dropFixtureUser(cmd)
84
+ raw, err := cmd.CombinedOutput()
85
+ if err == nil {
86
+ return 0, string(raw)
87
+ }
88
+ if e, ok := err.(*exec.ExitError); ok {
89
+ return e.ExitCode(), string(raw)
90
+ }
91
+ return -1, err.Error()
92
+ }
93
+
94
+ func TestDaemonLifecycle(t *testing.T) {
95
+ control, dest, data := fixture(t, "normal")
96
+ for _, step := range []struct {
97
+ action string
98
+ want int
99
+ }{{"status", 3}, {"stop", 0}, {"start", 0}, {"status", 0}, {"start", 0}, {"restart", 0}, {"stop", 0}, {"stop", 0}, {"status", 3}, {"unknown", 1}} {
100
+ if rc, out := runControl(control, step.action, dest, data); rc != step.want {
101
+ t.Fatalf("%s rc=%d want=%d: %s", step.action, rc, step.want, out)
102
+ }
103
+ }
104
+ raw, err := os.ReadFile(filepath.Join(data, "daemon/daemon.log"))
105
+ if err != nil {
106
+ t.Fatal(err)
107
+ }
108
+ if strings.Count(string(raw), `"uid":`) != 2 {
109
+ t.Fatalf("duplicate start spawned another child: %s", raw)
110
+ }
111
+ if strings.Contains(string(raw), "must-not-leak") {
112
+ t.Fatalf("ambient environment leaked: %s", raw)
113
+ }
114
+ if !strings.Contains(string(raw), "$(touch BAD)'") || !strings.Contains(string(raw), "/a space") {
115
+ t.Fatalf("argv changed: %s", raw)
116
+ }
117
+ stat, _ := os.Stat(filepath.Join(data, "daemon/daemon.log"))
118
+ if stat.Mode().Perm() != 0600 {
119
+ t.Fatal("log permissions")
120
+ }
121
+ stat, err = os.Stat(filepath.Join(data, "daemon/tmp"))
122
+ if err != nil || stat.Mode().Perm() != 0700 {
123
+ t.Fatal("private TMPDIR missing", err)
124
+ }
125
+ }
126
+
127
+ func TestImmediateExitAndEscalation(t *testing.T) {
128
+ for _, mode := range []string{"exit", "ignore"} {
129
+ t.Run(mode, func(t *testing.T) {
130
+ control, dest, data := fixture(t, mode)
131
+ rc, out := runControl(control, "start", dest, data)
132
+ if mode == "exit" {
133
+ if rc != 1 {
134
+ t.Fatalf("false readiness: %d %s", rc, out)
135
+ }
136
+ } else {
137
+ if rc != 0 {
138
+ t.Fatalf("start: %d %s", rc, out)
139
+ }
140
+ if rc, out = runControl(control, "stop", dest, data); rc != 0 {
141
+ t.Fatalf("escalation: %d %s", rc, out)
142
+ }
143
+ }
144
+ if rc, out = runControl(control, "status", dest, data); rc != 3 {
145
+ t.Fatalf("residue: %d %s", rc, out)
146
+ }
147
+ })
148
+ }
149
+ }
150
+
151
+ func TestForeignStateAndRootRefusal(t *testing.T) {
152
+ control, dest, data := fixture(t, "normal")
153
+ if os.Geteuid() == 0 {
154
+ raw, err := exec.Command(control, "start", dest, data).CombinedOutput()
155
+ if err == nil || !strings.Contains(string(raw), "package account") {
156
+ t.Fatalf("root accepted: %s %v", raw, err)
157
+ }
158
+ }
159
+ os.Mkdir(filepath.Join(data, "daemon"), 0700)
160
+ if os.Geteuid() == 0 {
161
+ os.Chown(filepath.Join(data, "daemon"), 65534, 65534)
162
+ }
163
+ os.Symlink(filepath.Join(data, "victim"), filepath.Join(data, "daemon/daemon.log"))
164
+ if rc, out := runControl(control, "start", dest, data); rc != 1 {
165
+ t.Fatalf("symlink accepted: %d %s", rc, out)
166
+ }
167
+ if _, err := os.Stat(filepath.Join(data, "victim")); !os.IsNotExist(err) {
168
+ t.Fatal("followed log symlink")
169
+ }
170
+ }
171
+
172
+ func TestUninstallCleanup(t *testing.T) {
173
+ for _, mode := range []string{"cleanup", "cleanup-fail", "cleanup-hang"} {
174
+ t.Run(mode, func(t *testing.T) {
175
+ control, dest, data := fixture(t, "normal")
176
+ path := filepath.Join(dest, "daemon/config.json")
177
+ raw, _ := os.ReadFile(path)
178
+ var cfg config
179
+ json.Unmarshal(raw, &cfg)
180
+ cfg.UninstallArgs = []string{mode, "${SYNOPKG_PKGVAR}"}
181
+ raw, _ = json.Marshal(cfg)
182
+ os.WriteFile(path, raw, 0644)
183
+ if rc, out := runControl(control, "start", dest, data); rc != 0 {
184
+ t.Fatalf("start: %d %s", rc, out)
185
+ }
186
+ want := 1
187
+ if mode == "cleanup" {
188
+ want = 0
189
+ }
190
+ if rc, out := runControl(control, "uninstall", dest, data); rc != want {
191
+ t.Fatalf("cleanup rc=%d want=%d: %s", rc, want, out)
192
+ }
193
+ if rc, out := runControl(control, "status", dest, data); rc != 3 {
194
+ t.Fatalf("cleanup must not restart daemon: %d %s", rc, out)
195
+ }
196
+ })
197
+ }
198
+ }
199
+
200
+ func TestPackageAccountIdentity(t *testing.T) {
201
+ control, dest, data := fixture(t, "normal")
202
+ path := filepath.Join(dest, "daemon/config.json")
203
+ raw, _ := os.ReadFile(path)
204
+ var cfg config
205
+ json.Unmarshal(raw, &cfg)
206
+ cfg.Package = "root"
207
+ raw, _ = json.Marshal(cfg)
208
+ os.WriteFile(path, raw, 0644)
209
+ rc, out := runControl(control, "start", dest, data)
210
+ if rc == 0 {
211
+ runControl(control, "stop", dest, data)
212
+ }
213
+ if rc != 1 {
214
+ t.Fatalf("other account accepted: %d %s", rc, out)
215
+ }
216
+ }
217
+
218
+ func TestFIFOInventoryCannotBlockStatus(t *testing.T) {
219
+ control, dest, data := fixture(t, "normal")
220
+ state := filepath.Join(data, "daemon")
221
+ os.Mkdir(state, 0700)
222
+ path := filepath.Join(state, "daemon.pid")
223
+ t.Cleanup(func() { os.Remove(path) })
224
+ if err := syscall.Mkfifo(path, 0600); err != nil {
225
+ t.Fatal(err)
226
+ }
227
+ if os.Geteuid() == 0 {
228
+ os.Chown(state, 65534, 65534)
229
+ os.Chown(path, 65534, 65534)
230
+ }
231
+ ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
232
+ defer cancel()
233
+ cmd := exec.CommandContext(ctx, control, "status", dest, data)
234
+ dropFixtureUser(cmd)
235
+ raw, err := cmd.CombinedOutput()
236
+ if ctx.Err() != nil {
237
+ t.Fatal("status blocked on FIFO")
238
+ }
239
+ if e, ok := err.(*exec.ExitError); !ok || e.ExitCode() != 1 {
240
+ t.Fatalf("FIFO status: %s %v", raw, err)
241
+ }
242
+ }
@@ -0,0 +1,55 @@
1
+ //go:build linux
2
+
3
+ package main
4
+
5
+ import (
6
+ "errors"
7
+ "net"
8
+ "os"
9
+ "strconv"
10
+ "syscall"
11
+ )
12
+
13
+ func childAttributes() *syscall.SysProcAttr { return &syscall.SysProcAttr{Pdeathsig: syscall.SIGKILL} }
14
+ func processBirth(pid int) string {
15
+ raw, err := os.ReadFile("/proc/" + strconv.Itoa(pid) + "/stat")
16
+ if err != nil {
17
+ return ""
18
+ }
19
+ birth, _ := parseBirth(string(raw))
20
+ return birth
21
+ }
22
+ func recordedChildAlive(pid int, birth string) bool {
23
+ raw, err := os.ReadFile("/proc/" + strconv.Itoa(pid) + "/stat")
24
+ if os.IsNotExist(err) {
25
+ return false
26
+ }
27
+ if err != nil {
28
+ return true
29
+ }
30
+ actual, alive := parseBirth(string(raw))
31
+ if actual == "" {
32
+ return true
33
+ }
34
+ return alive && (birth == "" || actual == birth)
35
+ }
36
+ func checkPeer(conn *net.UnixConn, pid int) error {
37
+ fd, err := conn.SyscallConn()
38
+ if err != nil {
39
+ return err
40
+ }
41
+ var peer *syscall.Ucred
42
+ var getErr error
43
+ if err := fd.Control(func(raw uintptr) {
44
+ peer, getErr = syscall.GetsockoptUcred(int(raw), syscall.SOL_SOCKET, syscall.SO_PEERCRED)
45
+ }); err != nil {
46
+ return err
47
+ }
48
+ if getErr != nil {
49
+ return getErr
50
+ }
51
+ if peer.Uid != uint32(os.Geteuid()) || peer.Pid != int32(pid) {
52
+ return errors.New("foreign daemon supervisor")
53
+ }
54
+ return nil
55
+ }
@@ -0,0 +1,161 @@
1
+ //go:build linux
2
+
3
+ package main
4
+
5
+ import (
6
+ "encoding/json"
7
+ "os"
8
+ "os/exec"
9
+ "path/filepath"
10
+ "strconv"
11
+ "sync"
12
+ "syscall"
13
+ "testing"
14
+ "time"
15
+ )
16
+
17
+ func waitDead(t *testing.T, pid int, birth string) {
18
+ t.Helper()
19
+ until := time.Now().Add(3 * time.Second)
20
+ for time.Now().Before(until) {
21
+ if !recordedChildAlive(pid, birth) {
22
+ return
23
+ }
24
+ time.Sleep(20 * time.Millisecond)
25
+ }
26
+ t.Fatalf("PID %d remained alive", pid)
27
+ }
28
+ func readFixtureRecord(t *testing.T, data string) record {
29
+ t.Helper()
30
+ raw, err := os.ReadFile(filepath.Join(data, "daemon/daemon.pid"))
31
+ if err != nil {
32
+ t.Fatal(err)
33
+ }
34
+ var r record
35
+ if err := json.Unmarshal(raw, &r); err != nil {
36
+ t.Fatal(err)
37
+ }
38
+ return r
39
+ }
40
+
41
+ func TestLinuxSupervisorDeathAndConcurrentStart(t *testing.T) {
42
+ control, dest, data := fixture(t, "normal")
43
+ var wg sync.WaitGroup
44
+ results := make(chan int, 6)
45
+ for i := 0; i < 6; i++ {
46
+ wg.Add(1)
47
+ go func() { defer wg.Done(); rc, _ := runControl(control, "start", dest, data); results <- rc }()
48
+ }
49
+ wg.Wait()
50
+ close(results)
51
+ for rc := range results {
52
+ if rc != 0 {
53
+ t.Fatalf("concurrent start: %d", rc)
54
+ }
55
+ }
56
+ r := readFixtureRecord(t, data)
57
+ if err := syscall.Kill(r.Supervisor, syscall.SIGKILL); err != nil {
58
+ t.Fatal(err)
59
+ }
60
+ waitDead(t, r.Child, r.Birth)
61
+ if rc, out := runControl(control, "status", dest, data); rc != 1 {
62
+ t.Fatalf("lost-supervisor status: %d %s", rc, out)
63
+ }
64
+ if rc, out := runControl(control, "stop", dest, data); rc != 0 {
65
+ t.Fatalf("retire dead child: %d %s", rc, out)
66
+ }
67
+ if rc, out := runControl(control, "start", dest, data); rc != 0 {
68
+ t.Fatalf("restart after death: %d %s", rc, out)
69
+ }
70
+ if r2 := readFixtureRecord(t, data); r2.Child == r.Child {
71
+ t.Fatal("did not start fresh child")
72
+ }
73
+ }
74
+
75
+ func TestLinuxInventoryNeverSignalsForeignPID(t *testing.T) {
76
+ control, dest, data := fixture(t, "normal")
77
+ if rc, out := runControl(control, "start", dest, data); rc != 0 {
78
+ t.Fatalf("start: %d %s", rc, out)
79
+ }
80
+ r := readFixtureRecord(t, data)
81
+ if rc, out := runControl(control, "stop", dest, data); rc != 0 {
82
+ t.Fatalf("stop: %d %s", rc, out)
83
+ }
84
+ foreign := exec.Command("/bin/sleep", "30")
85
+ if err := foreign.Start(); err != nil {
86
+ t.Fatal(err)
87
+ }
88
+ defer func() { foreign.Process.Kill(); foreign.Wait() }()
89
+ r.Supervisor = foreign.Process.Pid
90
+ r.Child = foreign.Process.Pid
91
+ r.Birth = processBirth(r.Child)
92
+ raw, _ := json.Marshal(r)
93
+ path := filepath.Join(data, "daemon/daemon.pid")
94
+ if err := os.WriteFile(path, raw, 0600); err != nil {
95
+ t.Fatal(err)
96
+ }
97
+ if os.Geteuid() == 0 {
98
+ os.Chown(path, 65534, 65534)
99
+ }
100
+ for _, action := range []string{"stop", "start", "restart"} {
101
+ if rc, out := runControl(control, action, dest, data); rc != 1 {
102
+ t.Fatalf("%s accepted live unwitnessed PID: %d %s", action, rc, out)
103
+ }
104
+ if !recordedChildAlive(r.Child, r.Birth) {
105
+ t.Fatal("signalled inventory PID")
106
+ }
107
+ }
108
+ // A reused numeric PID with a different birth can be retired without killing it.
109
+ r.Birth = "1"
110
+ raw, _ = json.Marshal(r)
111
+ os.WriteFile(path, raw, 0600)
112
+ if rc, out := runControl(control, "stop", dest, data); rc != 0 {
113
+ t.Fatalf("retire reused PID: %d %s", rc, out)
114
+ }
115
+ if !recordedChildAlive(foreign.Process.Pid, processBirth(foreign.Process.Pid)) {
116
+ t.Fatal("killed reused PID")
117
+ }
118
+ }
119
+
120
+ func TestLinuxChildSelfExitAndDeadlines(t *testing.T) {
121
+ control, dest, data := fixture(t, "normal")
122
+ if rc, out := runControl(control, "start", dest, data); rc != 0 {
123
+ t.Fatalf("start: %d %s", rc, out)
124
+ }
125
+ r := readFixtureRecord(t, data)
126
+ if err := syscall.Kill(r.Child, syscall.SIGTERM); err != nil {
127
+ t.Fatal(err)
128
+ }
129
+ waitDead(t, r.Child, r.Birth)
130
+ time.Sleep(100 * time.Millisecond)
131
+ if rc, out := runControl(control, "status", dest, data); rc != 1 {
132
+ t.Fatalf("self exit: %d %s", rc, out)
133
+ }
134
+ control, dest, data = fixture(t, "ignore")
135
+ if rc, out := runControl(control, "start", dest, data); rc != 0 {
136
+ t.Fatalf("start: %d %s", rc, out)
137
+ }
138
+ r = readFixtureRecord(t, data)
139
+ began := time.Now()
140
+ if rc, out := runControl(control, "stop", dest, data); rc != 0 {
141
+ t.Fatalf("stop: %d %s", rc, out)
142
+ }
143
+ if elapsed := time.Since(began); elapsed < time.Second || elapsed > 3*time.Second {
144
+ t.Fatalf("stop deadline: %s", elapsed)
145
+ }
146
+ waitDead(t, r.Child, r.Birth)
147
+ }
148
+
149
+ func TestParseLinuxProcBirth(t *testing.T) {
150
+ fields := []string{"S", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "1234"}
151
+ raw := "42 (a ) tricky name)"
152
+ for _, f := range fields {
153
+ raw += " " + f
154
+ }
155
+ if birth, alive := parseBirth(raw); birth != "1234" || !alive {
156
+ t.Fatal(birth, alive)
157
+ }
158
+ if recordedChildAlive(os.Getpid(), strconv.Itoa(os.Getpid())) {
159
+ t.Fatal("different process birth matched")
160
+ }
161
+ }
@@ -0,0 +1,14 @@
1
+ //go:build !linux
2
+
3
+ package main
4
+
5
+ import (
6
+ "net"
7
+ "syscall"
8
+ )
9
+
10
+ // Host-only tests exercise lifecycle/quoting; published controllers target Linux.
11
+ func childAttributes() *syscall.SysProcAttr { return &syscall.SysProcAttr{} }
12
+ func processBirth(int) string { return "host-fixture" }
13
+ func recordedChildAlive(pid int, _ string) bool { return syscall.Kill(pid, 0) == nil }
14
+ func checkPeer(*net.UnixConn, int) error { return nil }
@@ -0,0 +1,41 @@
1
+ // Linux/host fixture: a foreground process; never installed on a NAS.
2
+ package main
3
+
4
+ import (
5
+ "encoding/json"
6
+ "os"
7
+ "os/signal"
8
+ "syscall"
9
+ "time"
10
+ )
11
+
12
+ func main() {
13
+ if len(os.Args) > 1 {
14
+ switch os.Args[1] {
15
+ case "cleanup":
16
+ os.Exit(0)
17
+ case "cleanup-fail":
18
+ os.Exit(2)
19
+ case "cleanup-hang":
20
+ signal.Ignore(syscall.SIGTERM, syscall.SIGINT)
21
+ for {
22
+ time.Sleep(time.Second)
23
+ }
24
+ }
25
+ }
26
+ if os.Getenv("APP_MODE") == "exit" {
27
+ os.Exit(2)
28
+ }
29
+ raw, _ := json.Marshal(map[string]any{"uid": os.Geteuid(), "args": os.Args[1:], "env": os.Environ()})
30
+ fmtOutput := append(raw, '\n')
31
+ os.Stdout.Write(fmtOutput)
32
+ if os.Getenv("APP_MODE") == "ignore" {
33
+ signal.Ignore(syscall.SIGTERM, syscall.SIGINT)
34
+ for {
35
+ time.Sleep(time.Second)
36
+ }
37
+ }
38
+ c := make(chan os.Signal, 1)
39
+ signal.Notify(c, syscall.SIGTERM, syscall.SIGINT)
40
+ <-c
41
+ }
@@ -0,0 +1,27 @@
1
+ Copyright 2009 The Go Authors.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions are
5
+ met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above
10
+ copyright notice, this list of conditions and the following disclaimer
11
+ in the documentation and/or other materials provided with the
12
+ distribution.
13
+ * Neither the name of Google LLC nor the names of its
14
+ contributors may be used to endorse or promote products derived from
15
+ this software without specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,22 @@
1
+ Additional IP Rights Grant (Patents)
2
+
3
+ "This implementation" means the copyrightable works distributed by
4
+ Google as part of the Go project.
5
+
6
+ Google hereby grants to You a perpetual, worldwide, non-exclusive,
7
+ no-charge, royalty-free, irrevocable (except as stated in this section)
8
+ patent license to make, have made, use, offer to sell, sell, import,
9
+ transfer and otherwise run, modify and propagate the contents of this
10
+ implementation of Go, where such license applies only to those patent
11
+ claims, both currently owned or controlled by Google and acquired in
12
+ the future, licensable by Google that are necessarily infringed by this
13
+ implementation of Go. This grant does not include claims that would be
14
+ infringed only as a consequence of further modification of this
15
+ implementation. If you or your agent or exclusive licensee institute or
16
+ order or agree to the institution of patent litigation against any
17
+ entity (including a cross-claim or counterclaim in a lawsuit) alleging
18
+ that this implementation of Go or any code incorporated within this
19
+ implementation of Go constitutes direct or contributory patent
20
+ infringement, or inducement of patent infringement, then any patent
21
+ rights granted to you under this License for this implementation of Go
22
+ shall terminate as of the date such litigation is filed.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 synopkgland
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,14 @@
1
+ {
2
+ "@better-auth/utils@0.4.2": {
3
+ "integrity": "sha512-AUxrvu+HaaODsUyzDxFgwd/8RZ1yZaYo42LXKSrU2oGgR38pS1ij8nqQKNgtTWoYGpNevNXtCfgTy6loHveW9A==",
4
+ "file": "utils-0.4.2-LICENSE",
5
+ "source": "https://github.com/better-auth/utils/blob/ef522888b7b2ff77ca13f0afb476dfae8f297862/LICENSE",
6
+ "provenance": "Release manifests declare MIT but omit license text; retained upstream project license added in commit ef522888b7b2ff77ca13f0afb476dfae8f297862"
7
+ },
8
+ "@better-auth/utils@0.5.0": {
9
+ "integrity": "sha512-BL8W4EfIZFwlu0r54m3v1ztjDhu6dDe/amLTm0xybmbZaNgYUqhD3SjpAsnq0q8YD6/ki4iwIgxJNLP/N3TxiA==",
10
+ "file": "utils-0.5.0-LICENSE",
11
+ "source": "https://github.com/better-auth/utils/blob/ef522888b7b2ff77ca13f0afb476dfae8f297862/LICENSE",
12
+ "provenance": "Release manifests declare MIT but omit license text; retained upstream project license added in commit ef522888b7b2ff77ca13f0afb476dfae8f297862"
13
+ }
14
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 - present, Bereket Engida
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 - present, Bereket Engida
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.