mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
plugin_framework, plugin manager, debug linux
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -660,6 +660,25 @@ pub fn check_super_user_permission() -> ResultType<bool> {
|
||||
Ok(status.success() && status.code() == Some(0))
|
||||
}
|
||||
|
||||
pub fn elevate(arg: Vec<&str>) -> ResultType<Option<Child>> {
|
||||
let cmd = std::env::current_exe()?;
|
||||
match cmd.to_str() {
|
||||
Some(cmd) => {
|
||||
let mut args = vec![cmd];
|
||||
args.append(&mut arg.clone());
|
||||
// -E required for opensuse
|
||||
if is_opensuse() {
|
||||
args.insert(0, "-E");
|
||||
}
|
||||
let task = Command::new("pkexec").args(args).spawn()?;
|
||||
Ok(Some(task))
|
||||
}
|
||||
None => {
|
||||
hbb_common::bail!("Failed to get current exe as str");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type GtkSettingsPtr = *mut c_void;
|
||||
type GObjectPtr = *mut c_void;
|
||||
#[link(name = "gtk-3")]
|
||||
|
||||
@@ -54,27 +54,6 @@ pub fn get_active_username() -> String {
|
||||
#[cfg(target_os = "android")]
|
||||
pub const PA_SAMPLE_RATE: u32 = 48000;
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
pub fn run_as_root(arg: Vec<&str>) -> ResultType<Option<Child>> {
|
||||
let cmd = std::env::current_exe()?;
|
||||
match cmd.to_str() {
|
||||
Some(cmd) => {
|
||||
let mut args = vec![cmd];
|
||||
args.append(&mut arg.clone());
|
||||
// -E required for opensuse
|
||||
#[cfg(target_os = "linux")]
|
||||
if is_opensuse() {
|
||||
args.insert(0, "-E");
|
||||
}
|
||||
let task = Command::new("sudo").args(args).spawn()?;
|
||||
Ok(Some(task))
|
||||
}
|
||||
None => {
|
||||
bail!("Failed to get current exe as str");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user