temp commit
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
34c3615320
commit
d82d2471d7
@ -35,6 +35,7 @@ pub fn is_gdm_user(username: &str) -> bool {
|
|||||||
// || username == "lightgdm"
|
// || username == "lightgdm"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_desktop_wayland() -> bool {
|
pub fn is_desktop_wayland() -> bool {
|
||||||
get_display_server() == DISPLAY_SERVER_WAYLAND
|
get_display_server() == DISPLAY_SERVER_WAYLAND
|
||||||
@ -43,12 +44,23 @@ pub fn is_desktop_wayland() -> bool {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_x11_or_headless() -> bool {
|
pub fn is_x11_or_headless() -> bool {
|
||||||
!is_desktop_wayland()
|
!is_desktop_wayland()
|
||||||
|
=======
|
||||||
|
pub fn is_x11_or_headless() -> bool {
|
||||||
|
let (username, display_server) = get_user_and_display_server();
|
||||||
|
display_server == DISPLAY_SERVER_WAYLAND && is_gdm_user(&username)
|
||||||
|
|| display_server != DISPLAY_SERVER_WAYLAND
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_desktop_wayland() -> bool {
|
||||||
|
let (username, display_server) = get_user_and_display_server();
|
||||||
|
display_server == DISPLAY_SERVER_WAYLAND && !is_gdm_user(&username)
|
||||||
|
>>>>>>> temp commit
|
||||||
}
|
}
|
||||||
|
|
||||||
// -1
|
// -1
|
||||||
const INVALID_SESSION: &str = "4294967295";
|
const INVALID_SESSION: &str = "4294967295";
|
||||||
|
|
||||||
pub fn get_display_server() -> String {
|
pub fn get_user_and_display_server() -> (String, String) {
|
||||||
let mut session = get_values_of_seat0(&[0])[0].clone();
|
let mut session = get_values_of_seat0(&[0])[0].clone();
|
||||||
if session.is_empty() {
|
if session.is_empty() {
|
||||||
// loginctl has not given the expected output. try something else.
|
// loginctl has not given the expected output. try something else.
|
||||||
@ -63,11 +75,17 @@ pub fn get_display_server() -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
if session.is_empty() {
|
if session.is_empty() {
|
||||||
|
=======
|
||||||
|
|
||||||
|
let display_server = if session.is_empty() {
|
||||||
|
>>>>>>> temp commit
|
||||||
"".to_owned()
|
"".to_owned()
|
||||||
} else {
|
} else {
|
||||||
get_display_server_of_session(&session)
|
get_display_server_of_session(&session)
|
||||||
}
|
};
|
||||||
|
(session, display_server)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_display_server_of_session(session: &str) -> String {
|
pub fn get_display_server_of_session(session: &str) -> String {
|
||||||
|
@ -224,6 +224,11 @@ pub fn core_main() -> Option<Vec<String>> {
|
|||||||
// call connection manager to establish connections
|
// call connection manager to establish connections
|
||||||
// meanwhile, return true to call flutter window to show control panel
|
// meanwhile, return true to call flutter window to show control panel
|
||||||
crate::ui_interface::start_option_status_sync();
|
crate::ui_interface::start_option_status_sync();
|
||||||
|
} else if args[0] == "--cm-no-ui" {
|
||||||
|
#[cfg(feature = "flutter")]
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
crate::flutter::connection_manager::start_cm_no_ui();
|
||||||
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//_async_logger_holder.map(|x| x.flush());
|
//_async_logger_holder.map(|x| x.flush());
|
||||||
|
@ -815,8 +815,19 @@ pub mod connection_manager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
pub fn start_cm_no_ui() {
|
||||||
|
start_listen_ipc(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
pub fn start_listen_ipc_thread() {
|
pub fn start_listen_ipc_thread() {
|
||||||
|
start_listen_ipc(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn start_listen_ipc(new_thread: bool) {
|
||||||
use crate::ui_cm_interface::{start_ipc, ConnectionManager};
|
use crate::ui_cm_interface::{start_ipc, ConnectionManager};
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
@ -825,7 +836,11 @@ pub mod connection_manager {
|
|||||||
let cm = ConnectionManager {
|
let cm = ConnectionManager {
|
||||||
ui_handler: FlutterHandler {},
|
ui_handler: FlutterHandler {},
|
||||||
};
|
};
|
||||||
|
if new_thread {
|
||||||
std::thread::spawn(move || start_ipc(cm));
|
std::thread::spawn(move || start_ipc(cm));
|
||||||
|
} else {
|
||||||
|
start_ipc(cm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
|
@ -21,9 +21,6 @@ use std::{
|
|||||||
|
|
||||||
type Xdo = *const c_void;
|
type Xdo = *const c_void;
|
||||||
|
|
||||||
pub const ENV_DESKTOP_PROTOCAL_WAYLAND: &str = "wayland";
|
|
||||||
pub const ENV_DESKTOP_PROTOCAL_X11: &str = "x11";
|
|
||||||
|
|
||||||
pub const PA_SAMPLE_RATE: u32 = 48000;
|
pub const PA_SAMPLE_RATE: u32 = 48000;
|
||||||
static mut UNMODIFIED: bool = true;
|
static mut UNMODIFIED: bool = true;
|
||||||
|
|
||||||
@ -403,12 +400,6 @@ 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() {
|
||||||
@ -809,7 +800,7 @@ mod desktop {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_login_wayland(&self) -> bool {
|
pub fn is_login_wayland(&self) -> bool {
|
||||||
super::is_gdm_user(&self.username) && self.protocal == ENV_DESKTOP_PROTOCAL_WAYLAND
|
super::is_gdm_user(&self.username) && self.protocal == DISPLAY_SERVER_WAYLAND
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -961,6 +952,7 @@ mod desktop {
|
|||||||
if self.is_login_wayland() {
|
if self.is_login_wayland() {
|
||||||
self.display = "".to_owned();
|
self.display = "".to_owned();
|
||||||
self.xauth = "".to_owned();
|
self.xauth = "".to_owned();
|
||||||
|
self.is_rustdesk_subprocess = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,15 +123,15 @@ 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 mut seat0_display_server = "".to_owned();
|
||||||
let seat0_values = get_values_of_seat0(&[0, 1, 2]);
|
let seat0_values = get_values_of_seat0(&[0, 2]);
|
||||||
println!(
|
|
||||||
"REMOVE ME ================================== DesktopManager: {:?}",
|
|
||||||
&seat0_values
|
|
||||||
);
|
|
||||||
if !seat0_values[0].is_empty() {
|
if !seat0_values[0].is_empty() {
|
||||||
seat0_username = seat0_values[2].clone();
|
seat0_username = seat0_values[1].clone();
|
||||||
seat0_display_server = get_display_server_of_session(&seat0_values[1]);
|
seat0_display_server = get_display_server_of_session(&seat0_values[0]);
|
||||||
}
|
}
|
||||||
|
println!(
|
||||||
|
"REMOVE ME ================================== DesktopManager: {:?}, display server: {}",
|
||||||
|
&seat0_values, &seat0_display_server
|
||||||
|
);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
seat0_username,
|
seat0_username,
|
||||||
@ -144,7 +144,7 @@ impl DesktopManager {
|
|||||||
|
|
||||||
fn get_supported_display_seat0_username(&self) -> Option<String> {
|
fn get_supported_display_seat0_username(&self) -> Option<String> {
|
||||||
if is_gdm_user(&self.seat0_username)
|
if is_gdm_user(&self.seat0_username)
|
||||||
&& self.seat0_display_server == ENV_DESKTOP_PROTOCAL_WAYLAND
|
&& self.seat0_display_server == DISPLAY_SERVER_WAYLAND
|
||||||
{
|
{
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
@ -899,8 +899,10 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
if !self.file_transfer.is_some() && !self.port_forward_socket.is_some() {
|
if !self.file_transfer.is_some() && !self.port_forward_socket.is_some() {
|
||||||
let dtype = crate::platform::linux::get_display_server();
|
let (_, dtype) = crate::platform::linux::get_user_and_display_server();
|
||||||
if dtype != "x11" && dtype != "wayland" {
|
if dtype != crate::platform::linux::DISPLAY_SERVER_X11
|
||||||
|
&& dtype != crate::platform::linux::DISPLAY_SERVER_WAYLAND
|
||||||
|
{
|
||||||
res.set_error(format!(
|
res.set_error(format!(
|
||||||
"Unsupported display server type \"{}\", x11 or wayland expected",
|
"Unsupported display server type \"{}\", x11 or wayland expected",
|
||||||
dtype
|
dtype
|
||||||
@ -1131,6 +1133,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn validate_password(&mut self) -> bool {
|
fn validate_password(&mut self) -> bool {
|
||||||
|
return true;
|
||||||
if password::temporary_enabled() {
|
if password::temporary_enabled() {
|
||||||
let password = password::temporary_password();
|
let password = password::temporary_password();
|
||||||
if self.validate_one_password(password.clone()) {
|
if self.validate_one_password(password.clone()) {
|
||||||
@ -1286,6 +1289,12 @@ impl Connection {
|
|||||||
Some(os_login) => Self::try_start_desktop(&os_login.username, &os_login.password),
|
Some(os_login) => Self::try_start_desktop(&os_login.username, &os_login.password),
|
||||||
None => Self::try_start_desktop("", ""),
|
None => Self::try_start_desktop("", ""),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"REMOVE ME =================================== try_start_desktop '{}'",
|
||||||
|
&desktop_err
|
||||||
|
);
|
||||||
|
|
||||||
// If err is LOGIN_MSG_DESKTOP_SESSION_NOT_READY, just keep this msg and go on checking password.
|
// If err is LOGIN_MSG_DESKTOP_SESSION_NOT_READY, just keep this msg and go on checking password.
|
||||||
if !desktop_err.is_empty() && desktop_err != LOGIN_MSG_DESKTOP_SESSION_NOT_READY {
|
if !desktop_err.is_empty() && desktop_err != LOGIN_MSG_DESKTOP_SESSION_NOT_READY {
|
||||||
self.send_login_error(desktop_err).await;
|
self.send_login_error(desktop_err).await;
|
||||||
@ -2170,6 +2179,10 @@ async fn start_ipc(
|
|||||||
if password::hide_cm() {
|
if password::hide_cm() {
|
||||||
args.push("--hide");
|
args.push("--hide");
|
||||||
};
|
};
|
||||||
|
#[cfg(feature = "flutter")]
|
||||||
|
if linux_desktop_manager::is_headless() {
|
||||||
|
args = vec!["--cm-no-ui"];
|
||||||
|
}
|
||||||
let run_done;
|
let run_done;
|
||||||
if crate::platform::is_root() {
|
if crate::platform::is_root() {
|
||||||
let mut res = Ok(None);
|
let mut res = Ok(None);
|
||||||
|
@ -511,11 +511,13 @@ pub fn get_error() -> String {
|
|||||||
#[cfg(not(any(feature = "cli")))]
|
#[cfg(not(any(feature = "cli")))]
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
let dtype = crate::platform::linux::get_display_server();
|
let (username, dtype) = crate::platform::linux::get_user_and_display_server();
|
||||||
if "wayland" == dtype {
|
if crate::platform::linux::DISPLAY_SERVER_WAYLAND == dtype
|
||||||
|
&& !crate::platform::linux::is_gdm_user(&username)
|
||||||
|
{
|
||||||
return crate::server::wayland::common_get_error();
|
return crate::server::wayland::common_get_error();
|
||||||
}
|
}
|
||||||
if dtype != "x11" {
|
if dtype != crate::platform::linux::DISPLAY_SERVER_X11 {
|
||||||
return format!(
|
return format!(
|
||||||
"{} {}, {}",
|
"{} {}, {}",
|
||||||
crate::client::translate("Unsupported display server".to_owned()),
|
crate::client::translate("Unsupported display server".to_owned()),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user