add polkit for custom authentication && update build.rs

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2022-09-13 18:10:20 +08:00
parent 64f5f3253c
commit 203d9e39a0
3 changed files with 40 additions and 10 deletions

View File

@@ -638,7 +638,13 @@ pub fn quit_gui() {
}
pub fn check_super_user_permission() -> ResultType<bool> {
// TODO: replace echo with a rustdesk's program, which is location-fixed and non-gui.
let status = std::process::Command::new("pkexec").arg("echo").status()?;
let file = "/usr/share/rustdesk/files/polkit";
let arg;
if std::path::Path::new(file).is_file() {
arg = file;
} else {
arg = "echo";
}
let status = std::process::Command::new("pkexec").arg(arg).status()?;
Ok(status.success() && status.code() == Some(0))
}