git.delta.rocks / remowt / refs/commits / 11447649e1e7

difftreelog

feat remowt user identity

nulpnyxpYaroslav Bolyukin3 days agoparent: #075f103.patch.diff
in: trunk

5 files changed

modifiedCargo.lockdiffbeforeafterboth
308308
309[[package]]309[[package]]
310name = "bifrostlink"310name = "bifrostlink"
311version = "0.2.6"311version = "0.2.7"
312source = "registry+https://github.com/rust-lang/crates.io-index"312source = "registry+https://github.com/rust-lang/crates.io-index"
313checksum = "2fb01af731c11dd31b23783a83a36a29f644cc1972481f6fa4f4fabc709079eb"313checksum = "0c8ce9dc1425ee2aaffd3324548f114acccd456b9b1ffb33fe9eb9a7be6475a8"
314dependencies = [314dependencies = [
315 "async-trait",315 "async-trait",
316 "async_fn_traits",316 "async_fn_traits",
322 "serde_json",322 "serde_json",
323 "tokio",323 "tokio",
324 "tracing",324 "tracing",
325 "uuid",
326]325]
327326
328[[package]]327[[package]]
329name = "bifrostlink-macros"328name = "bifrostlink-macros"
330version = "0.2.6"329version = "0.2.7"
331source = "registry+https://github.com/rust-lang/crates.io-index"330source = "registry+https://github.com/rust-lang/crates.io-index"
332checksum = "8c4b7a5fb38b36bd81910c17ebf369f9296e508d92b1277a768a63c8a2254fdb"331checksum = "a7d071add2d3b90486fe141edb2e811f7735155d320aee3936ebd67e535d6ac1"
333dependencies = [332dependencies = [
334 "proc-macro2",333 "proc-macro2",
335 "quote",334 "quote",
338337
339[[package]]338[[package]]
340name = "bifrostlink-ports"339name = "bifrostlink-ports"
341version = "0.2.6"340version = "0.2.7"
342source = "registry+https://github.com/rust-lang/crates.io-index"341source = "registry+https://github.com/rust-lang/crates.io-index"
343checksum = "977acfcb8ed3c24ab7c2f76fb3eeebff1533c72708733ce6020f2501980b7cf2"342checksum = "ccf6ba32d0ff83b27a242f9d2fca124ad215ddd9bf99144d66b7ca44a885de50"
344dependencies = [343dependencies = [
345 "bifrostlink",344 "bifrostlink",
346 "bytes",345 "bytes",
17771776
1778[[package]]1777[[package]]
1779name = "polkit-backend"1778name = "polkit-backend"
1780version = "0.1.7"1779version = "0.1.8"
1781dependencies = [1780dependencies = [
1782 "anyhow",1781 "anyhow",
1783 "clap",1782 "clap",
19511950
1952[[package]]1951[[package]]
1953name = "remowt-agent"1952name = "remowt-agent"
1954version = "0.1.7"1953version = "0.1.8"
1955dependencies = [1954dependencies = [
1956 "anyhow",1955 "anyhow",
1957 "bifrostlink",1956 "bifrostlink",
19761975
1977[[package]]1976[[package]]
1978name = "remowt-client"1977name = "remowt-client"
1979version = "0.1.7"1978version = "0.1.8"
1980dependencies = [1979dependencies = [
1981 "anyhow",1980 "anyhow",
1982 "bifrostlink",1981 "bifrostlink",
19981997
1999[[package]]1998[[package]]
2000name = "remowt-endpoints"1999name = "remowt-endpoints"
2001version = "0.1.7"2000version = "0.1.8"
2002dependencies = [2001dependencies = [
2003 "bifrostlink",2002 "bifrostlink",
2004 "camino",2003 "camino",
20132012
2014[[package]]2013[[package]]
2015name = "remowt-link-shared"2014name = "remowt-link-shared"
2016version = "0.1.7"2015version = "0.1.8"
2017dependencies = [2016dependencies = [
2018 "bifrostlink",2017 "bifrostlink",
2019 "bytes",2018 "bytes",
20272026
2028[[package]]2027[[package]]
2029name = "remowt-plugin"2028name = "remowt-plugin"
2030version = "0.1.7"2029version = "0.1.8"
2031dependencies = [2030dependencies = [
2032 "anyhow",2031 "anyhow",
2033 "bifrostlink",2032 "bifrostlink",
20402039
2041[[package]]2040[[package]]
2042name = "remowt-polkit-shared"2041name = "remowt-polkit-shared"
2043version = "0.1.7"2042version = "0.1.8"
2044dependencies = [2043dependencies = [
2045 "nix",2044 "nix",
2046 "serde",2045 "serde",
20492048
2050[[package]]2049[[package]]
2051name = "remowt-ssh"2050name = "remowt-ssh"
2052version = "0.1.7"2051version = "0.1.8"
2053dependencies = [2052dependencies = [
2054 "anyhow",2053 "anyhow",
2055 "clap",2054 "clap",
20642063
2065[[package]]2064[[package]]
2066name = "remowt-ui-prompt"2065name = "remowt-ui-prompt"
2067version = "0.1.7"2066version = "0.1.8"
2068dependencies = [2067dependencies = [
2069 "anyhow",2068 "anyhow",
2070 "bifrostlink",2069 "bifrostlink",
modifiedCargo.tomldiffbeforeafterboth
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,18 +3,18 @@
 resolver = "2"
 
 [workspace.package]
-version = "0.1.7"
+version = "0.1.8"
 license = "MIT"
 edition = "2021"
 repository = "https://git.delta.rocks/r/remowt"
 
 [workspace.dependencies]
-remowt-client = { version = "0.1.7", path = "crates/remowt-client" }
-remowt-polkit-shared = { version = "0.1.7", path = "crates/polkit-shared" }
-remowt-link-shared = { version = "0.1.7", path = "crates/remowt-link-shared" }
-remowt-plugin = { version = "0.1.7", path = "crates/remowt-plugin" }
-remowt-ui-prompt = { version = "0.1.7", path = "crates/remowt-ui-prompt" }
-remowt-endpoints = { version = "0.1.7", path = "crates/remowt-endpoints" }
+remowt-client = { version = "0.1.8", path = "crates/remowt-client" }
+remowt-polkit-shared = { version = "0.1.8", path = "crates/polkit-shared" }
+remowt-link-shared = { version = "0.1.8", path = "crates/remowt-link-shared" }
+remowt-plugin = { version = "0.1.8", path = "crates/remowt-plugin" }
+remowt-ui-prompt = { version = "0.1.8", path = "crates/remowt-ui-prompt" }
+remowt-endpoints = { version = "0.1.8", path = "crates/remowt-endpoints" }
 
 bifrostlink = "0.2.0"
 bifrostlink-macros = "0.2.0"
modifiedcmds/remowt-ssh/src/main.rsdiffbeforeafterboth
--- a/cmds/remowt-ssh/src/main.rs
+++ b/cmds/remowt-ssh/src/main.rs
@@ -53,8 +53,14 @@
 
 	let bundle = AgentBundle::from_dir(agents_dir()?)?;
 	let (conn, escalate) = match &opts {
-		Opts::Ssh { host, escalate } => (Remowt::connect(host, &bundle).await?, *escalate),
-		Opts::Local { escalate } => (Remowt::connect_local(&bundle).await?, *escalate),
+		Opts::Ssh { host, escalate } => (
+			Remowt::connect(host, &bundle, "remowt-ssh".to_owned()).await?,
+			*escalate,
+		),
+		Opts::Local { escalate } => (
+			Remowt::connect_local(&bundle, "remowt-ssh".to_owned()).await?,
+			*escalate,
+		),
 	};
 	let mut rpc = conn.rpc();
 
modifiedcrates/remowt-client/src/lib.rsdiffbeforeafterboth
--- a/crates/remowt-client/src/lib.rs
+++ b/crates/remowt-client/src/lib.rs
@@ -249,6 +249,7 @@
 	#[allow(dead_code)]
 	children: Mutex<Vec<tokio::process::Child>>,
 	_runtime_tmp: Option<TempDir>,
+	user: String,
 }
 
 #[derive(Clone)]
@@ -259,7 +260,7 @@
 impl Remowt {
 	/// Connect to the remote host over ssh, detect the architecture and deploy the required
 	/// agent binary.
-	pub async fn connect(host: &str, bundle: &AgentBundle) -> Result<Self> {
+	pub async fn connect(host: &str, bundle: &AgentBundle, remowt_user: String) -> Result<Self> {
 		let conf = russh_config::parse_home(host)?;
 		let port = conf.host_config.port.or(conf.port).unwrap_or(22);
 		let hostname = conf
@@ -337,11 +338,12 @@
 			elevated: tokio::sync::OnceCell::new(),
 			children: Mutex::new(Vec::new()),
 			_runtime_tmp: None,
+			user: remowt_user,
 		})))
 	}
 
 	/// "Connect" to the local machine's agent, by starting the agent binary locally.
-	pub async fn connect_local(bundle: &AgentBundle) -> Result<Self> {
+	pub async fn connect_local(bundle: &AgentBundle, user: String) -> Result<Self> {
 		let agent_path = bundle.local_binary()?;
 		let mut child = tokio::process::Command::new(&agent_path)
 			.arg("real-agent")
@@ -368,6 +370,7 @@
 			elevated: tokio::sync::OnceCell::new(),
 			children: Mutex::new(vec![child]),
 			_runtime_tmp: runtime_tmp,
+			user,
 		})))
 	}
 
@@ -431,6 +434,14 @@
 				args.push("-w".to_owned());
 				args.push(tool.to_owned());
 				args.extend(flags.iter().copied().map(str::to_owned));
+				if tool == "run0" {
+					args.push(format!(
+						"--unit={}-{}-{}.scope",
+						self.0.user,
+						std::process::id(),
+						Uuid::new_v4()
+					));
+				}
 				args.push(agent_path);
 				args.push("real-agent".to_owned());
 				args.push("--privileged".to_owned());
modifiedcrates/remowt-endpoints/Cargo.tomldiffbeforeafterboth
--- a/crates/remowt-endpoints/Cargo.toml
+++ b/crates/remowt-endpoints/Cargo.toml
@@ -11,7 +11,13 @@
 serde = { workspace = true }
 tempfile.workspace = true
 thiserror.workspace = true
-tokio = { workspace = true, features = ["net", "io-util", "rt", "process"] }
+tokio = { workspace = true, features = [
+	"net",
+	"io-util",
+	"rt",
+	"process",
+	"io-std",
+] }
 tracing.workspace = true
 nix = { workspace = true, features = ["process", "signal", "term"] }
 zbus.workspace = true