chore: replace sudo with pkexec execution

This commit is contained in:
huzibaca 2024-10-21 02:31:43 +08:00
parent 90091db3b1
commit babf5d840c
No known key found for this signature in database
GPG Key ID: D4364EE4851DC302
2 changed files with 1 additions and 2 deletions

View File

@ -103,7 +103,6 @@ pub async fn reinstall_service() -> Result<()> {
}; };
log::info!(target:"app", "status code:{}", status.code().unwrap()); log::info!(target:"app", "status code:{}", status.code().unwrap());
let elevator = crate::utils::help::linux_elevator();
let status = match get_effective_uid() { let status = match get_effective_uid() {
0 => StdCommand::new(install_shell).status()?, 0 => StdCommand::new(install_shell).status()?,
_ => StdCommand::new(elevator) _ => StdCommand::new(elevator)

View File

@ -108,7 +108,7 @@ pub fn open_file(app: tauri::AppHandle, path: PathBuf) -> Result<()> {
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
pub fn linux_elevator() -> String { pub fn linux_elevator() -> String {
use std::process::Command; use std::process::Command;
match Command::new("which").arg("sudo").output() { match Command::new("which").arg("pkexec").output() {
Ok(output) => { Ok(output) => {
if !output.stdout.is_empty() { if !output.stdout.is_empty() {
// Convert the output to a string slice // Convert the output to a string slice