virtual display, linux, debug

Signed-off-by: qcloud <ubuntu@localhost.localdomain>
This commit is contained in:
qcloud 2023-03-29 17:39:16 +08:00 committed by fufesou
parent 6149c7f477
commit b82207f20b
4 changed files with 31 additions and 69 deletions

View File

@ -57,6 +57,6 @@ where
{
unsafe {
GLOBAL_CALLBACK = Some(Box::new(callback));
libc::signal(libc::SIGSEGV, breakdown_signal_handler as _);
// libc::signal(libc::SIGSEGV, breakdown_signal_handler as _);
}
}

View File

@ -225,6 +225,13 @@ fn stop_rustdesk_servers() {
));
}
#[inline]
fn stop_xorg_subprocess() {
let _ = run_cmds(format!(
r##"ps -ef | grep '/etc/rustdesk/xorg.conf' | grep -v grep | awk '{{printf("kill -9 %d\n", $2)}}' | bash"##,
));
}
fn should_start_server(
try_x11: bool,
uid: &mut String,
@ -295,6 +302,7 @@ fn force_stop_server() {
pub fn start_os_service() {
stop_rustdesk_servers();
stop_xorg_subprocess();
start_uinput_service();
let running = Arc::new(AtomicBool::new(true));
@ -329,6 +337,7 @@ pub fn start_os_service() {
&mut last_restart,
&mut server,
) {
stop_xorg_subprocess();
force_stop_server();
start_server(None, &mut server);
}
@ -921,7 +930,6 @@ mod desktop {
if !self.sid.is_empty() && is_active(&self.sid) {
return;
}
let seat0_values = get_values_of_seat0(&[0, 1, 2]);
if seat0_values[0].is_empty() {
*self = Self::default();
@ -942,8 +950,6 @@ mod desktop {
self.get_display();
self.get_xauth();
self.set_is_subprocess();
println!("REMOVE ME ======================================= desktop: {:?}", self);
}
}
}

View File

@ -111,6 +111,7 @@ impl DesktopManager {
pub fn new() -> Self {
let mut x11_username = "".to_owned();
let seat0_values = get_values_of_seat0(&[0, 1, 2]);
println!("REMOVE ME ======================== DesktopManager seato values {:?}", &seat0_values);
if !seat0_values[0].is_empty() {
if "x11" == get_display_server_of_session(&seat0_values[1]) {
x11_username = seat0_values[2].clone();
@ -608,7 +609,7 @@ impl DesktopManager {
//"-logfile",
//"/tmp/RustDesk_xorg.log",
"-config",
"rustdesk/xorg.conf",
"/etc/rustdesk/xorg.conf",
"-auth",
xauth,
display,

View File

@ -1075,6 +1075,7 @@ impl Connection {
#[cfg(target_os = "linux")]
if _username.is_empty() {
let username = crate::platform::linux_desktop_manager::get_username();
println!("REMOVE ME ===================================== try_start_desktop username '{}'", &username);
if username.is_empty() {
LOGIN_MSG_XSESSION_NOT_READY
} else {
@ -1274,6 +1275,7 @@ impl Connection {
Some(os_login) => Self::try_start_desktop(&os_login.username, &os_login.password),
None => Self::try_start_desktop("", ""),
};
// If err is LOGIN_MSG_XSESSION_NOT_READY, just keep this msg and go on checking password.
if !desktop_err.is_empty() && desktop_err != LOGIN_MSG_XSESSION_NOT_READY {
self.send_login_error(desktop_err).await;
return true;
@ -1302,73 +1304,26 @@ impl Connection {
self.send_login_error("Connection not allowed").await;
return false;
} else if self.is_recent_session() {
self.try_start_cm(lr.my_id, lr.my_name, true);
self.send_logon_response().await;
if self.port_forward_socket.is_some() {
return false;
}
} else if lr.password.is_empty() {
self.try_start_cm(lr.my_id, lr.my_name, false);
} else {
let mut failure = LOGIN_FAILURES
.lock()
.unwrap()
.get(&self.ip)
.map(|x| x.clone())
.unwrap_or((0, 0, 0));
let time = (get_time() / 60_000) as i32;
if failure.2 > 30 {
self.send_login_error("Too many wrong password attempts")
.await;
Self::post_alarm_audit(
AlarmAuditType::ManyWrongPassword,
true,
json!({
"ip":self.ip,
}),
);
} else if time == failure.0 && failure.1 > 6 {
self.send_login_error("Please try 1 minute later").await;
Self::post_alarm_audit(
AlarmAuditType::FrequentAttempt,
true,
json!({
"ip":self.ip,
}),
);
} else if !self.validate_password() {
if failure.0 == time {
failure.1 += 1;
failure.2 += 1;
} else {
failure.0 = time;
failure.1 = 1;
failure.2 += 1;
}
LOGIN_FAILURES
.lock()
.unwrap()
.insert(self.ip.clone(), failure);
if desktop_err.is_empty() {
self.send_login_error(LOGIN_MSG_PASSWORD_WRONG).await;
self.try_start_cm(lr.my_id, lr.my_name, false);
} else {
self.send_login_error(LOGIN_MSG_XSESSION_NOT_READY_PASSWORD_WRONG)
.await;
if desktop_err.is_empty() {
self.try_start_cm(lr.my_id, lr.my_name, true);
self.send_logon_response().await;
if self.port_forward_socket.is_some() {
return false;
}
} else {
if failure.0 != 0 {
LOGIN_FAILURES.lock().unwrap().remove(&self.ip);
}
if desktop_err.is_empty() {
self.send_logon_response().await;
self.try_start_cm(lr.my_id, lr.my_name, true);
if self.port_forward_socket.is_some() {
return false;
}
} else {
self.send_login_error(desktop_err).await;
self.send_login_error(desktop_err).await;
}
} else {
if desktop_err.is_empty() {
println!("REMOVE ME =============================== send logon response");
self.send_logon_response().await;
self.try_start_cm(lr.my_id, lr.my_name, true);
if self.port_forward_socket.is_some() {
return false;
}
} else {
println!("REMOVE ME =============================== send login error {}", &desktop_err);
self.send_login_error(desktop_err).await;
}
}
} else if let Some(message::Union::TestDelay(t)) = msg.union {