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

difftreelog

refactor drop NixDaemon::connect_daemon

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

4 files changed

modifiedCargo.lockdiffbeforeafterboth
308308
309[[package]]309[[package]]
310name = "bifrostlink"310name = "bifrostlink"
311version = "0.2.5"311version = "0.2.6"
312source = "registry+https://github.com/rust-lang/crates.io-index"312source = "registry+https://github.com/rust-lang/crates.io-index"
313checksum = "910f9286588d13e3dbdbbc1ad4d292656e704bc93e1f41b8a13b48e3a8e95f39"313checksum = "2fb01af731c11dd31b23783a83a36a29f644cc1972481f6fa4f4fabc709079eb"
314dependencies = [314dependencies = [
315 "async-trait",315 "async-trait",
316 "async_fn_traits",316 "async_fn_traits",
327327
328[[package]]328[[package]]
329name = "bifrostlink-macros"329name = "bifrostlink-macros"
330version = "0.2.5"330version = "0.2.6"
331source = "registry+https://github.com/rust-lang/crates.io-index"331source = "registry+https://github.com/rust-lang/crates.io-index"
332checksum = "a0ea5c423c3831c523c8ef78debdf6a64e72b21ec92148a44163a4c25c05dfd0"332checksum = "8c4b7a5fb38b36bd81910c17ebf369f9296e508d92b1277a768a63c8a2254fdb"
333dependencies = [333dependencies = [
334 "proc-macro2",334 "proc-macro2",
335 "quote",335 "quote",
338338
339[[package]]339[[package]]
340name = "bifrostlink-ports"340name = "bifrostlink-ports"
341version = "0.2.5"341version = "0.2.6"
342source = "registry+https://github.com/rust-lang/crates.io-index"342source = "registry+https://github.com/rust-lang/crates.io-index"
343checksum = "9e3a9a01ec1b8bd7d44b47cd0183a1465880e241027d9f5afcb076e11704ec70"343checksum = "977acfcb8ed3c24ab7c2f76fb3eeebff1533c72708733ce6020f2501980b7cf2"
344dependencies = [344dependencies = [
345 "bifrostlink",345 "bifrostlink",
346 "bytes",346 "bytes",
18351835
1836[[package]]1836[[package]]
1837name = "polkit-backend"1837name = "polkit-backend"
1838version = "0.1.6"1838version = "0.1.7"
1839dependencies = [1839dependencies = [
1840 "anyhow",1840 "anyhow",
1841 "clap",1841 "clap",
20552055
2056[[package]]2056[[package]]
2057name = "remowt-agent"2057name = "remowt-agent"
2058version = "0.1.6"2058version = "0.1.7"
2059dependencies = [2059dependencies = [
2060 "anyhow",2060 "anyhow",
2061 "bifrostlink",2061 "bifrostlink",
20832083
2084[[package]]2084[[package]]
2085name = "remowt-client"2085name = "remowt-client"
2086version = "0.1.6"2086version = "0.1.7"
2087dependencies = [2087dependencies = [
2088 "anyhow",2088 "anyhow",
2089 "bifrostlink",2089 "bifrostlink",
21062106
2107[[package]]2107[[package]]
2108name = "remowt-endpoints"2108name = "remowt-endpoints"
2109version = "0.1.6"2109version = "0.1.7"
2110dependencies = [2110dependencies = [
2111 "anyhow",2111 "anyhow",
2112 "bifrostlink",2112 "bifrostlink",
21242124
2125[[package]]2125[[package]]
2126name = "remowt-link-shared"2126name = "remowt-link-shared"
2127version = "0.1.6"2127version = "0.1.7"
2128dependencies = [2128dependencies = [
2129 "bifrostlink",2129 "bifrostlink",
2130 "bytes",2130 "bytes",
21382138
2139[[package]]2139[[package]]
2140name = "remowt-plugin"2140name = "remowt-plugin"
2141version = "0.1.6"2141version = "0.1.7"
2142dependencies = [2142dependencies = [
2143 "anyhow",2143 "anyhow",
2144 "bifrostlink",2144 "bifrostlink",
21522152
2153[[package]]2153[[package]]
2154name = "remowt-polkit-shared"2154name = "remowt-polkit-shared"
2155version = "0.1.6"2155version = "0.1.7"
2156dependencies = [2156dependencies = [
2157 "nix",2157 "nix",
2158 "serde",2158 "serde",
21612161
2162[[package]]2162[[package]]
2163name = "remowt-ssh"2163name = "remowt-ssh"
2164version = "0.1.6"2164version = "0.1.7"
2165dependencies = [2165dependencies = [
2166 "anyhow",2166 "anyhow",
2167 "async-trait",2167 "async-trait",
21892189
2190[[package]]2190[[package]]
2191name = "remowt-ui-prompt"2191name = "remowt-ui-prompt"
2192version = "0.1.6"2192version = "0.1.7"
2193dependencies = [2193dependencies = [
2194 "anyhow",2194 "anyhow",
2195 "bifrostlink",2195 "bifrostlink",
modifiedCargo.tomldiffbeforeafterboth
3resolver = "2"3resolver = "2"
44
5[workspace.package]5[workspace.package]
6version = "0.1.6"6version = "0.1.7"
7license = "MIT"7license = "MIT"
8edition = "2021"8edition = "2021"
9repository = "https://git.delta.rocks/r/remowt"9repository = "https://git.delta.rocks/r/remowt"
1010
11[workspace.dependencies]11[workspace.dependencies]
12remowt-client = { version = "0.1.6", path = "crates/remowt-client" }12remowt-client = { version = "0.1.7", path = "crates/remowt-client" }
13remowt-polkit-shared = { version = "0.1.6", path = "crates/polkit-shared" }13remowt-polkit-shared = { version = "0.1.7", path = "crates/polkit-shared" }
14remowt-link-shared = { version = "0.1.6", path = "crates/remowt-link-shared" }14remowt-link-shared = { version = "0.1.7", path = "crates/remowt-link-shared" }
15remowt-plugin = { version = "0.1.6", path = "crates/remowt-plugin" }15remowt-plugin = { version = "0.1.7", path = "crates/remowt-plugin" }
16remowt-ui-prompt = { version = "0.1.6", path = "crates/remowt-ui-prompt" }16remowt-ui-prompt = { version = "0.1.7", path = "crates/remowt-ui-prompt" }
17remowt-endpoints = { version = "0.1.6", path = "crates/remowt-endpoints" }17remowt-endpoints = { version = "0.1.7", path = "crates/remowt-endpoints" }
1818
19bifrostlink = "0.2.0"19bifrostlink = "0.2.0"
20bifrostlink-macros = "0.2.0"20bifrostlink-macros = "0.2.0"
modifiedcrates/remowt-client/src/lib.rsdiffbeforeafterboth
427 };427 };
428428
429 let (tool, flags) = self.detect_escalation().await?;429 let (tool, flags) = self.detect_escalation().await?;
430 let mut args: Vec<String> = flags.iter().map(|f| (*f).to_owned()).collect();430 let mut args: Vec<String> = Vec::new();
431 args.push("-w".to_owned());
432 args.push(tool.to_owned());
433 args.extend(flags.iter().copied().map(str::to_owned));
431 args.push(agent_path);434 args.push(agent_path);
432 args.push("real-agent".to_owned());435 args.push("real-agent".to_owned());
433 args.push("--privileged".to_owned());436 args.push("--privileged".to_owned());
437440
438 let child = self441 let child = self
439 .spawn(SpawnOptions {442 .spawn(SpawnOptions {
440 program: tool.to_owned(),443 program: "setsid".to_owned(),
441 args,444 args,
442 stdin: StdioMode::Pipe,445 stdin: StdioMode::Pipe,
443 stdout: StdioMode::Pipe,446 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> {