msg: make the SturdyRef overrideable with $SYNDICATE_STEP

This commit is contained in:
Emery Hemingway 2023-05-18 18:08:59 +01:00
parent e898bc62db
commit df421db071
2 changed files with 8 additions and 2 deletions

View File

@ -12,7 +12,8 @@ Do not send messages immediately to the dataspace passed `json_socket_translator
## msg
A utility that sends a message to $SYNDICATE_SOCK in the form `<ARGV…>`.
A utility that sends a message to `$SYNDICATE_SOCK` in the form `<ARGV0 ARG1 … ARGVn>`.
The `$SYNDICATE_STEP` variables sets the SturdyRef capability with a default to the SturdyRef generated by `<ref { oid: "syndicate" key: #x"" }>`.
## preserve_process_environment

View File

@ -9,10 +9,15 @@ proc unixSocketPath: Unix =
if result.path == "":
result.path = getEnv("XDG_RUNTIME_DIR", "/run/user/1000") / "dataspace"
proc envStep: Preserve[Ref] =
var s = getEnv("SYNDICATE_STEP")
if s != "": parsePreserves(s, Ref)
else: capabilities.mint().toPreserve(Ref)
proc main =
let label = getAppFilename().extractFilename
bootDataspace(label) do (root: Ref; turn: var Turn):
connect(turn, unixSocketPath(), capabilities.mint().toPreserve(Ref)) do (turn: var Turn; ds: Ref):
connect(turn, unixSocketPath(), envStep()) do (turn: var Turn; ds: Ref):
message(turn, ds, initRecord(label, map(commandLineParams(), parsePreserves)))
for i in 0..3: poll(20)