From 61ea6dc13f7310fc0e013397c0f6c53b6dd1a880 Mon Sep 17 00:00:00 2001 From: hosted-fornet Date: Mon, 4 Nov 2024 16:56:44 -0800 Subject: [PATCH] terminal: only send caps issued by a given process to that process --- kinode/packages/terminal/m/src/lib.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/kinode/packages/terminal/m/src/lib.rs b/kinode/packages/terminal/m/src/lib.rs index 0155a658..4bfe8874 100644 --- a/kinode/packages/terminal/m/src/lib.rs +++ b/kinode/packages/terminal/m/src/lib.rs @@ -10,7 +10,7 @@ wit_bindgen::generate!({ const USAGE: &str = "\x1b[1mUsage:\x1b[0m m [-a ]"; script!(init); -fn init(_our: Address, args: String) -> String { +fn init(our: Address, args: String) -> String { if args.is_empty() { return format!("Send a request to a process.\n{USAGE}"); } @@ -58,10 +58,21 @@ fn init(_our: Address, args: String) -> String { return format!("No body given.\n{USAGE}"); }; + let target = if target.node() != "our" { + target + } else { + Address::new(our.node(), target.process) + }; + + let capabilities = our_capabilities() + .into_iter() + .filter(|cap| cap.issuer == target) + .collect(); + let req = Request::new() .target(target) .body(body.as_bytes().to_vec()) - .capabilities(our_capabilities()); + .capabilities(capabilities); match parsed.get_one::("await") { Some(s) => {