From a77a7cc07b1e4596f5237c78d126ac4169216451 Mon Sep 17 00:00:00 2001 From: David McKinney Date: Fri, 15 Jan 2021 09:01:52 -0500 Subject: [PATCH] Implement the wayland_socket config option for realms --- libcitadel/src/realm/config.rs | 13 +++++++++++-- libcitadel/src/realm/launcher.rs | 8 +++++--- libcitadel/src/realm/manager.rs | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/libcitadel/src/realm/config.rs b/libcitadel/src/realm/config.rs index 91e21d5..71add87 100644 --- a/libcitadel/src/realm/config.rs +++ b/libcitadel/src/realm/config.rs @@ -65,6 +65,9 @@ pub struct RealmConfig { #[serde(rename="use-wayland")] pub use_wayland: Option, + #[serde(rename="wayland-socket")] + pub wayland_socket: Option, + #[serde(rename="use-kvm")] pub use_kvm: Option, @@ -188,6 +191,7 @@ impl RealmConfig { use_sound: Some(true), use_x11: Some(true), use_wayland: Some(true), + wayland_socket: Some("wayland-0".to_string()), use_kvm: Some(false), use_gpu: Some(false), use_gpu_card0: Some(false), @@ -217,6 +221,7 @@ impl RealmConfig { use_sound: None, use_x11: None, use_wayland: None, + wayland_socket: None, use_kvm: None, use_gpu: None, use_gpu_card0: None, @@ -246,8 +251,6 @@ impl RealmConfig { self.bool_value(|c| c.use_kvm) } - - /// If `true` render node device /dev/dri/renderD128 will be added to realm. /// /// This enables hardware graphics acceleration in realm. @@ -319,6 +322,12 @@ impl RealmConfig { self.bool_value(|c| c.use_wayland) } + /// The name of the wayland socket to use if `self.wayland()` is `true` + /// defaults to wayland-0, will appear in the realm as wayland-0 regardless of value + pub fn wayland_socket(&self) -> &str { + self.str_value(|c| c.wayland_socket.as_ref()).unwrap_or("wayland-0") + } + /// If `true` the realm will have access to the network through the zone specified /// by `self.network_zone()` pub fn network(&self) -> bool { diff --git a/libcitadel/src/realm/launcher.rs b/libcitadel/src/realm/launcher.rs index aa09860..1b37721 100644 --- a/libcitadel/src/realm/launcher.rs +++ b/libcitadel/src/realm/launcher.rs @@ -140,7 +140,9 @@ impl <'a> RealmLauncher <'a> { } if config.wayland() { - writeln!(s, "BindReadOnly=/run/user/1000/wayland-0:/run/user/host/wayland-0")?; + // This socket will always be mounted in the realm as wayland-0, regardless of the + // value of wayland_socket() + writeln!(s, "BindReadOnly=/run/user/1000/{}:/run/user/host/wayland-0", config.wayland_socket())?; } for bind in config.extra_bindmounts() { @@ -206,7 +208,6 @@ impl <'a> RealmLauncher <'a> { for dev in &self.devices { writeln!(s, "DeviceAllow={}", dev).unwrap(); } - REALM_SERVICE_TEMPLATE.replace("$REALM_NAME", self.realm.name()) .replace("$ROOTFS", &rootfs) .replace("$NETNS_ARG", &netns_arg) @@ -226,4 +227,5 @@ impl From for crate::Error { fn from(e: fmt::Error) -> Self { format_err!("Error formatting string: {}", e).into() } -} \ No newline at end of file +} + diff --git a/libcitadel/src/realm/manager.rs b/libcitadel/src/realm/manager.rs index 9cf1df5..e60ec6c 100644 --- a/libcitadel/src/realm/manager.rs +++ b/libcitadel/src/realm/manager.rs @@ -91,7 +91,7 @@ impl RealmManager { pub fn launch_terminal(&self, realm: &Realm) -> Result<()> { info!("opening terminal in realm '{}'", realm.name()); let title_arg = format!("Realm: {}", realm.name()); - let args = &["/usr/bin/gnome-terminal".to_owned(), "--title".to_owned(), title_arg]; + let args = &["/usr/bin/x-terminal-emulator".to_owned(), "--title".to_owned(), title_arg]; Systemd::machinectl_shell(realm, args, "user", true, true)?; Ok(()) }