git.delta.rocks / remowt / refs/commits / 023a07f7fe9b

difftreelog

refactor drop NixDaemon::connect_daemon

nxkzssyuYaroslav Bolyukin4 days agoparent: #6d9cf16.patch.diff
in: trunk

4 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -308,9 +308,9 @@
 
 [[package]]
 name = "bifrostlink"
-version = "0.2.5"
+version = "0.2.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "910f9286588d13e3dbdbbc1ad4d292656e704bc93e1f41b8a13b48e3a8e95f39"
+checksum = "2fb01af731c11dd31b23783a83a36a29f644cc1972481f6fa4f4fabc709079eb"
 dependencies = [
  "async-trait",
  "async_fn_traits",
@@ -327,9 +327,9 @@
 
 [[package]]
 name = "bifrostlink-macros"
-version = "0.2.5"
+version = "0.2.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a0ea5c423c3831c523c8ef78debdf6a64e72b21ec92148a44163a4c25c05dfd0"
+checksum = "8c4b7a5fb38b36bd81910c17ebf369f9296e508d92b1277a768a63c8a2254fdb"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -338,9 +338,9 @@
 
 [[package]]
 name = "bifrostlink-ports"
-version = "0.2.5"
+version = "0.2.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9e3a9a01ec1b8bd7d44b47cd0183a1465880e241027d9f5afcb076e11704ec70"
+checksum = "977acfcb8ed3c24ab7c2f76fb3eeebff1533c72708733ce6020f2501980b7cf2"
 dependencies = [
  "bifrostlink",
  "bytes",
@@ -1835,7 +1835,7 @@
 
 [[package]]
 name = "polkit-backend"
-version = "0.1.6"
+version = "0.1.7"
 dependencies = [
  "anyhow",
  "clap",
@@ -2055,7 +2055,7 @@
 
 [[package]]
 name = "remowt-agent"
-version = "0.1.6"
+version = "0.1.7"
 dependencies = [
  "anyhow",
  "bifrostlink",
@@ -2083,7 +2083,7 @@
 
 [[package]]
 name = "remowt-client"
-version = "0.1.6"
+version = "0.1.7"
 dependencies = [
  "anyhow",
  "bifrostlink",
@@ -2106,7 +2106,7 @@
 
 [[package]]
 name = "remowt-endpoints"
-version = "0.1.6"
+version = "0.1.7"
 dependencies = [
  "anyhow",
  "bifrostlink",
@@ -2124,7 +2124,7 @@
 
 [[package]]
 name = "remowt-link-shared"
-version = "0.1.6"
+version = "0.1.7"
 dependencies = [
  "bifrostlink",
  "bytes",
@@ -2138,7 +2138,7 @@
 
 [[package]]
 name = "remowt-plugin"
-version = "0.1.6"
+version = "0.1.7"
 dependencies = [
  "anyhow",
  "bifrostlink",
@@ -2152,7 +2152,7 @@
 
 [[package]]
 name = "remowt-polkit-shared"
-version = "0.1.6"
+version = "0.1.7"
 dependencies = [
  "nix",
  "serde",
@@ -2161,7 +2161,7 @@
 
 [[package]]
 name = "remowt-ssh"
-version = "0.1.6"
+version = "0.1.7"
 dependencies = [
  "anyhow",
  "async-trait",
@@ -2189,7 +2189,7 @@
 
 [[package]]
 name = "remowt-ui-prompt"
-version = "0.1.6"
+version = "0.1.7"
 dependencies = [
  "anyhow",
  "bifrostlink",
modifiedCargo.tomldiffbeforeafterboth
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,18 +3,18 @@
 resolver = "2"
 
 [workspace.package]
-version = "0.1.6"
+version = "0.1.7"
 license = "MIT"
 edition = "2021"
 repository = "https://git.delta.rocks/r/remowt"
 
 [workspace.dependencies]
-remowt-client = { version = "0.1.6", path = "crates/remowt-client" }
-remowt-polkit-shared = { version = "0.1.6", path = "crates/polkit-shared" }
-remowt-link-shared = { version = "0.1.6", path = "crates/remowt-link-shared" }
-remowt-plugin = { version = "0.1.6", path = "crates/remowt-plugin" }
-remowt-ui-prompt = { version = "0.1.6", path = "crates/remowt-ui-prompt" }
-remowt-endpoints = { version = "0.1.6", path = "crates/remowt-endpoints" }
+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" }
 
 bifrostlink = "0.2.0"
 bifrostlink-macros = "0.2.0"
modifiedcrates/remowt-client/src/lib.rsdiffbeforeafterboth
--- a/crates/remowt-client/src/lib.rs
+++ b/crates/remowt-client/src/lib.rs
@@ -427,7 +427,10 @@
 				};
 
 				let (tool, flags) = self.detect_escalation().await?;
-				let mut args: Vec<String> = flags.iter().map(|f| (*f).to_owned()).collect();
+				let mut args: Vec<String> = Vec::new();
+				args.push("-w".to_owned());
+				args.push(tool.to_owned());
+				args.extend(flags.iter().copied().map(str::to_owned));
 				args.push(agent_path);
 				args.push("real-agent".to_owned());
 				args.push("--privileged".to_owned());
@@ -437,7 +440,7 @@
 
 				let child = self
 					.spawn(SpawnOptions {
-						program: tool.to_owned(),
+						program: "setsid".to_owned(),
 						args,
 						stdin: StdioMode::Pipe,
 						stdout: StdioMode::Pipe,
modifiedcrates/remowt-endpoints/src/nix_daemon.rsdiffbeforeafterboth
6use std::result::Result;6use std::result::Result;
7use tokio::process::Command;7use tokio::process::Command;
8
9pub const NIX_DAEMON_SOCKET: &str = "/nix/var/nix/daemon-socket/socket";
108
11pub struct NixDaemon;9pub struct NixDaemon;
1210
2018
21#[endpoints(ns = 4)]19#[endpoints(ns = 4)]
22impl NixDaemon {20impl NixDaemon {
23 #[endpoints(id = 1)]
24 async fn connect_daemon(&self, socket: String) -> Result<(), Error> {
25 let mut daemon = tokio::net::UnixStream::connect(NIX_DAEMON_SOCKET)
26 .await
27 .map_err(|e| Error::DaemonUnavailable(e.to_string()))?;
28 let mut tunnel = tokio::net::UnixStream::connect(&socket)
29 .await
30 .map_err(|e| Error::Tunnel(e.to_string()))?;
31 tokio::spawn(async move {
32 if let Err(e) = tokio::io::copy_bidirectional(&mut daemon, &mut tunnel).await {
33 tracing::debug!("nix daemon tunnel ended: {e}");
34 }
35 });
36 Ok(())
37 }
38
39 #[endpoints(id = 2)]21 #[endpoints(id = 2)]
40 async fn serve_store(&self, store: String, socket: String) -> Result<(), Error> {22 async fn serve_store(&self, store: String, socket: String) -> Result<(), Error> {