From df421db0719fda8cdfb6687f36114ea36892c181 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Thu, 18 May 2023 18:08:59 +0100 Subject: [PATCH] msg: make the SturdyRef overrideable with $SYNDICATE_STEP --- README.md | 3 ++- src/msg.nim | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a7c8d65..80d73a6 100644 --- a/README.md +++ b/README.md @@ -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 ``. +A utility that sends a message to `$SYNDICATE_SOCK` in the form ``. +The `$SYNDICATE_STEP` variables sets the SturdyRef capability with a default to the SturdyRef generated by ``. ## preserve_process_environment diff --git a/src/msg.nim b/src/msg.nim index b7bd7c4..b2d9a32 100644 --- a/src/msg.nim +++ b/src/msg.nim @@ -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)