fix: allow logon screen password, on lock screen (#11566)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou
2025-04-25 10:37:09 +08:00
committed by GitHub
parent 279fb72a4f
commit 198967ea35
7 changed files with 248 additions and 9 deletions

View File

@@ -623,6 +623,31 @@ pub fn is_prelogin() -> bool {
n < 4 && n > 1
}
// Check "Lock".
// "Switch user" can't be checked, because `get_values_of_seat0(&[0])` does not return the session.
// The logged in session is "online" not "active".
// And the "Switch user" screen is usually Wayland login session, which we do not support.
pub fn is_locked() -> bool {
if is_prelogin() {
return false;
}
let values = get_values_of_seat0(&[0]);
// Though the values can't be empty, we still add check here for safety.
// Because we cannot guarantee whether the internal implementation will change in the future.
// https://github.com/rustdesk/hbb_common/blob/ebb4d4a48cf7ed6ca62e93f8ed124065c6408536/src/platform/linux.rs#L119
if values.is_empty() {
log::debug!("Failed to check is locked, values vector is empty.");
return false;
}
let session = &values[0];
if session.is_empty() {
log::debug!("Failed to check is locked, session is empty.");
return false;
}
is_session_locked(session)
}
pub fn is_root() -> bool {
crate::username() == "root"
}