feat: use shellx tauri-shell plugin fork to bypass permission enforcement

This commit is contained in:
Maarten van Heusden
2025-02-21 14:12:29 +01:00
parent 9bee63241e
commit c2d47a9e52
10 changed files with 35 additions and 21 deletions

View File

@@ -14,7 +14,8 @@
"@tauri-apps/api": "2.2.0",
"@tauri-apps/plugin-dialog": "2.2.0",
"@tauri-apps/plugin-shell": "2.2.0",
"jquery": "^3.7.1"
"jquery": "^3.7.1",
"tauri-plugin-shellx-api": "^2.0.14"
},
"devDependencies": {
"@eslint/js": "^9.20.0",

10
pnpm-lock.yaml generated
View File

@@ -20,6 +20,9 @@ importers:
jquery:
specifier: ^3.7.1
version: 3.7.1
tauri-plugin-shellx-api:
specifier: ^2.0.14
version: 2.0.14
devDependencies:
'@eslint/js':
specifier: ^9.20.0
@@ -849,6 +852,9 @@ packages:
resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}
engines: {node: '>=8'}
tauri-plugin-shellx-api@2.0.14:
resolution: {integrity: sha512-MdSYD2KDw63b7yEIa9Q2GXnbidL5Tk+s92BJX0XvYfHrv2l1fYE2vdRWGnyhvCWmUavyCeiOle5uMxM6QLOb2Q==}
to-regex-range@5.0.1:
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
engines: {node: '>=8.0'}
@@ -1654,6 +1660,10 @@ snapshots:
dependencies:
has-flag: 4.0.0
tauri-plugin-shellx-api@2.0.14:
dependencies:
'@tauri-apps/api': 2.2.0
to-regex-range@5.0.1:
dependencies:
is-number: 7.0.0

16
src-tauri/Cargo.lock generated
View File

@@ -4280,9 +4280,9 @@ dependencies = [
[[package]]
name = "tauri-plugin"
version = "2.0.2"
version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fa4e6c94cb1d635f65a770c69e23de1bc054b0e4c554fa037a7cc7676333d39"
checksum = "5841b9a0200e954ef7457f8d327091424328891e267a97b641dc246cc54d0dec"
dependencies = [
"anyhow",
"glob",
@@ -4337,13 +4337,12 @@ dependencies = [
]
[[package]]
name = "tauri-plugin-shell"
version = "2.2.0"
name = "tauri-plugin-shellx"
version = "2.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb2c50a63e60fb8925956cc5b7569f4b750ac197a4d39f13b8dd46ea8e2bad79"
checksum = "32409a09fd9351a3d3e25f7a2e2ba501b114c6869afb7b46d06a5473055c995f"
dependencies = [
"encoding_rs",
"log",
"open",
"os_pipe",
"regex",
@@ -4351,9 +4350,10 @@ dependencies = [
"serde",
"serde_json",
"shared_child",
"strip-ansi-escapes",
"tauri",
"tauri-plugin",
"thiserror 2.0.11",
"thiserror 1.0.69",
"tokio",
]
@@ -4938,7 +4938,7 @@ dependencies = [
"tauri",
"tauri-build",
"tauri-plugin-dialog",
"tauri-plugin-shell",
"tauri-plugin-shellx",
"zip",
]

View File

@@ -14,13 +14,13 @@ tauri-build = { version = "2.0.5", features = [] }
[dependencies]
fix-path-env = { git = "https://github.com/tauri-apps/fix-path-env-rs" }
tauri = { version = "2.2.5", features = [] }
tauri-plugin-shell = "2.2.0"
tauri-plugin-dialog = "2.2.0"
serde = { version = "1.0.218", features = ["derive"] }
serde_json = "1.0.139"
derive-getters = "0.5.0"
reqwest = { version = "0.12.12",features = ["blocking"] }
zip = "2.2.2"
tauri-plugin-shellx = "2.0.12"

View File

@@ -7,9 +7,9 @@
],
"permissions": [
"core:default",
"shell:allow-open",
"dialog:default",
"shell:allow-execute",
"shell:allow-spawn"
"shellx:allow-open",
"shellx:allow-execute",
"shellx:allow-spawn"
]
}

View File

@@ -13,7 +13,7 @@ use std::path::{Path, PathBuf};
use std::sync::OnceLock;
use std::time::Duration;
use tauri::{AppHandle, Emitter, Manager};
use tauri_plugin_shell::ShellExt;
use tauri_plugin_shellx::ShellExt;
/// The first terminal found. Used as default terminal.
@@ -60,7 +60,6 @@ async fn start_download(steam_download: steam::SteamDownload, app: AppHandle) {
println!("\t- Terminal command: \n\t {:?}", terminal_to_use.create_command(&steam_download, shell, &WORKING_DIR.get().unwrap()));
println!("----------------------------------------------------------\n");
terminal_to_use.create_command(&steam_download, shell, &WORKING_DIR.get().unwrap()).spawn().ok();
}
@@ -134,7 +133,8 @@ fn main() {
}
println!();
tauri::Builder::default().plugin(tauri_plugin_dialog::init()).plugin(tauri_plugin_shell::init()).invoke_handler(tauri::generate_handler![
tauri::Builder::default().plugin(tauri_plugin_dialog::init()).plugin(tauri_plugin_shellx::init(true)).invoke_handler(tauri::generate_handler![
start_download,
download_depotdownloader,
internet_connection,

View File

@@ -3,8 +3,8 @@ use crate::steam::SteamDownload;
use std::fs;
use std::path::PathBuf;
use tauri::Wry;
use tauri_plugin_shell::process::Command;
use tauri_plugin_shell::Shell;
use tauri_plugin_shellx::process::Command;
use tauri_plugin_shellx::Shell;
/// Represents a terminal that can be used to run commands.
/// **Should be in sync with the terminal dropdown in the frontend.**

View File

@@ -1,7 +1,7 @@
import $ from "jquery";
import {invoke} from "@tauri-apps/api/core";
import {open as openDialog} from "@tauri-apps/plugin-dialog";
import {open as openShell} from "@tauri-apps/plugin-shell";
import {open as openShell} from "tauri-plugin-shellx-api";
import {listen} from "@tauri-apps/api/event";
function setLoader(state: boolean) {

View File

@@ -1,10 +1,13 @@
import {message} from "@tauri-apps/plugin-dialog";
import {invoke} from "@tauri-apps/api/core";
import {open} from "@tauri-apps/plugin-shell";
import {fixPathEnv, open} from "tauri-plugin-shellx-api";
import $ from "jquery";
$(async () => {
/* Fix stupid PATH shit */
fixPathEnv();
/* eslint-disable indent */
switch (await invoke("internet_connection")) {
case false: {

View File

@@ -1,5 +1,5 @@
import {getVersion} from "@tauri-apps/api/app";
import {open} from "@tauri-apps/plugin-shell";
import {open} from "tauri-plugin-shellx-api";
import $ from "jquery";