difftreelog
refactor drop NixDaemon::connect_daemon
in: trunk
4 files changed
Cargo.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",
Cargo.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"
crates/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,
crates/remowt-endpoints/src/nix_daemon.rsdiffbeforeafterboth1use std::process::Stdio;23use bifrostlink::declarative::endpoints;4use bifrostlink::Config;5use serde::{Deserialize, Serialize};6use std::result::Result;7use tokio::process::Command;89pub const NIX_DAEMON_SOCKET: &str = "/nix/var/nix/daemon-socket/socket";1011pub struct NixDaemon;1213#[derive(Serialize, Deserialize, Debug, thiserror::Error)]14pub enum Error {15 #[error("nix daemon unavailable: {0}")]16 DaemonUnavailable(String),17 #[error("tunnel socket unavailable: {0}")]18 Tunnel(String),19}2021#[endpoints(ns = 4)]22impl 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 .await27 .map_err(|e| Error::DaemonUnavailable(e.to_string()))?;28 let mut tunnel = tokio::net::UnixStream::connect(&socket)29 .await30 .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 }3839 #[endpoints(id = 2)]40 async fn serve_store(&self, store: String, socket: String) -> Result<(), Error> {41 let mut child = Command::new("nix-daemon")42 .arg("--stdio")43 .arg("--store")44 .arg(&store)45 .stdin(Stdio::piped())46 .stdout(Stdio::piped())47 .spawn()48 .map_err(|e| Error::DaemonUnavailable(e.to_string()))?;49 let tunnel = tokio::net::UnixStream::connect(&socket)50 .await51 .map_err(|e| Error::Tunnel(e.to_string()))?;52 let mut stdin = child.stdin.take().expect("piped");53 let mut stdout = child.stdout.take().expect("piped");54 tokio::spawn(async move {55 let mut tunnel = tunnel;56 let (mut tr, mut tw) = tunnel.split();57 let _ = tokio::join!(58 tokio::io::copy(&mut tr, &mut stdin),59 tokio::io::copy(&mut stdout, &mut tw),60 );61 let _ = child.wait().await;62 });63 Ok(())64 }65}1use std::process::Stdio;23use bifrostlink::declarative::endpoints;4use bifrostlink::Config;5use serde::{Deserialize, Serialize};6use std::result::Result;7use tokio::process::Command;89pub struct NixDaemon;1011#[derive(Serialize, Deserialize, Debug, thiserror::Error)]12pub enum Error {13 #[error("nix daemon unavailable: {0}")]14 DaemonUnavailable(String),15 #[error("tunnel socket unavailable: {0}")]16 Tunnel(String),17}1819#[endpoints(ns = 4)]20impl NixDaemon {21 #[endpoints(id = 2)]22 async fn serve_store(&self, store: String, socket: String) -> Result<(), Error> {23 let mut child = Command::new("nix-daemon")24 .arg("--stdio")25 .arg("--store")26 .arg(&store)27 .stdin(Stdio::piped())28 .stdout(Stdio::piped())29 .spawn()30 .map_err(|e| Error::DaemonUnavailable(e.to_string()))?;31 let tunnel = tokio::net::UnixStream::connect(&socket)32 .await33 .map_err(|e| Error::Tunnel(e.to_string()))?;34 let mut stdin = child.stdin.take().expect("piped");35 let mut stdout = child.stdout.take().expect("piped");36 tokio::spawn(async move {37 let mut tunnel = tunnel;38 let (mut tr, mut tw) = tunnel.split();39 let _ = tokio::join!(40 tokio::io::copy(&mut tr, &mut stdin),41 tokio::io::copy(&mut stdout, &mut tw),42 );43 let _ = child.wait().await;44 });45 Ok(())46 }47}