#libunftp #unftp #start #unftp-sbe-rooter #user-detail #user-with-root

unftp-sbe-rooter

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

4 releases

new 0.2.2 Apr 25, 2025
0.2.1 May 18, 2024
0.2.0 Sep 17, 2023
0.1.0 Sep 9, 2023

#1333 in Network programming

Download history 2/week @ 2025-01-01 2/week @ 2025-01-08 23/week @ 2025-01-22 5/week @ 2025-01-29 12/week @ 2025-02-05 10/week @ 2025-02-12 5/week @ 2025-02-19 4/week @ 2025-02-26 20/week @ 2025-03-05 26/week @ 2025-03-12 15/week @ 2025-03-19 13/week @ 2025-04-09 128/week @ 2025-04-16

143 downloads per month
Used in unftp

Apache-2.0

23KB
312 lines

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"))
    });
}


unftp-sbe-rooter

Crate Version API Docs Crate License Follow on Telegram

A libunftp wrapper storage back-end that roots a user to a specific home directory. See the docs to get started.

Dependencies

~26–53MB
~1M SLoC