mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-03-31 09:01:04 +03:00
fix: allow logon screen password, on lock screen (#11566)
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
@@ -491,6 +491,38 @@ pub fn is_prelogin() -> bool {
|
||||
get_active_userid() == "0"
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/11505255/osx-check-if-the-screen-is-locked
|
||||
// No "CGSSessionScreenIsLocked" can be found when macOS is not locked.
|
||||
//
|
||||
// `ioreg -n Root -d1` returns `"CGSSessionScreenIsLocked"=Yes`
|
||||
// `ioreg -n Root -d1 -a` returns
|
||||
// ```
|
||||
// ...
|
||||
// <key>CGSSessionScreenIsLocked</key>
|
||||
// <true/>
|
||||
// ...
|
||||
// ```
|
||||
pub fn is_locked() -> bool {
|
||||
match std::process::Command::new("ioreg")
|
||||
.arg("-n")
|
||||
.arg("Root")
|
||||
.arg("-d1")
|
||||
.output()
|
||||
{
|
||||
Ok(output) => {
|
||||
let output_str = String::from_utf8_lossy(&output.stdout);
|
||||
// Although `"CGSSessionScreenIsLocked"=Yes` was printed on my macOS,
|
||||
// I also check `"CGSSessionScreenIsLocked"=true` for better compability.
|
||||
output_str.contains("\"CGSSessionScreenIsLocked\"=Yes")
|
||||
|| output_str.contains("\"CGSSessionScreenIsLocked\"=true")
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Failed to query ioreg for the lock state: {}", e);
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_root() -> bool {
|
||||
crate::username() == "root"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user