Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the flatpak(-spawn) portal nicer to work with #146

Open
orowith2os opened this issue Jul 31, 2023 · 1 comment
Open

Make the flatpak(-spawn) portal nicer to work with #146

orowith2os opened this issue Jul 31, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@orowith2os
Copy link

orowith2os commented Jul 31, 2023

The flatpak module currently doesn't seem very nice to work with; ideally it would more closely look like the flatpak-spawn command, and (imo) wouldn't look as "ugly".

Here's a quick draft of what the ideal struct for it would be like, this 100% needs tweaking in order to work with the Flatpak portal, and work "properly":

use std::os::fd::RawFd;
use std::fs::File;

#[derive(Debug)]
struct EnvVar {
    var: String,
    val: String,
}

/// A (more or less) 1:1 copy of the flatpak-spawn command, as a struct
#[derive(Default, Debug)]
struct FlatpakSpawn {
    /// Enable debug output
    verbose: bool,
    /// Forward file descriptor(s)
    forward_fd: Vec<RawFd>,
    /// Run with clean environment
    clear_env: bool,
    /// Make the spawned command exit if we do
    watch_bus: bool,
    /// Expose sandbox PIDs in calling sandbox
    expose_pids: bool,
    /// Use the same PID namespace as calling sandbox
    share_pids: bool,
    /// Set environment variable(s)
    env: Vec<EnvVar>,
    // Unset environment variable(s)
    // Remember to only pass through the variable name, not the contents!
    // TODO
    // unset-env: Vec<String>

    // TODO: env-fd

    /// Run with the latest vesion of the app and runtime
    latest_version: bool,
    /// Run sandboxed, without inheriting permissions.
    /// See the --sandbox argument in https://man7.org/linux/man-pages/man1/flatpak-run.1.html 
    /// for more information.
    sandbox: bool,
    /// Whether to run with network access
    no_network: bool,
    /// Expose read-write access to the files/directories
    sandbox-expose-rw: Vec<File>,
    /// Expose read-only access to the files/directories
    sandbox-expose-ro: Vec<File>,

    // TODO: sandbox-flag
    
    // NOT PLANNED: host (use a separate struct, ideally closer to Command)
    
    /// Working directory in which to run the command
    directory: File,

    // Replace runtime's /app with DIR, or empty
    // TODO
    // app-path

    /// Replace runtime's /usr with DIR
    usr-path: File,
}
@orowith2os orowith2os changed the title Make the flatpak portal nicer to work with Make the flatpak(-spawn) portal nicer to work with Aug 1, 2023
@bilelmoussaoui
Copy link
Owner

PRs are welcome.

@bilelmoussaoui bilelmoussaoui added the enhancement New feature or request label Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants