#Running an extarnal bin part of the application as root

4 messages · Page 1 of 1 (latest)

minor gazelle
#

Context:
I'm trying to rewrite my Electron app in Rust. The Electron version cannot be bundled in deb or AppImage format and, on Linux, must be run from a terminal.
I quickly tested Tauri and was able to load my C++ lib, which itself runs the Chrolog server as root with pkexec. The app was also working without launching it from a terminal!

Now:
I converted the Chrolog server to Rust, and now I'm trying to run it directly in Rust Tauri without the previous .so lib middleware. But it seems like Tauri can't locate pkexec when using:

use tauri::api::process::Command;

Command::new_sidecar("/usr/bin/pkexec")
        .expect("Failed to find pkexec")
        .args(&[resource_path])
        .spawn()
        .expect("Failed to spawn Chrolog server");

I checked the documentation for sidecar and command API and cannot understand if the issue is pkexec being an edge case?

I get this error when trying to run Tauri dev:

error: failed to run custom build command for `chrolog-tauri v0.0.0 (/home/lucas/Workspace/Projet/chrolog-tauri/src-tauri)`

Caused by:
  process didn't exit successfully: `build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=TAURI_CONFIG
  cargo:rerun-if-changed=tauri.conf.json
  cargo:rustc-cfg=desktop
  cargo:rustc-cfg=dev
  path matching /usr/bin/pkexec-x86_64-unknown-linux-gnu not found.

You may need to embed depending binaries to make your application work or prevent users from installing additional dependencies (e.g., Node.js or Python).

Access the system shell.

#

My tauri.config.json trimmed:

{
    "tauri": {
        "allowlist": {
            "all": false,
            "shell": {
                "all": false,
                "open": true,
                "sidecar": true,
                "scope": [
                    {
                        "name": "/usr/bin/pkexec",
                        "sidecar": true,
                        "args": [{ "validator": "/chrolog-server$/" }]
                    }
                ]
            },
            "path": {
                "all": true
            }
        },
        "bundle": {
            "externalBin": ["/usr/bin/pkexec"]
        }
    }
}
#

Thanks for reading !

minor gazelle