feat: Use polkit to elevate permission instaed of sudo (#678)

This commit is contained in:
Kimiblock Moe 2023-07-21 23:05:33 +08:00 committed by GitHub
parent 9638eefc91
commit 6c1ab6002d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,7 +28,7 @@ pub fn grant_permission(core: String) -> anyhow::Result<()> {
let output = { let output = {
let path = path.replace(' ', "\\ "); // 避免路径中有空格 let path = path.replace(' ', "\\ "); // 避免路径中有空格
let shell = format!("setcap cap_net_bind_service,cap_net_admin=+ep {path}"); let shell = format!("setcap cap_net_bind_service,cap_net_admin=+ep {path}");
Command::new("sudo") Command::new("pkexec")
.arg("sh") .arg("sh")
.arg("-c") .arg("-c")
.arg(shell) .arg(shell)