git.delta.rocks / remowt / refs/commits / 600e6edc0e86

difftreelog

refactor merge well-known endpoints into a single crate

ymvmzxwvYaroslav Bolyukin5 days agoparent: #875f55a.patch.diff
in: trunk

36 files changed

modifiedCargo.lockdiffbeforeafterboth
2065 "futures-util",2065 "futures-util",
2066 "nix",2066 "nix",
2067 "rand 0.10.1",2067 "rand 0.10.1",
2068 "remowt-endpoints",
2068 "remowt-link-shared",2069 "remowt-link-shared",
2069 "remowt-plugin",2070 "remowt-plugin",
2070 "remowt-polkit-shared",2071 "remowt-polkit-shared",
2071 "remowt-pty",
2072 "remowt-ui-prompt",2072 "remowt-ui-prompt",
2073 "serde",2073 "serde",
2074 "tempfile",2074 "tempfile",
2090 "bifrostlink-ports",2090 "bifrostlink-ports",
2091 "bytes",2091 "bytes",
2092 "camino",2092 "camino",
2093 "remowt-endpoints",
2093 "remowt-link-shared",2094 "remowt-link-shared",
2094 "russh",2095 "russh",
2095 "russh-config",2096 "russh-config",
2101]2102]
21022103
2103[[package]]2104[[package]]
2104name = "remowt-fs"2105name = "remowt-endpoints"
2105version = "0.1.1"2106version = "0.1.1"
2106dependencies = [2107dependencies = [
2108 "anyhow",
2107 "bifrostlink",2109 "bifrostlink",
2108 "bifrostlink-macros",2110 "bifrostlink-macros",
2109 "camino",2111 "camino",
2112 "nix",
2110 "serde",2113 "serde",
2111 "tempfile",2114 "tempfile",
2112 "thiserror",2115 "thiserror",
2113 "tokio",2116 "tokio",
2117 "tracing",
2118 "uuid",
2119 "zbus",
2114]2120]
21152121
2116[[package]]2122[[package]]
2120 "bifrostlink",2126 "bifrostlink",
2121 "bytes",2127 "bytes",
2122 "camino",2128 "camino",
2123 "remowt-fs",
2124 "remowt-pty",
2125 "remowt-systemd",
2126 "remowt-ui-prompt",2129 "remowt-ui-prompt",
2127 "serde",2130 "serde",
2128 "serde_json",2131 "serde_json",
2129 "thiserror",2132 "thiserror",
2130 "tokio",2133 "tokio",
2131]2134]
2132
2133[[package]]
2134name = "remowt-nix-daemon"
2135version = "0.1.1"
2136dependencies = [
2137 "anyhow",
2138 "bifrostlink",
2139 "bifrostlink-macros",
2140 "camino",
2141 "remowt-client",
2142 "serde",
2143 "thiserror",
2144 "tokio",
2145 "tracing",
2146 "uuid",
2147]
21482135
2149[[package]]2136[[package]]
2150name = "remowt-plugin"2137name = "remowt-plugin"
2170 "zbus",2157 "zbus",
2171]2158]
2172
2173[[package]]
2174name = "remowt-pty"
2175version = "0.1.1"
2176dependencies = [
2177 "bifrostlink",
2178 "bifrostlink-macros",
2179 "camino",
2180 "nix",
2181 "serde",
2182 "thiserror",
2183 "tokio",
2184 "tracing",
2185]
21862159
2187[[package]]2160[[package]]
2188name = "remowt-ssh"2161name = "remowt-ssh"
2212 "uuid",2185 "uuid",
2213]2186]
2214
2215[[package]]
2216name = "remowt-systemd"
2217version = "0.1.1"
2218dependencies = [
2219 "bifrostlink",
2220 "bifrostlink-macros",
2221 "serde",
2222 "thiserror",
2223 "zbus",
2224]
22252187
2226[[package]]2188[[package]]
2227name = "remowt-ui-prompt"2189name = "remowt-ui-prompt"
modifiedCargo.tomldiffbeforeafterboth
9repository = "https://gitlab.delta.directory/iam/remowt"9repository = "https://gitlab.delta.directory/iam/remowt"
1010
11[workspace.dependencies]11[workspace.dependencies]
12remowt-fs = { version = "0.1.1", path = "crates/remowt-fs" }
13remowt-pty = { version = "0.1.1", path = "crates/remowt-pty" }
14remowt-systemd = { version = "0.1.1", path = "crates/remowt-systemd" }
15remowt-client = { version = "0.1.1", path = "crates/remowt-client" }12remowt-client = { version = "0.1.1", path = "crates/remowt-client" }
16remowt-polkit-shared = { version = "0.1.1", path = "crates/polkit-shared" }13remowt-polkit-shared = { version = "0.1.1", path = "crates/polkit-shared" }
17remowt-link-shared = { version = "0.1.1", path = "crates/remowt-link-shared" }14remowt-link-shared = { version = "0.1.1", path = "crates/remowt-link-shared" }
18remowt-plugin = { version = "0.1.1", path = "crates/remowt-plugin" }15remowt-plugin = { version = "0.1.1", path = "crates/remowt-plugin" }
19remowt-ui-prompt = { version = "0.1.1", path = "crates/ui-prompt" }16remowt-ui-prompt = { version = "0.1.1", path = "crates/remowt-ui-prompt" }
17remowt-endpoints = { version = "0.1.1", path = "crates/remowt-endpoints" }
2018
21bifrostlink = "0.2.0"19bifrostlink = "0.2.0"
22bifrostlink-macros = "0.2.0"20bifrostlink-macros = "0.2.0"
modifiedcmds/polkit-dbus-helper/src/main.rsdiffbeforeafterboth
8use nix::unistd::{setuid, Uid, User};8use nix::unistd::{setuid, Uid, User};
9use pam_client::{Context, ConversationHandler, ErrorCode, Flag};9use pam_client::{Context, ConversationHandler, ErrorCode, Flag};
10use remowt_polkit_shared::BackendRequest;10use remowt_polkit_shared::BackendRequest;
11use tokio::task::{block_in_place, spawn_blocking};11use remowt_ui_prompt::dbus::DbusPrompterProxyBlocking;
12use tracing::trace;12use remowt_ui_prompt::BlockingPrompter;
13use remowt_ui_prompt::dbus::DbusPrompterProxyBlocking;13use tokio::task::{block_in_place, spawn_blocking};
14use remowt_ui_prompt::BlockingPrompter;14use tracing::trace;
15use zbus::fdo;15use zbus::fdo;
16use zbus::message::Header;16use zbus::message::Header;
17use zbus::zvariant::OwnedValue;17use zbus::zvariant::OwnedValue;
modifiedcmds/remowt-agent/Cargo.tomldiffbeforeafterboth
17rand.workspace = true17rand.workspace = true
18remowt-link-shared.workspace = true18remowt-link-shared.workspace = true
19remowt-plugin.workspace = true19remowt-plugin.workspace = true
20remowt-pty.workspace = true
21serde = { workspace = true, features = ["derive"] }20serde = { workspace = true, features = ["derive"] }
22tempfile.workspace = true21tempfile.workspace = true
23tokio = { workspace = true, features = [22tokio = { workspace = true, features = [
36uuid = { workspace = true, features = ["v4"] }35uuid = { workspace = true, features = ["v4"] }
37zbus = { workspace = true, features = ["tokio"] }36zbus = { workspace = true, features = ["tokio"] }
38zbus_polkit = { workspace = true, features = ["tokio"] }37zbus_polkit = { workspace = true, features = ["tokio"] }
38remowt-endpoints.workspace = true
3939
modifiedcmds/remowt-agent/src/helper/protocol.rsdiffbeforeafterboth
3use anyhow::bail;3use anyhow::bail;
4use futures::stream::Peekable;4use futures::stream::Peekable;
5use futures::StreamExt as _;5use futures::StreamExt as _;
6use remowt_ui_prompt::Prompter;
6use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt as _};7use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt as _};
7use tokio::select;8use tokio::select;
8use tokio_util::codec::{FramedRead, LinesCodec};9use tokio_util::codec::{FramedRead, LinesCodec};
9use remowt_ui_prompt::Prompter;
1010
11pub async fn run_conversation<R, W, P>(reader: R, mut writer: W, prompt: P) -> anyhow::Result<()>11pub async fn run_conversation<R, W, P>(reader: R, mut writer: W, prompt: P) -> anyhow::Result<()>
12where12where
modifiedcmds/remowt-agent/src/main.rsdiffbeforeafterboth
11use bifrostlink_ports::stdio::from_stdio;11use bifrostlink_ports::stdio::from_stdio;
12use bifrostlink_ports::unix_socket::from_socket;12use bifrostlink_ports::unix_socket::from_socket;
13use clap::Parser;13use clap::Parser;
14use remowt_link_shared::editor::EditorEndpointsClient;14use remowt_endpoints::{fs::Fs, pty::Pty, systemd::Systemd};
15use remowt_link_shared::{Address, BifConfig, Fs, Pty, Systemd};15use remowt_link_shared::{editor::EditorEndpointsClient, Address, BifConfig};
16use remowt_polkit_shared::{emphasize, BackendRequest, Identity, PidDisplay};16use remowt_polkit_shared::{emphasize, BackendRequest, Identity, PidDisplay};
17use remowt_ui_prompt::bifrost::PromptEndpointsClient;17use remowt_ui_prompt::bifrost::PromptEndpointsClient;
18use remowt_ui_prompt::rofi::RofiPrompter;18use remowt_ui_prompt::rofi::RofiPrompter;
modifiedcmds/remowt-ssh/src/main.rsdiffbeforeafterboth
13use remowt_client::editor::SshEditor;13use remowt_client::editor::SshEditor;
14use remowt_client::{AgentBundle, Remowt};14use remowt_client::{AgentBundle, Remowt};
15use remowt_link_shared::editor::serve_editor;15use remowt_link_shared::editor::serve_editor;
16use remowt_ui_prompt::bifrost::serve_prompts;
17use remowt_ui_prompt::rofi::RofiPrompter;
18use remowt_ui_prompt::{PrependSourcePrompter, Source};
16use tokio::io::unix::AsyncFd;19use tokio::io::unix::AsyncFd;
17use tokio::io::{AsyncRead, ReadBuf};20use tokio::io::{AsyncRead, ReadBuf};
18use tokio::signal::unix::{signal, SignalKind};21use tokio::signal::unix::{signal, SignalKind};
19use tracing::info;22use tracing::info;
20use remowt_ui_prompt::bifrost::serve_prompts;
21use remowt_ui_prompt::rofi::RofiPrompter;
22use remowt_ui_prompt::{PrependSourcePrompter, Source};
2323
24#[derive(Parser)]24#[derive(Parser)]
25struct Opts {25struct Opts {
modifiedcrates/remowt-client/Cargo.tomldiffbeforeafterboth
19tokio = { workspace = true, features = ["net", "io-util", "rt", "sync", "macros", "process"] }19tokio = { workspace = true, features = ["net", "io-util", "rt", "sync", "macros", "process"] }
20tracing.workspace = true20tracing.workspace = true
21uuid = { workspace = true, features = ["v4"] }21uuid = { workspace = true, features = ["v4"] }
22remowt-endpoints.workspace = true
2223
modifiedcrates/remowt-client/src/lib.rsdiffbeforeafterboth
1use std::collections::HashMap;1use std::collections::HashMap;
2use std::io;
3use std::path::PathBuf;2use std::path::PathBuf;
4use std::sync::{Arc, Mutex};3use std::sync::{Arc, Mutex};
4use std::{env, io};
55
6use anyhow::{anyhow, bail, ensure, Context as _, Result};6use anyhow::{anyhow, bail, ensure, Context as _, Result};
7use bifrostlink::declarative::RemoteEndpoints;7use bifrostlink::declarative::RemoteEndpoints;
8use bifrostlink::{Port, Remote, Rpc, Rtt, WeakRpc};8use bifrostlink::{Port, Remote, Rpc, Rtt, WeakRpc};
9use bifrostlink_ports::unix_socket::from_socket;9use bifrostlink_ports::unix_socket::from_socket;
10use bytes::{Bytes, BytesMut};10use bytes::{Bytes, BytesMut};
11use camino::{Utf8Path, Utf8PathBuf};11use camino::{Utf8Path, Utf8PathBuf};
12use remowt_endpoints::{
13 fs::Fs,
14 pty::{Pty, PtyClient, ShellId},
15 systemd::Systemd,
16};
12use remowt_link_shared::plugin::PluginEndpointsClient;17use remowt_link_shared::plugin::PluginEndpointsClient;
13use remowt_link_shared::{18use remowt_link_shared::{Address, BifConfig, ElevateEndpoints, ElevateError, Elevator};
14 Address, BifConfig, ElevateEndpoints, ElevateError, Elevator, Fs, Pty, PtyClient, ShellId,
15 Systemd,
16};
17use russh::client::{connect, Config, Handle, Handler, Msg, Session};19use russh::client::{connect, Config, Handle, Handler, Msg, Session};
18use russh::keys::agent::client::AgentClient;20use russh::keys::agent::client::AgentClient;
220}222}
221223
222fn find_in_path(name: &str) -> Option<std::path::PathBuf> {224fn find_in_path(name: &str) -> Option<std::path::PathBuf> {
223 let path = std::env::var_os("PATH")?;225 let path = env::var_os("PATH")?;
224 std::env::split_paths(&path)226 env::split_paths(&path)
225 .map(|dir| dir.join(name))227 .map(|dir| dir.join(name))
226 .find(|p| p.is_file())228 .find(|p| p.is_file())
227}229}
383impl Remowt {385impl Remowt {
384 pub async fn connect(host: &str, bundle: &AgentBundle) -> Result<Self> {386 pub async fn connect(host: &str, bundle: &AgentBundle) -> Result<Self> {
385 let conf = russh_config::parse_home(host)?;387 let conf = russh_config::parse_home(host)?;
386 let port = conf.host_config.port.unwrap_or(22);388 let port = conf.host_config.port.or(conf.port).unwrap_or(22);
387 let hostname = conf389 let hostname = conf
388 .host_config390 .host_config
389 .hostname391 .hostname
392 let user = conf394 let user = conf
393 .user395 .user
394 .clone()396 .clone()
395 .unwrap_or_else(|| std::env::var("USER").unwrap_or_else(|_| "root".to_owned()));397 .unwrap_or_else(|| env::var("USER").unwrap_or_else(|_| "root".to_owned()));
396398
397 let subs: Subs = Arc::new(Mutex::new(HashMap::new()));399 let subs: Subs = Arc::new(Mutex::new(HashMap::new()));
398 let mut sess = connect(400 let mut sess = connect(
548 port_from_channel(ch)550 port_from_channel(ch)
549 }551 }
550 Transport::Local { agent_path, .. } => {552 Transport::Local { agent_path, .. } => {
551 let sock = std::env::temp_dir()553 let sock = env::temp_dir()
552 .join(format!("remowt-priv-{}.sock", uuid::Uuid::new_v4()));554 .join(format!("remowt-priv-{}.sock", uuid::Uuid::new_v4()));
553 let _ = std::fs::remove_file(&sock);555 let _ = std::fs::remove_file(&sock);
554 let listener = UnixListener::bind(&sock)?;556 let listener = UnixListener::bind(&sock)?;
addedcrates/remowt-endpoints/Cargo.tomldiffbeforeafterboth

no changes

addedcrates/remowt-endpoints/src/fs.rsdiffbeforeafterboth

no changes

addedcrates/remowt-endpoints/src/lib.rsdiffbeforeafterboth

no changes

addedcrates/remowt-endpoints/src/nix_daemon.rsdiffbeforeafterboth

no changes

addedcrates/remowt-endpoints/src/pty.rsdiffbeforeafterboth

no changes

addedcrates/remowt-endpoints/src/systemd.rsdiffbeforeafterboth

no changes

deletedcrates/remowt-fs/Cargo.tomldiffbeforeafterboth

no changes

deletedcrates/remowt-fs/src/lib.rsdiffbeforeafterboth

no changes

modifiedcrates/remowt-link-shared/Cargo.tomldiffbeforeafterboth
12serde_json.workspace = true12serde_json.workspace = true
13thiserror.workspace = true13thiserror.workspace = true
14tokio = { workspace = true, features = ["fs"] }14tokio = { workspace = true, features = ["fs"] }
15remowt-fs.workspace = true
16remowt-systemd.workspace = true
17remowt-ui-prompt.workspace = true15remowt-ui-prompt.workspace = true
18camino = { workspace = true, features = ["serde1"] }16camino = { workspace = true, features = ["serde1"] }
19remowt-pty.workspace = true
2017
modifiedcrates/remowt-link-shared/src/lib.rsdiffbeforeafterboth
2121
22pub mod plugin;22pub mod plugin;
23
24pub use remowt_fs::{Error as FsError, Fs, FsClient};
25pub use remowt_pty::{Error as PtyError, Pty, PtyClient, ShellId};
26pub use remowt_systemd::{Error as SystemdError, Systemd, SystemdClient};
2723
28#[derive(Serialize, Deserialize, Debug, thiserror::Error)]24#[derive(Serialize, Deserialize, Debug, thiserror::Error)]
29pub enum ElevateError {25pub enum ElevateError {
deletedcrates/remowt-nix-daemon/Cargo.tomldiffbeforeafterboth

no changes

deletedcrates/remowt-nix-daemon/src/lib.rsdiffbeforeafterboth

no changes

modifiedcrates/remowt-plugin/src/lib.rsdiffbeforeafterboth
8pub mod host;8pub mod host;
99
10pub use bifrostlink;10pub use bifrostlink;
11pub use remowt_link_shared::{self, Address, BifConfig, Fs, Pty, Systemd};11pub use remowt_link_shared::{self, Address, BifConfig};
1212
13pub fn plugin_index() -> Result<u16> {13pub fn plugin_index() -> Result<u16> {
14 let arg = std::env::args()14 let arg = std::env::args()
deletedcrates/remowt-pty/Cargo.tomldiffbeforeafterboth

no changes

deletedcrates/remowt-pty/src/lib.rsdiffbeforeafterboth

no changes

deletedcrates/remowt-systemd/Cargo.tomldiffbeforeafterboth

no changes

deletedcrates/remowt-systemd/src/lib.rsdiffbeforeafterboth

no changes

addedcrates/remowt-ui-prompt/Cargo.tomldiffbeforeafterboth

no changes

addedcrates/remowt-ui-prompt/src/bifrost.rsdiffbeforeafterboth

no changes

addedcrates/remowt-ui-prompt/src/dbus.rsdiffbeforeafterboth

no changes

addedcrates/remowt-ui-prompt/src/lib.rsdiffbeforeafterboth

no changes

addedcrates/remowt-ui-prompt/src/rofi.rsdiffbeforeafterboth

no changes

deletedcrates/ui-prompt/Cargo.tomldiffbeforeafterboth

no changes

deletedcrates/ui-prompt/src/bifrost.rsdiffbeforeafterboth

no changes

deletedcrates/ui-prompt/src/dbus.rsdiffbeforeafterboth

no changes

deletedcrates/ui-prompt/src/lib.rsdiffbeforeafterboth

no changes

deletedcrates/ui-prompt/src/rofi.rsdiffbeforeafterboth

no changes