From 7740c945172347733980c3fd8259f7e5afdefe67 Mon Sep 17 00:00:00 2001 From: hosted-fornet Date: Mon, 4 Nov 2024 16:17:31 -0800 Subject: [PATCH 1/4] terminal: have `m` pass all terminal caps on message --- kinode/packages/terminal/m/src/lib.rs | 7 +++++-- kinode/packages/terminal/pkg/manifest.json | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/kinode/packages/terminal/m/src/lib.rs b/kinode/packages/terminal/m/src/lib.rs index 378eea94..0155a658 100644 --- a/kinode/packages/terminal/m/src/lib.rs +++ b/kinode/packages/terminal/m/src/lib.rs @@ -1,5 +1,5 @@ use clap::{Arg, Command}; -use kinode_process_lib::{println, script, Address, Request, SendErrorKind}; +use kinode_process_lib::{our_capabilities, println, script, Address, Request, SendErrorKind}; use regex::Regex; wit_bindgen::generate!({ @@ -58,7 +58,10 @@ fn init(_our: Address, args: String) -> String { return format!("No body given.\n{USAGE}"); }; - let req = Request::new().target(target).body(body.as_bytes().to_vec()); + let req = Request::new() + .target(target) + .body(body.as_bytes().to_vec()) + .capabilities(our_capabilities()); match parsed.get_one::("await") { Some(s) => { diff --git a/kinode/packages/terminal/pkg/manifest.json b/kinode/packages/terminal/pkg/manifest.json index 0e83a3f1..13634f7d 100644 --- a/kinode/packages/terminal/pkg/manifest.json +++ b/kinode/packages/terminal/pkg/manifest.json @@ -7,6 +7,22 @@ "request_capabilities": [ "app-store:app-store:sys", "contacts:contacts:sys", + { + "process": "contacts:contacts:sys", + "params": "ReadNameOnly" + }, + { + "process": "contacts:contacts:sys", + "params": "Read" + }, + { + "process": "contacts:contacts:sys", + "params": "Add" + }, + { + "process": "contacts:contacts:sys", + "params": "Remove" + }, "chess:chess:sys", "eth:distro:sys", { From 61ea6dc13f7310fc0e013397c0f6c53b6dd1a880 Mon Sep 17 00:00:00 2001 From: hosted-fornet Date: Mon, 4 Nov 2024 16:56:44 -0800 Subject: [PATCH 2/4] 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) => { From 28664d7c27261dfd74127a85a020fd5452faa75e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2024 01:58:54 +0000 Subject: [PATCH 3/4] Format Rust code using rustfmt --- kinode/src/kernel/process.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/kinode/src/kernel/process.rs b/kinode/src/kernel/process.rs index 093aa7e8..375fa3ac 100644 --- a/kinode/src/kernel/process.rs +++ b/kinode/src/kernel/process.rs @@ -507,12 +507,10 @@ pub async fn make_process_loop( reinitialize.await; None } - Some(wait_till) => { - Some(tokio::spawn(async move { - tokio::time::sleep_until(wait_till).await; - reinitialize.await; - })) - } + Some(wait_till) => Some(tokio::spawn(async move { + tokio::time::sleep_until(wait_till).await; + reinitialize.await; + })), }; *restart_backoff_lock = Some(RestartBackoff { next_soonest_restart_time, From 108aacf16bbe6fa075adc3961e4b3c9847255c74 Mon Sep 17 00:00:00 2001 From: hosted-fornet Date: Thu, 5 Dec 2024 08:35:36 -0800 Subject: [PATCH 4/4] move contacts caps from terminal request to contacts grant --- kinode/packages/contacts/pkg/manifest.json | 17 +++++++++++++++++ kinode/packages/terminal/pkg/manifest.json | 17 ----------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/kinode/packages/contacts/pkg/manifest.json b/kinode/packages/contacts/pkg/manifest.json index 8cbffda6..01257601 100644 --- a/kinode/packages/contacts/pkg/manifest.json +++ b/kinode/packages/contacts/pkg/manifest.json @@ -13,6 +13,23 @@ "grant_capabilities": [ "eth:distro:sys", "http-server:distro:sys", + "terminal:terminal:sys", + { + "process": "terminal:terminal:sys", + "params": "ReadNameOnly" + }, + { + "process": "terminal:terminal:sys", + "params": "Read" + }, + { + "process": "terminal:terminal:sys", + "params": "Add" + }, + { + "process": "terminal:terminal:sys", + "params": "Remove" + }, "vfs:distro:sys" ], "public": false diff --git a/kinode/packages/terminal/pkg/manifest.json b/kinode/packages/terminal/pkg/manifest.json index 13634f7d..2a6f5317 100644 --- a/kinode/packages/terminal/pkg/manifest.json +++ b/kinode/packages/terminal/pkg/manifest.json @@ -6,23 +6,6 @@ "request_networking": true, "request_capabilities": [ "app-store:app-store:sys", - "contacts:contacts:sys", - { - "process": "contacts:contacts:sys", - "params": "ReadNameOnly" - }, - { - "process": "contacts:contacts:sys", - "params": "Read" - }, - { - "process": "contacts:contacts:sys", - "params": "Add" - }, - { - "process": "contacts:contacts:sys", - "params": "Remove" - }, "chess:chess:sys", "eth:distro:sys", {