mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-19 02:41:10 +03:00
refact: remove linux headless (#15866)
* refact: remove linux headless Signed-off-by: fufesou <linlong1266@gmail.com> * fix(linux): probe DRM availability asynchronously on login Signed-off-by: fufesou <linlong1266@gmail.com> * revert changes in drm_capturer.rs Signed-off-by: fufesou <linlong1266@gmail.com> * Update submodule hbb_common Signed-off-by: fufesou <linlong1266@gmail.com> * docs(linux): clarify DRM availability comments Remove stale headless and unauthenticated-request wording, and document the Available-only login-screen gate. Signed-off-by: fufesou <linlong1266@gmail.com> * fix(linux): remove unreachable session cleanup branch Remove the obsolete empty-session path and clarify the intended use of cached DRM availability. Signed-off-by: fufesou <linlong1266@gmail.com> --------- Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
@@ -14,7 +14,7 @@ use hbb_common::{
|
||||
allow_err,
|
||||
anyhow::anyhow,
|
||||
bail,
|
||||
config::{keys::OPTION_ALLOW_LINUX_HEADLESS, Config},
|
||||
config::Config,
|
||||
libc::{c_char, c_int, c_long, c_uint, c_ulong, c_void},
|
||||
log,
|
||||
message_proto::{DisplayInfo, Resolution},
|
||||
@@ -235,11 +235,6 @@ pub struct xcb_xfixes_get_cursor_image {
|
||||
pub pixels: *const c_long,
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_headless_allowed() -> bool {
|
||||
Config::get_option(OPTION_ALLOW_LINUX_HEADLESS) == "Y"
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_login_screen_wayland() -> bool {
|
||||
let values = get_values_of_seat0_with_gdm_wayland(&[0, 2]);
|
||||
@@ -863,18 +858,6 @@ fn stop_rustdesk_servers() {
|
||||
));
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn stop_subprocess() {
|
||||
let _ = run_cmds(&format!(
|
||||
r##"ps -ef | grep '/etc/{}/xorg.conf' | grep -v grep | awk '{{print $2}}' | xargs -r kill -9"##,
|
||||
crate::get_app_name().to_lowercase(),
|
||||
));
|
||||
let _ = run_cmds(&format!(
|
||||
r##"ps -ef | grep -E '{} +--cm-no-ui' | grep -v grep | awk '{{print $2}}' | xargs -r kill -9"##,
|
||||
crate::get_app_name().to_lowercase(),
|
||||
));
|
||||
}
|
||||
|
||||
fn should_start_server(
|
||||
try_x11: bool,
|
||||
is_display_changed: bool,
|
||||
@@ -888,13 +871,7 @@ fn should_start_server(
|
||||
let mut start_new = false;
|
||||
let mut should_kill = false;
|
||||
|
||||
if desktop.is_headless() {
|
||||
if !uid.is_empty() {
|
||||
// From having a monitor to not having a monitor.
|
||||
*uid = "".to_owned();
|
||||
should_kill = true;
|
||||
}
|
||||
} else if is_display_changed || desktop.uid != *uid && !desktop.uid.is_empty() {
|
||||
if is_display_changed || desktop.uid != *uid && !desktop.uid.is_empty() {
|
||||
*uid = desktop.uid.clone();
|
||||
if try_x11 {
|
||||
set_x11_env(&desktop);
|
||||
@@ -953,7 +930,6 @@ fn force_stop_server() {
|
||||
pub fn start_os_service() {
|
||||
check_if_stop_service();
|
||||
stop_rustdesk_servers();
|
||||
stop_subprocess();
|
||||
start_uinput_service();
|
||||
|
||||
std::thread::spawn(|| {
|
||||
@@ -1003,8 +979,7 @@ pub fn start_os_service() {
|
||||
desktop.refresh();
|
||||
update_active_user_lookup_cache(&desktop);
|
||||
|
||||
// Duplicate logic here with should_start_server
|
||||
// Login wayland will try to start a headless --server.
|
||||
// Duplicate logic here with should_start_server.
|
||||
if desktop.username == "root" || desktop.is_login_wayland() {
|
||||
// try kill subprocess "--server"
|
||||
stop_server(&mut user_server);
|
||||
@@ -1019,7 +994,6 @@ pub fn start_os_service() {
|
||||
&mut last_restart,
|
||||
&mut server,
|
||||
) {
|
||||
stop_subprocess();
|
||||
force_stop_server();
|
||||
// Run the login-screen --server as the active seat0 session user (the greeter
|
||||
// account) rather than root, so the DRM capture GPU/EGL convert never loads the
|
||||
@@ -1072,7 +1046,6 @@ pub fn start_os_service() {
|
||||
&mut last_restart,
|
||||
&mut user_server,
|
||||
) {
|
||||
stop_subprocess();
|
||||
force_stop_server();
|
||||
start_server(Some(&desktop), &mut user_server);
|
||||
}
|
||||
@@ -1082,17 +1055,14 @@ pub fn start_os_service() {
|
||||
stop_server(&mut server);
|
||||
}
|
||||
|
||||
let keeps_headless = sid.is_empty() && desktop.is_headless();
|
||||
let keeps_session = sid == desktop.sid;
|
||||
if keeps_headless || keeps_session {
|
||||
if keeps_session {
|
||||
// for fixing https://github.com/rustdesk/rustdesk/issues/3129 to avoid too much dbus calling,
|
||||
sleep_millis(500);
|
||||
} else {
|
||||
sleep_millis(super::SERVICE_INTERVAL);
|
||||
}
|
||||
if !desktop.is_headless() {
|
||||
sid = desktop.sid.clone();
|
||||
}
|
||||
sid = desktop.sid.clone();
|
||||
}
|
||||
|
||||
if let Some(ps) = user_server.take().as_mut() {
|
||||
@@ -1249,7 +1219,6 @@ fn is_flatpak() -> bool {
|
||||
std::path::PathBuf::from("/.flatpak-info").exists()
|
||||
}
|
||||
|
||||
// Headless is enabled, always return true.
|
||||
pub fn is_prelogin() -> bool {
|
||||
if is_flatpak() {
|
||||
return false;
|
||||
@@ -1860,7 +1829,6 @@ mod desktop {
|
||||
pub xauth: String,
|
||||
pub home: String,
|
||||
pub dbus: String,
|
||||
pub is_rustdesk_subprocess: bool,
|
||||
pub wl_display: String,
|
||||
}
|
||||
|
||||
@@ -1875,11 +1843,6 @@ mod desktop {
|
||||
super::is_gdm_user(&self.username) && self.protocol == DISPLAY_SERVER_WAYLAND
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_headless(&self) -> bool {
|
||||
self.sid.is_empty() || self.is_rustdesk_subprocess
|
||||
}
|
||||
|
||||
fn get_display_xauth_wayland(&mut self) {
|
||||
for _ in 1..=10 {
|
||||
// Prefer Wayland-related variables first when multiple portal processes match.
|
||||
@@ -2117,25 +2080,11 @@ mod desktop {
|
||||
last
|
||||
}
|
||||
|
||||
fn set_is_subprocess(&mut self) {
|
||||
self.is_rustdesk_subprocess = false;
|
||||
let cmd = format!(
|
||||
"ps -ef | grep '{}/xorg.conf' | grep -v grep | wc -l",
|
||||
crate::get_app_name().to_lowercase()
|
||||
);
|
||||
if let Ok(res) = run_cmds(&cmd) {
|
||||
if res.trim() != "0" {
|
||||
self.is_rustdesk_subprocess = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn refresh(&mut self) {
|
||||
if !self.sid.is_empty() && is_active_and_seat0(&self.sid) {
|
||||
// Xwayland display and xauth may not be available in a short time after login.
|
||||
if is_xwayland_running() && !self.is_login_wayland() {
|
||||
self.get_display_xauth_xwayland();
|
||||
self.is_rustdesk_subprocess = false;
|
||||
} else if self.is_wayland() {
|
||||
self.get_display_xauth_wayland();
|
||||
}
|
||||
@@ -2145,7 +2094,6 @@ mod desktop {
|
||||
let seat0_values = get_values_of_seat0_with_gdm_wayland(&[0, 1, 2]);
|
||||
if seat0_values[0].is_empty() {
|
||||
*self = Self::default();
|
||||
self.is_rustdesk_subprocess = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2156,7 +2104,6 @@ mod desktop {
|
||||
if self.is_login_wayland() {
|
||||
self.display = "".to_owned();
|
||||
self.xauth = "".to_owned();
|
||||
self.is_rustdesk_subprocess = false;
|
||||
// Resolve HOME even on this path. Upstream returned without it because nothing then
|
||||
// consumed a login-Wayland Desktop, but the drm build starts a `--server` as the
|
||||
// greeter uid here, and a child with no HOME has nowhere to put its config. The
|
||||
@@ -2183,11 +2130,9 @@ mod desktop {
|
||||
} else {
|
||||
self.get_display_xauth_wayland();
|
||||
}
|
||||
self.is_rustdesk_subprocess = false;
|
||||
} else {
|
||||
self.get_display_x11();
|
||||
self.get_xauth_x11();
|
||||
self.set_is_subprocess();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user