mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-16 23:38:56 +00:00
feat: clearer messaging around setcap failures; getcap after setcap
This commit is contained in:
parent
36322b3b2c
commit
0020dcf3d4
2 changed files with 45 additions and 6 deletions
|
@ -41,7 +41,9 @@ use crate::{
|
|||
steam_linux_runtime_injector::{
|
||||
restore_runtime_entrypoint, set_runtime_entrypoint_launch_opts_from_profile,
|
||||
},
|
||||
util::file_utils::{setcap_cap_sys_nice_eip, setcap_cap_sys_nice_eip_cmd},
|
||||
util::file_utils::{
|
||||
setcap_cap_sys_nice_eip, setcap_cap_sys_nice_eip_cmd, verify_cap_sys_nice_eip,
|
||||
},
|
||||
vulkaninfo::VulkanInfo,
|
||||
wivrn_dbus,
|
||||
xr_devices::XRDevice,
|
||||
|
@ -653,7 +655,23 @@ impl AsyncComponent for App {
|
|||
error!("pkexec not found, skipping setcap");
|
||||
} else {
|
||||
let profile = self.get_selected_profile();
|
||||
setcap_cap_sys_nice_eip(&profile).await;
|
||||
let setcap_failed_dialog = || {
|
||||
alert_w_widget(
|
||||
"Setcap failed to run",
|
||||
Some("Setting the capabilities automatically failed, you can still try manually using the command below."
|
||||
),
|
||||
Some(&copiable_code_snippet(
|
||||
&format!("sudo {}", setcap_cap_sys_nice_eip_cmd(&profile).join(" "))
|
||||
)),
|
||||
Some(&self.app_win.clone().upcast())
|
||||
);
|
||||
};
|
||||
if let Err(e) = setcap_cap_sys_nice_eip(&profile).await {
|
||||
setcap_failed_dialog();
|
||||
error!("failed running setcap: {e}");
|
||||
} else if !verify_cap_sys_nice_eip(&profile).await {
|
||||
setcap_failed_dialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
Msg::ProfileSelected(prof) => {
|
||||
|
|
|
@ -90,11 +90,32 @@ pub fn setcap_cap_sys_nice_eip_cmd(profile: &Profile) -> Vec<String> {
|
|||
]
|
||||
}
|
||||
|
||||
pub async fn setcap_cap_sys_nice_eip(profile: &Profile) {
|
||||
if let Err(e) = async_process("pkexec", Some(&setcap_cap_sys_nice_eip_cmd(profile)), None).await
|
||||
{
|
||||
error!("failed running setcap: {e}");
|
||||
pub async fn verify_cap_sys_nice_eip(profile: &Profile) -> bool {
|
||||
let xrservice_binary = profile.xrservice_binary().to_string_lossy().to_string();
|
||||
match async_process("getcap", Some(&[&xrservice_binary]), None).await {
|
||||
Err(e) => {
|
||||
error!("failed to run `getcap {xrservice_binary}`: {e:?}");
|
||||
false
|
||||
}
|
||||
Ok(out) => {
|
||||
debug!("getcap {xrservice_binary} stdout: {}", out.stdout);
|
||||
debug!("getcap {xrservice_binary} stderr: {}", out.stderr);
|
||||
if out.exit_code != 0 {
|
||||
error!(
|
||||
"command `getcap {xrservice_binary}` failed with status code {}",
|
||||
out.exit_code
|
||||
);
|
||||
false
|
||||
} else {
|
||||
out.stdout.to_lowercase().contains("cap_sys_nice=eip")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn setcap_cap_sys_nice_eip(profile: &Profile) -> anyhow::Result<()> {
|
||||
async_process("pkexec", Some(&setcap_cap_sys_nice_eip_cmd(profile)), None).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn rm_rf(path: &Path) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue