renaming the project adduser -> umanux
This commit is contained in:
parent
05cbd2d139
commit
5a678bc3d5
32
Cargo.lock
generated
32
Cargo.lock
generated
@ -1,21 +1,5 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
[[package]]
|
|
||||||
name = "adduser"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"chrono",
|
|
||||||
"clap",
|
|
||||||
"derive_builder",
|
|
||||||
"env_logger",
|
|
||||||
"lazy_static",
|
|
||||||
"log",
|
|
||||||
"regex",
|
|
||||||
"simplelog",
|
|
||||||
"tempfile",
|
|
||||||
"test_bin",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aho-corasick"
|
name = "aho-corasick"
|
||||||
version = "0.7.13"
|
version = "0.7.13"
|
||||||
@ -501,6 +485,22 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "umanux"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
"clap",
|
||||||
|
"derive_builder",
|
||||||
|
"env_logger",
|
||||||
|
"lazy_static",
|
||||||
|
"log",
|
||||||
|
"regex",
|
||||||
|
"simplelog",
|
||||||
|
"tempfile",
|
||||||
|
"test_bin",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-segmentation"
|
name = "unicode-segmentation"
|
||||||
version = "1.6.0"
|
version = "1.6.0"
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "adduser"
|
name = "umanux"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
description = "Library for managing Linux users and their directories"
|
description = "Library for managing Linux users and their directories"
|
||||||
authors = ["Dietrich <dietrich@teilgedanken.de>"]
|
authors = ["Dietrich <dietrich@teilgedanken.de>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
keywords = ["user", "admin", "linux", "manage"]
|
keywords = ["user", "admin", "linux", "manage", "passwd"]
|
||||||
categories = ["system-tools", "system-tools::user-management"]
|
categories = ["os", "os::linux-apis", "parser-implementations", "command-line-utilities"]
|
||||||
repository = "https://git.teilgedanken.de/Rust/useradd/"
|
repository = "https://github.com/umanux/umanux"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
@ -3,8 +3,8 @@ use std::path::PathBuf;
|
|||||||
extern crate clap;
|
extern crate clap;
|
||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
|
|
||||||
extern crate adduser;
|
extern crate umanux;
|
||||||
use adduser::{api::UserDBWrite, UserLibError};
|
use umanux::{api::UserDBWrite, UserLibError};
|
||||||
|
|
||||||
fn main() -> Result<(), UserLibError> {
|
fn main() -> Result<(), UserLibError> {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
@ -48,18 +48,18 @@ fn main() -> Result<(), UserLibError> {
|
|||||||
)
|
)
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
let mf = adduser::Files {
|
let mf = umanux::Files {
|
||||||
passwd: Some(PathBuf::from(matches.value_of("passwd").unwrap())),
|
passwd: Some(PathBuf::from(matches.value_of("passwd").unwrap())),
|
||||||
shadow: Some(PathBuf::from(matches.value_of("shadow").unwrap())),
|
shadow: Some(PathBuf::from(matches.value_of("shadow").unwrap())),
|
||||||
group: Some(PathBuf::from(matches.value_of("group").unwrap())),
|
group: Some(PathBuf::from(matches.value_of("group").unwrap())),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut db = adduser::UserDBLocal::load_files(mf).unwrap();
|
let mut db = umanux::UserDBLocal::load_files(mf).unwrap();
|
||||||
|
|
||||||
match db.new_user(
|
match db.new_user(
|
||||||
adduser::api::CreateUserArgs::builder()
|
umanux::api::CreateUserArgs::builder()
|
||||||
.username(matches.value_of("username").unwrap())
|
.username(matches.value_of("username").unwrap())
|
||||||
// .delete_home(adduser::api::DeleteHome::Delete)
|
// .delete_home(umanux::api::DeleteHome::Delete)
|
||||||
.build()
|
.build()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
) {
|
) {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
extern crate adduser;
|
extern crate umanux;
|
||||||
|
|
||||||
use adduser::api::UserDBWrite;
|
use umanux::api::UserDBWrite;
|
||||||
use adduser::api::UserRead;
|
use umanux::api::UserRead;
|
||||||
|
|
||||||
extern crate env_logger;
|
extern crate env_logger;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
@ -12,18 +12,18 @@ use log::{debug, error, info, trace, warn};
|
|||||||
fn main() {
|
fn main() {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
|
|
||||||
let mf = adduser::Files {
|
let mf = umanux::Files {
|
||||||
passwd: Some(PathBuf::from("./passwd")),
|
passwd: Some(PathBuf::from("./passwd")),
|
||||||
shadow: Some(PathBuf::from("./shadow")),
|
shadow: Some(PathBuf::from("./shadow")),
|
||||||
group: Some(PathBuf::from("./group")),
|
group: Some(PathBuf::from("./group")),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut db = adduser::UserDBLocal::load_files(mf).unwrap();
|
let mut db = umanux::UserDBLocal::load_files(mf).unwrap();
|
||||||
|
|
||||||
let user_res: Result<adduser::User, adduser::UserLibError> = db.delete_user(
|
let user_res: Result<umanux::User, umanux::UserLibError> = db.delete_user(
|
||||||
adduser::api::DeleteUserArgs::builder()
|
umanux::api::DeleteUserArgs::builder()
|
||||||
.username("teste")
|
.username("teste")
|
||||||
// .delete_home(adduser::api::DeleteHome::Delete)
|
// .delete_home(umanux::api::DeleteHome::Delete)
|
||||||
.build()
|
.build()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
extern crate adduser;
|
extern crate umanux;
|
||||||
use adduser::api::UserDBRead;
|
use umanux::api::UserDBRead;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
simplelog::CombinedLogger::init(vec![simplelog::TermLogger::new(
|
simplelog::CombinedLogger::init(vec![simplelog::TermLogger::new(
|
||||||
@ -9,7 +9,7 @@ fn main() {
|
|||||||
)])
|
)])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let db = adduser::UserDBLocal::load_files(adduser::Files::default()).unwrap();
|
let db = umanux::UserDBLocal::load_files(umanux::Files::default()).unwrap();
|
||||||
|
|
||||||
for u in db.get_all_users() {
|
for u in db.get_all_users() {
|
||||||
println!("{}", u);
|
println!("{}", u);
|
||||||
|
@ -106,9 +106,9 @@ impl NewFromString for Group {
|
|||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```
|
/// ```
|
||||||
/// use crate::adduser::api::GroupRead;
|
/// use crate::umanux::api::GroupRead;
|
||||||
/// use adduser::NewFromString;
|
/// use umanux::NewFromString;
|
||||||
/// let grp = adduser::Group::new_from_string(
|
/// let grp = umanux::Group::new_from_string(
|
||||||
/// "teste:x:1002:test,teste".to_owned(),
|
/// "teste:x:1002:test,teste".to_owned(),
|
||||||
/// 0,
|
/// 0,
|
||||||
/// ).unwrap();
|
/// ).unwrap();
|
||||||
|
@ -73,9 +73,9 @@ impl NewFromString for User {
|
|||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```
|
/// ```
|
||||||
/// use crate::adduser::api::UserRead;
|
/// use crate::umanux::api::UserRead;
|
||||||
/// use adduser::NewFromString;
|
/// use umanux::NewFromString;
|
||||||
/// let pwd = adduser::User::new_from_string(
|
/// let pwd = umanux::User::new_from_string(
|
||||||
/// "testuser:testpassword:1001:1001:full Name,,,,:/home/test:/bin/test".to_string(), 0).unwrap();
|
/// "testuser:testpassword:1001:1001:full Name,,,,:/home/test:/bin/test".to_string(), 0).unwrap();
|
||||||
/// assert_eq!(pwd.get_username().unwrap(), "testuser");
|
/// assert_eq!(pwd.get_username().unwrap(), "testuser");
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -88,8 +88,8 @@ impl NewFromString for Shadow {
|
|||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```
|
/// ```
|
||||||
/// use adduser::NewFromString;
|
/// use umanux::NewFromString;
|
||||||
/// let shad = adduser::Shadow::new_from_string(
|
/// let shad = umanux::Shadow::new_from_string(
|
||||||
/// "test:!!$6$/RotIe4VZzzAun4W$7YUONvru1rDnllN5TvrnOMsWUD5wSDUPAD6t6/Xwsr/0QOuWF3HcfAhypRkGa8G1B9qqWV5kZSnCb8GKMN9N61:18260:0:99999:7:::".to_string(),
|
/// "test:!!$6$/RotIe4VZzzAun4W$7YUONvru1rDnllN5TvrnOMsWUD5wSDUPAD6t6/Xwsr/0QOuWF3HcfAhypRkGa8G1B9qqWV5kZSnCb8GKMN9N61:18260:0:99999:7:::".to_string(),
|
||||||
/// 0,
|
/// 0,
|
||||||
/// ).unwrap();
|
/// ).unwrap();
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
extern crate adduser;
|
|
||||||
extern crate test_bin;
|
extern crate test_bin;
|
||||||
|
extern crate umanux;
|
||||||
mod testfiles;
|
mod testfiles;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_create_user_function() {
|
fn test_create_user_function() {
|
||||||
use testfiles::Fixture;
|
use testfiles::Fixture;
|
||||||
|
|
||||||
use adduser::api::UserDBWrite;
|
|
||||||
use adduser::api::UserRead;
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
use umanux::api::UserDBWrite;
|
||||||
|
use umanux::api::UserRead;
|
||||||
|
|
||||||
let p = Fixture::copy("passwd");
|
let p = Fixture::copy("passwd");
|
||||||
let s = Fixture::copy("shadow");
|
let s = Fixture::copy("shadow");
|
||||||
@ -16,18 +16,18 @@ fn test_create_user_function() {
|
|||||||
|
|
||||||
let pf = fs::read_to_string(&p.path).unwrap();
|
let pf = fs::read_to_string(&p.path).unwrap();
|
||||||
|
|
||||||
let mf = adduser::Files {
|
let mf = umanux::Files {
|
||||||
passwd: Some(p.path.clone()),
|
passwd: Some(p.path.clone()),
|
||||||
shadow: Some(s.path),
|
shadow: Some(s.path),
|
||||||
group: Some(g.path),
|
group: Some(g.path),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut db = adduser::UserDBLocal::load_files(mf).unwrap();
|
let mut db = umanux::UserDBLocal::load_files(mf).unwrap();
|
||||||
|
|
||||||
let user_res: Result<&adduser::User, adduser::UserLibError> = db.new_user(
|
let user_res: Result<&umanux::User, umanux::UserLibError> = db.new_user(
|
||||||
adduser::api::CreateUserArgs::builder()
|
umanux::api::CreateUserArgs::builder()
|
||||||
.username("test2")
|
.username("test2")
|
||||||
// .delete_home(adduser::api::DeleteHome::Delete)
|
// .delete_home(umanux::api::DeleteHome::Delete)
|
||||||
.build()
|
.build()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
extern crate adduser;
|
extern crate umanux;
|
||||||
mod testfiles;
|
mod testfiles;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_delete_user_function() {
|
fn test_delete_user_function() {
|
||||||
use testfiles::Fixture;
|
use testfiles::Fixture;
|
||||||
|
|
||||||
use adduser::api::UserDBWrite;
|
|
||||||
use adduser::api::UserRead;
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
use umanux::api::UserDBWrite;
|
||||||
|
use umanux::api::UserRead;
|
||||||
|
|
||||||
let p = Fixture::copy("passwd");
|
let p = Fixture::copy("passwd");
|
||||||
let s = Fixture::copy("shadow");
|
let s = Fixture::copy("shadow");
|
||||||
@ -15,18 +15,18 @@ fn test_delete_user_function() {
|
|||||||
|
|
||||||
let pf = fs::read_to_string(&p.path).unwrap();
|
let pf = fs::read_to_string(&p.path).unwrap();
|
||||||
|
|
||||||
let mf = adduser::Files {
|
let mf = umanux::Files {
|
||||||
passwd: Some(p.path.clone()),
|
passwd: Some(p.path.clone()),
|
||||||
shadow: Some(s.path),
|
shadow: Some(s.path),
|
||||||
group: Some(g.path),
|
group: Some(g.path),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut db = adduser::UserDBLocal::load_files(mf).unwrap();
|
let mut db = umanux::UserDBLocal::load_files(mf).unwrap();
|
||||||
|
|
||||||
let user_res: Result<adduser::User, adduser::UserLibError> = db.delete_user(
|
let user_res: Result<umanux::User, umanux::UserLibError> = db.delete_user(
|
||||||
adduser::api::DeleteUserArgs::builder()
|
umanux::api::DeleteUserArgs::builder()
|
||||||
.username("teste")
|
.username("teste")
|
||||||
// .delete_home(adduser::api::DeleteHome::Delete)
|
// .delete_home(umanux::api::DeleteHome::Delete)
|
||||||
.build()
|
.build()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user