#home-dir #user #libunftp #root #unftp #wrapper #back-end

unftp-sbe-rooter

一个将用户根目录固定到特定目录的 libunftp 包装存储后端

3 个不稳定版本

0.2.1 2024 年 5 月 18 日
0.2.0 2023 年 9 月 17 日
0.1.0 2023 年 9 月 9 日

网络编程 中排名 1180

Download history · Rust 包仓库 15/week @ 2024-03-11 · Rust 包仓库 9/week @ 2024-03-18 · Rust 包仓库 5/week @ 2024-03-25 · Rust 包仓库 54/week @ 2024-04-01 · Rust 包仓库 2/week @ 2024-04-08 · Rust 包仓库 57/week @ 2024-04-15 · Rust 包仓库 7/week @ 2024-04-22 · Rust 包仓库 48/week @ 2024-05-06 · Rust 包仓库 273/week @ 2024-05-13 · Rust 包仓库 61/week @ 2024-05-20 · Rust 包仓库 40/week @ 2024-05-27 · Rust 包仓库 10/week @ 2024-06-03 · Rust 包仓库 9/week @ 2024-06-10 · Rust 包仓库 72/week @ 2024-06-17 · Rust 包仓库 9/week @ 2024-06-24 · Rust 包仓库

每月下载量 107
用于 unftp

Apache-2.0

15KB
312 行(不包括注释)

unftp-sbe-rooter

Crate Version API Docs Crate License Follow on Telegram

一个将用户根目录固定到特定目录的 libunftp 包装存储后端。请参阅文档以开始使用。


lib.rs:

一个将用户根目录固定到特定目录的 libunftp 包装存储后端。

快速开始

首先实现 libunftp 的 UserDetail 特性,然后实现 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"))
    });
}

依赖关系

~22–34MB
~603K SLoC