Crate rootless_run

Crate rootless_run 

Source
Expand description

§rootless-run 🫚🚫🏃‍➡️

A Rust library for the execution of commands as root without being root.

Currently, it supports fakeroot and rootlesskit.

§Documentation

Refer to https://docs.rs/rootless-run/latest/rootless_run/ for released versions of the crate.

§Examples

§Library

use rootless_run::{
    FakerootBackend,
    FakerootOptions,
    RootlessBackend,
    RootlesskitBackend,
    RootlesskitOptions,
};

// Create a fakeroot backend with default options.
let backend = FakerootBackend::new(FakerootOptions::default());

// Call `whoami` using fakeroot and return its output.
let output = backend.run(&["whoami"])?;

assert_eq!("root\n", String::from_utf8_lossy(&output.stdout));

// Create a rootlesskit backend with default options.
let backend = RootlesskitBackend::new(RootlesskitOptions::default());

// Call `whoami` using rootlesskit and return its output.
let output = backend.run(&["whoami"])?;

assert_eq!("root\n", String::from_utf8_lossy(&output.stdout));

§Contributing

Please refer to the contribution guidelines to learn how to contribute to this project.

§Releases

Releases are created by the developers of this project.

OpenPGP certificates with the following OpenPGP fingerprints can be used to verify signed tags:

Some of the above are part of archlinux-keyring and certified by at least three main signing keys of the distribution. All certificate are cross-signed and can be retrieved from OpenPGP keyservers.

§License

This project can be used under the terms of the Apache-2.0 or MIT. Contributions to this project, unless noted otherwise, are automatically licensed under the terms of both of those licenses.

Structs§

FakerootBackend
A rootless backend for running commands using fakeroot.
FakerootOptions
Options for fakeroot.
RootlesskitBackend
A rootless backend for running commands using rootlesskit.
RootlesskitOptions
Options for rootlesskit.

Enums§

AutoOption
An option that may be on, off or automatic.
ConfidentialVirtualizationTechnology
A confidential virtualization technology detected by systemd-detect-virt.
CopyUpMode
The mode used for rootlesskit’s --copy-up option.
Error
An error that can occur when using a rootless backend.
Net
A network driver used by rootlesskit.
PortDriver
A port driver for the non-host network of rootlesskit.
Propagation
The propagation used for rootlesskit’s --copy-up option.
SubIdSource
The source of subids for rootlesskit.
SystemdDetectVirtContainer
A container environment detected by systemd-detect-virt.
SystemdDetectVirtOutput
The output of systemd-detect-virt.
SystemdDetectVirtVm
A VM environment detected by systemd-detect-virt.

Traits§

RootlessBackend
A backend for running a command as root.
RootlessOptions
The options for a rootless backend.

Functions§

detect_virt
Detects whether currently running in a virtualized or containerized Linux environment.
get_command
Returns the path to a command.