Skip to content

Commit

Permalink
Cleanup + tidy
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Saveau <[email protected]>
  • Loading branch information
SUPERCILEX committed Dec 30, 2022
1 parent db22404 commit bd120d1
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 29 deletions.
53 changes: 37 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ license = "Apache-2.0"
clap = { version = "4.0.32", features = ["derive", "wrap_help"] }
dirs = "4.0.0"
error-stack = "0.2.4"
nix = { version = "0.26.1", default-features = false, features = ["user", "mount"] }
# TODO nuke once rustix has mount
nix = { version = "0.26.1", default-features = false, features = ["mount"] }
rustix = { version = "0.36.6", features = ["fs", "process"] }
thiserror = "1.0.38"

[dev-dependencies]
expect-test = "1.4.0"
public-api = "0.24.0"
rustdoc-json = "0.7.0"
public-api = "0.25.0"
rustdoc-json = "0.7.4"

[profile.release]
lto = true
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ ForkFS allows you to sandbox a process's changes to your file system.
### Use prebuilt binaries

Binaries for a number of platforms are available on the
[release page](https://github.com/SUPERCILEX/ftzz/releases/latest).
[release page](https://github.com/SUPERCILEX/forkfs/releases/latest).

### Build from source

```console,ignore
$ cargo +nightly install ftzz
$ cargo +nightly install forkfs
```

> To install cargo, follow [these instructions](https://doc.rust-lang.org/cargo/getting-started/installation.html).
> To install cargo, follow
> [these instructions](https://doc.rust-lang.org/cargo/getting-started/installation.html).
## Usage

Expand All @@ -25,10 +26,15 @@ Run a command in the sandbox:
$ sudo forkfs run -- <your command>
```

All file system changes the command makes will only exist within the sandbox and will not modify your real file system.
All file system changes the command makes will only exist within the sandbox and will not modify
your real file system.

You can also start a bash shell wherein any command you execute has its file operations sandboxed:

```sh
$ sudo -E forkfs run bash
```

> Note: be consistent with your usage of `-E`. Bare `sudo` vs `sudo -E` will likely change the
> forkfs environment, meaning sessions that appear in `sudo` will not appear in `sudo -E` and vice
> versa.
12 changes: 6 additions & 6 deletions api.golden
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pub mod forkfs
pub enum forkfs::Error
pub enum variant forkfs::Error::InvalidArgument
pub enum variant forkfs::Error::Io
pub enum variant forkfs::Error::NotRoot
pub enum variant forkfs::Error::SessionNotFound
pub forkfs::Error::InvalidArgument
pub forkfs::Error::Io
pub forkfs::Error::NotRoot
pub forkfs::Error::SessionNotFound
impl core::fmt::Debug for forkfs::Error
pub fn forkfs::Error::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
impl core::fmt::Display for forkfs::Error
Expand Down Expand Up @@ -38,8 +38,8 @@ impl<T, U> core::convert::TryInto<U> for forkfs::Error where U: core::convert::T
pub type forkfs::Error::Error = <U as core::convert::TryFrom<T>>::Error
pub fn forkfs::Error::try_into(self) -> core::result::Result<U, <U as core::convert::TryFrom<T>>::Error>
pub enum forkfs::SessionOperand<'a, S: core::convert::AsRef<str>>
pub enum variant forkfs::SessionOperand::All
pub enum variant forkfs::SessionOperand::List(&'a [S])
pub forkfs::SessionOperand::All
pub forkfs::SessionOperand::List(&'a [S])
impl<'a, S> core::panic::unwind_safe::RefUnwindSafe for forkfs::SessionOperand<'a, S> where S: core::panic::unwind_safe::RefUnwindSafe
impl<'a, S> core::marker::Send for forkfs::SessionOperand<'a, S> where S: core::marker::Sync
impl<'a, S> core::marker::Sync for forkfs::SessionOperand<'a, S> where S: core::marker::Sync
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#![feature(const_cstr_methods)]
#![feature(dir_entry_ext2)]
#![allow(clippy::missing_errors_doc)]
#![allow(clippy::multiple_crate_versions)]

use std::{
fmt::{Debug, Display},
Expand Down Expand Up @@ -39,6 +40,7 @@ pub enum Error {
}

fn get_sessions_dir() -> Result<PathBuf, Error> {
// TODO check capabilities instead once in rustix
if !getuid().is_root() {
return Err(Error::NotRoot).into_report();
}
Expand Down
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::multiple_crate_versions)]

use std::{
ffi::OsString,
io,
Expand Down

0 comments on commit bd120d1

Please sign in to comment.