#home-dir #user #directory #libunftp #root #unftp #wrapper

unftp-sbe-rooter

A libunftp wrapper storage back-end that roots a user to a specific home directory

2 unstable releases

0.2.0 Sep 17, 2023
0.1.0 Sep 9, 2023

#6 in #unftp

Download history 42/week @ 2023-12-20 27/week @ 2023-12-27 1/week @ 2024-01-10 7/week @ 2024-01-17 4/week @ 2024-02-14 31/week @ 2024-02-21 61/week @ 2024-02-28 10/week @ 2024-03-06 16/week @ 2024-03-13 7/week @ 2024-03-20 17/week @ 2024-03-27 40/week @ 2024-04-03

82 downloads per month
Used in unftp

Apache-2.0

15KB
312 lines

unftp-sbe-rooter

A libunftp wrapper storage back-end that roots a user to a specific home directory.


lib.rs:

A libunftp wrapper storage back-end that roots a user to a specific home directory.

Quick start

Start by implementing the libunftp UserDetail trait and then follow that by implementing UserWithRoot.

use libunftp::auth::UserDetail;
use unftp_sbe_rooter::UserWithRoot;
use std::fmt::Formatter;
use std::path::{Path, PathBuf};

#[derive(Debug, PartialEq, Eq)]
pub struct User {
    pub username: String,
    pub root: Option<PathBuf>,
}

impl UserDetail for User {
    fn account_enabled(&self) -> bool {
        true
    }
}

impl std::fmt::Display for User {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        write!(f, "User(username: {:?}", self.username,)
    }
}

impl UserWithRoot for User {
    fn user_root(&self) -> Option<PathBuf> {
        self.root.clone()
    }
}

// Return type omited for brevity.
fn create_rooted_storage_backend() {
    use unftp_sbe_fs::{Filesystem, Meta};
    let _backend = Box::new(move || {
        unftp_sbe_rooter::RooterVfs::<Filesystem, User, Meta>::new(Filesystem::new("/srv/ftp"))
    });
}

Dependencies

~19–32MB
~544K SLoC