get values of seat0, do not filter gdm
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
9ef4f4c1de
commit
34c3615320
@ -135,7 +135,7 @@ pub fn get_values_of_seat0_with_gdm_wayland(indices: &[usize]) -> Vec<String> {
|
|||||||
fn _get_values_of_seat0(indices: &[usize], ignore_gdm_wayland: bool) -> Vec<String> {
|
fn _get_values_of_seat0(indices: &[usize], ignore_gdm_wayland: bool) -> Vec<String> {
|
||||||
if let Ok(output) = run_loginctl(None) {
|
if let Ok(output) = run_loginctl(None) {
|
||||||
for line in String::from_utf8_lossy(&output.stdout).lines() {
|
for line in String::from_utf8_lossy(&output.stdout).lines() {
|
||||||
if !line.contains("gdm") && line.contains("seat0") {
|
if line.contains("seat0") {
|
||||||
if let Some(sid) = line.split_whitespace().next() {
|
if let Some(sid) = line.split_whitespace().next() {
|
||||||
if is_active(sid) {
|
if is_active(sid) {
|
||||||
if ignore_gdm_wayland {
|
if ignore_gdm_wayland {
|
||||||
|
@ -56,7 +56,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("show_monitors_tip", "Show monitors in toolbar."),
|
("show_monitors_tip", "Show monitors in toolbar."),
|
||||||
("enter_rustdesk_passwd_tip", "Enter RustDesk password"),
|
("enter_rustdesk_passwd_tip", "Enter RustDesk password"),
|
||||||
("remember_rustdesk_passwd_tip", "Remember RustDesk password"),
|
("remember_rustdesk_passwd_tip", "Remember RustDesk password"),
|
||||||
("login_linux_tip", "Remote desktop is unready. Please \n 1. Login on remote side and then try again\n 2. Or input remote account to login and start a X desktop session"),
|
("login_linux_tip", "You need to login to remote Linux account to enable a X desktop session"),
|
||||||
("verify_rustdesk_password_tip", "Veryfy RustDesk password"),
|
("verify_rustdesk_password_tip", "Veryfy RustDesk password"),
|
||||||
("remember_account_tip", "Remember this account"),
|
("remember_account_tip", "Remember this account"),
|
||||||
("remember_password_tip", "Remember password"),
|
("remember_password_tip", "Remember password"),
|
||||||
|
@ -357,6 +357,7 @@ pub fn start_os_service() {
|
|||||||
&mut last_restart,
|
&mut last_restart,
|
||||||
&mut user_server,
|
&mut user_server,
|
||||||
) {
|
) {
|
||||||
|
stop_xorg_subprocess();
|
||||||
force_stop_server();
|
force_stop_server();
|
||||||
start_server(
|
start_server(
|
||||||
Some((desktop.uid.clone(), desktop.username.clone())),
|
Some((desktop.uid.clone(), desktop.username.clone())),
|
||||||
@ -402,6 +403,12 @@ pub fn get_active_userid() -> String {
|
|||||||
get_values_of_seat0(&[1])[0].clone()
|
get_values_of_seat0(&[1])[0].clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn is_gdm_user(username: &str) -> bool {
|
||||||
|
username == "gdm"
|
||||||
|
// || username == "lightgdm"
|
||||||
|
}
|
||||||
|
|
||||||
fn get_cm() -> bool {
|
fn get_cm() -> bool {
|
||||||
if let Ok(output) = Command::new("ps").args(vec!["aux"]).output() {
|
if let Ok(output) = Command::new("ps").args(vec!["aux"]).output() {
|
||||||
for line in String::from_utf8_lossy(&output.stdout).lines() {
|
for line in String::from_utf8_lossy(&output.stdout).lines() {
|
||||||
@ -800,6 +807,11 @@ mod desktop {
|
|||||||
self.sid.is_empty()
|
self.sid.is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn is_login_wayland(&self) -> bool {
|
||||||
|
super::is_gdm_user(&self.username) && self.protocal == ENV_DESKTOP_PROTOCAL_WAYLAND
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_headless(&self) -> bool {
|
pub fn is_headless(&self) -> bool {
|
||||||
self.sid.is_empty() || self.is_rustdesk_subprocess
|
self.sid.is_empty() || self.is_rustdesk_subprocess
|
||||||
|
@ -23,6 +23,7 @@ lazy_static::lazy_static! {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct DesktopManager {
|
struct DesktopManager {
|
||||||
seat0_username: String,
|
seat0_username: String,
|
||||||
|
seat0_display_server: String,
|
||||||
child_username: String,
|
child_username: String,
|
||||||
child_exit: Arc<AtomicBool>,
|
child_exit: Arc<AtomicBool>,
|
||||||
is_child_running: Arc<AtomicBool>,
|
is_child_running: Arc<AtomicBool>,
|
||||||
@ -61,8 +62,8 @@ pub fn stop_xdesktop() {
|
|||||||
pub fn try_start_x_session(username: &str, password: &str) -> ResultType<(String, bool)> {
|
pub fn try_start_x_session(username: &str, password: &str) -> ResultType<(String, bool)> {
|
||||||
let mut desktop_manager = DESKTOP_MANAGER.lock().unwrap();
|
let mut desktop_manager = DESKTOP_MANAGER.lock().unwrap();
|
||||||
if let Some(desktop_manager) = &mut (*desktop_manager) {
|
if let Some(desktop_manager) = &mut (*desktop_manager) {
|
||||||
if !desktop_manager.seat0_username.is_empty() {
|
if let Some(seat0_username) = desktop_manager.get_supported_display_seat0_username() {
|
||||||
return Ok((desktop_manager.seat0_username.clone(), true));
|
return Ok((seat0_username, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = desktop_manager.try_start_x_session(username, password)?;
|
let _ = desktop_manager.try_start_x_session(username, password)?;
|
||||||
@ -86,14 +87,16 @@ pub fn is_headless() -> bool {
|
|||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |manager| manager.seat0_username.is_empty())
|
.map_or(false, |manager| {
|
||||||
|
manager.get_supported_display_seat0_username().is_none()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_username() -> String {
|
pub fn get_username() -> String {
|
||||||
match &*DESKTOP_MANAGER.lock().unwrap() {
|
match &*DESKTOP_MANAGER.lock().unwrap() {
|
||||||
Some(manager) => {
|
Some(manager) => {
|
||||||
if !manager.seat0_username.is_empty() {
|
if let Some(seat0_username) = manager.get_supported_display_seat0_username() {
|
||||||
manager.seat0_username.clone()
|
seat0_username
|
||||||
} else {
|
} else {
|
||||||
if manager.is_running() && !manager.child_username.is_empty() {
|
if manager.is_running() && !manager.child_username.is_empty() {
|
||||||
manager.child_username.clone()
|
manager.child_username.clone()
|
||||||
@ -119,28 +122,40 @@ impl DesktopManager {
|
|||||||
|
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let mut seat0_username = "".to_owned();
|
let mut seat0_username = "".to_owned();
|
||||||
|
let mut seat0_display_server = "".to_owned();
|
||||||
let seat0_values = get_values_of_seat0(&[0, 1, 2]);
|
let seat0_values = get_values_of_seat0(&[0, 1, 2]);
|
||||||
println!(
|
println!(
|
||||||
"REMOVE ME ================================== DesktopManager: {:?}",
|
"REMOVE ME ================================== DesktopManager: {:?}",
|
||||||
&seat0_values
|
&seat0_values
|
||||||
);
|
);
|
||||||
if !seat0_values[0].is_empty() {
|
if !seat0_values[0].is_empty() {
|
||||||
let display_server = get_display_server_of_session(&seat0_values[1]);
|
|
||||||
if display_server == ENV_DESKTOP_PROTOCAL_X11
|
|
||||||
|| display_server == ENV_DESKTOP_PROTOCAL_WAYLAND
|
|
||||||
{
|
|
||||||
seat0_username = seat0_values[2].clone();
|
seat0_username = seat0_values[2].clone();
|
||||||
}
|
seat0_display_server = get_display_server_of_session(&seat0_values[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
seat0_username,
|
seat0_username,
|
||||||
|
seat0_display_server,
|
||||||
child_username: "".to_owned(),
|
child_username: "".to_owned(),
|
||||||
child_exit: Arc::new(AtomicBool::new(true)),
|
child_exit: Arc::new(AtomicBool::new(true)),
|
||||||
is_child_running: Arc::new(AtomicBool::new(false)),
|
is_child_running: Arc::new(AtomicBool::new(false)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_supported_display_seat0_username(&self) -> Option<String> {
|
||||||
|
if is_gdm_user(&self.seat0_username)
|
||||||
|
&& self.seat0_display_server == ENV_DESKTOP_PROTOCAL_WAYLAND
|
||||||
|
{
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
if self.seat0_username.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(self.seat0_username.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_xauth() -> String {
|
fn get_xauth() -> String {
|
||||||
let xauth = get_env_var("XAUTHORITY");
|
let xauth = get_env_var("XAUTHORITY");
|
||||||
|
Loading…
Reference in New Issue
Block a user