From 540316655229262d80f57e43ca8b6ff2a363e03f Mon Sep 17 00:00:00 2001 From: fufesou Date: Sat, 29 Jul 2023 17:16:53 +0800 Subject: [PATCH] refact, linux headless option, debug Signed-off-by: fufesou --- src/platform/linux.rs | 6 ++++++ src/server/connection.rs | 23 ++++++++++------------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/platform/linux.rs b/src/platform/linux.rs index f553d63ba..86b530342 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -79,6 +79,12 @@ pub fn is_headless_allowed() -> bool { Config::get_option(CONFIG_OPTION_ALLOW_LINUX_HEADLESS) == "Y" } +#[inline] +pub fn is_login_screen_wayland() -> bool { + let values = get_values_of_seat0_with_gdm_wayland(&[0, 2]); + is_gdm_user(&values[1]) && get_display_server_of_session(&values[0]) == DISPLAY_SERVER_WAYLAND +} + #[inline] fn sleep_millis(millis: u64) { std::thread::sleep(Duration::from_millis(millis)); diff --git a/src/server/connection.rs b/src/server/connection.rs index bc101e697..5765e59bd 100644 --- a/src/server/connection.rs +++ b/src/server/connection.rs @@ -1007,21 +1007,18 @@ impl Connection { } #[cfg(target_os = "linux")] if !self.file_transfer.is_some() && !self.port_forward_socket.is_some() { - let mut msg = "".to_owned(); - if crate::platform::linux::is_login_wayland() { - msg = crate::client::LOGIN_SCREEN_WAYLAND.to_owned(); - } else { - let dtype = crate::platform::linux::get_display_server(); - if dtype != crate::platform::linux::DISPLAY_SERVER_X11 - && dtype != crate::platform::linux::DISPLAY_SERVER_WAYLAND - { - msg = format!( + let dtype = crate::platform::linux::get_display_server(); + if dtype != crate::platform::linux::DISPLAY_SERVER_X11 + && dtype != crate::platform::linux::DISPLAY_SERVER_WAYLAND + { + let msg = if crate::platform::linux::is_login_screen_wayland() { + crate::client::LOGIN_SCREEN_WAYLAND.to_owned() + } else { + format!( "Unsupported display server type \"{}\", x11 or wayland expected", dtype - ); - } - } - if !msg.is_empty() { + ) + }; res.set_error(msg); let mut msg_out = Message::new(); msg_out.set_login_response(res);