Update redox_users.
This commit is contained in:
Generated
+117
-15
@@ -46,6 +46,12 @@ version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
|
||||
|
||||
[[package]]
|
||||
name = "blake2b_simd"
|
||||
version = "0.5.11"
|
||||
@@ -59,9 +65,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bytecount"
|
||||
version = "0.6.3"
|
||||
version = "0.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c"
|
||||
checksum = "e1e5f035d16fc623ae5f74981db80a439803888314e3a555fd6f04acd51a3205"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
@@ -77,7 +83,7 @@ checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"atty",
|
||||
"bitflags",
|
||||
"bitflags 1.3.2",
|
||||
"strsim",
|
||||
"textwrap",
|
||||
"unicode-width",
|
||||
@@ -147,9 +153,20 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.147"
|
||||
version = "0.2.149"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
|
||||
checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b"
|
||||
|
||||
[[package]]
|
||||
name = "libredox"
|
||||
version = "0.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"libc",
|
||||
"redox_syscall 0.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "numtoa"
|
||||
@@ -169,6 +186,24 @@ dependencies = [
|
||||
"sdl2-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox-daemon"
|
||||
version = "0.1.1"
|
||||
@@ -197,7 +232,7 @@ version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 1.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -206,7 +241,16 @@ version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 1.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -220,13 +264,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
|
||||
version = "0.4.3"
|
||||
source = "git+https://gitlab.redox-os.org/redox-os/users.git#06755b3ca678043d76c784c8e0659669ff3045c7"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"redox_syscall 0.2.16",
|
||||
"libredox",
|
||||
"rust-argon2",
|
||||
"thiserror",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -247,7 +292,7 @@ version = "0.35.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7959277b623f1fb9e04aea73686c3ca52f01b2145f8ea16f4ff30d8b7623b1a"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 1.3.2",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"sdl2-sys",
|
||||
@@ -270,6 +315,17 @@ version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termion"
|
||||
version = "1.5.6"
|
||||
@@ -292,10 +348,36 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.10"
|
||||
name = "thiserror"
|
||||
version = "1.0.50"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
|
||||
checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.50"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
|
||||
|
||||
[[package]]
|
||||
name = "userutils"
|
||||
@@ -351,3 +433,23 @@ name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "zeroize"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9"
|
||||
dependencies = [
|
||||
"zeroize_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zeroize_derive"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ redox-daemon = "0.1.1"
|
||||
redox_liner = "0.5.1"
|
||||
redox_syscall = "0.3"
|
||||
redox_termios = "0.1.2"
|
||||
redox_users = "=0.4.0" # TODO: Update
|
||||
redox_users = { git = "https://gitlab.redox-os.org/redox-os/users.git" }
|
||||
termion = "1.5.6"
|
||||
|
||||
[profile.release]
|
||||
|
||||
+6
-5
@@ -7,7 +7,7 @@ use extra::option::OptionalExt;
|
||||
|
||||
use std::process::exit;
|
||||
|
||||
use redox_users::{All, AllGroups, Config, UsersError};
|
||||
use redox_users::{All, AllGroups, Config, Error, GroupBuilder};
|
||||
|
||||
const _MAN_PAGE: &'static str = /* @MANSTART{groupadd} */ r#"
|
||||
NAME
|
||||
@@ -48,7 +48,7 @@ fn main() {
|
||||
(@arg GID: -g --gid +takes_value "Group id. Positive integer and must not be in use")
|
||||
).get_matches();
|
||||
|
||||
let mut sys_groups = AllGroups::new(Config::default()).unwrap_or_exit(1);
|
||||
let mut sys_groups = AllGroups::new(Config::default().writeable(true)).unwrap_or_exit(1);
|
||||
|
||||
let groupname = args.value_of("GROUP").unwrap();
|
||||
|
||||
@@ -67,9 +67,10 @@ fn main() {
|
||||
})
|
||||
};
|
||||
|
||||
match sys_groups.add_group(groupname, gid, &[""]) {
|
||||
Ok(_) => { },
|
||||
Err(ref err) if err.downcast_ref::<UsersError>() == Some(&UsersError::AlreadyExists) && args.is_present("FORCE") => {
|
||||
let group = GroupBuilder::new(groupname).gid(gid);
|
||||
match sys_groups.add_group(group) {
|
||||
Ok(_) => (),
|
||||
Err(Error::GroupAlreadyExists) if args.is_present("FORCE") => {
|
||||
exit(0);
|
||||
},
|
||||
Err(err) => {
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ fn main() {
|
||||
|
||||
let group = matches.value_of("GROUP").unwrap();
|
||||
|
||||
let mut sys_groups = AllGroups::new(Config::default()).unwrap_or_exit(1);
|
||||
let mut sys_groups = AllGroups::new(Config::default().writeable(true)).unwrap_or_exit(1);
|
||||
|
||||
sys_groups.remove_by_name(group.to_string());
|
||||
|
||||
|
||||
+2
-2
@@ -51,7 +51,7 @@ fn main() {
|
||||
|
||||
let groupname = args.value_of("GROUP").unwrap();
|
||||
|
||||
let mut sys_groups = AllGroups::new(Config::default()).unwrap_or_exit(1);
|
||||
let mut sys_groups = AllGroups::new(Config::default().writeable(true)).unwrap_or_exit(1);
|
||||
{
|
||||
let group = sys_groups
|
||||
.get_mut_by_name(groupname)
|
||||
@@ -63,7 +63,7 @@ fn main() {
|
||||
if let Some(gid) = args.value_of("GID") {
|
||||
let gid = gid.parse::<usize>().unwrap_or_exit(1);
|
||||
// Update users
|
||||
let mut sys_users = AllUsers::authenticator(Config::default()).unwrap_or_exit(1);
|
||||
let mut sys_users = AllUsers::authenticator(Config::default().writeable(true)).unwrap_or_exit(1);
|
||||
for user in sys_users.iter_mut() {
|
||||
if user.gid == group.gid {
|
||||
user.gid = gid;
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ fn main() {
|
||||
).get_matches();
|
||||
|
||||
let uid = get_uid().unwrap_or_exit(1);
|
||||
let mut users = AllUsers::authenticator(Config::default()).unwrap_or_exit(1);
|
||||
let mut users = AllUsers::authenticator(Config::default().writeable(true)).unwrap_or_exit(1);
|
||||
|
||||
{
|
||||
let user = match args.value_of("LOGIN") {
|
||||
|
||||
+6
-5
@@ -8,7 +8,7 @@ extern crate userutils;
|
||||
use std::process::exit;
|
||||
|
||||
use extra::option::OptionalExt;
|
||||
use redox_users::{All, AllGroups, AllUsers, Config};
|
||||
use redox_users::{All, AllGroups, AllUsers, Config, GroupBuilder, UserBuilder};
|
||||
use userutils::create_user_dir;
|
||||
|
||||
const _MAN_PAGE: &'static str = /* @MANSTART{useradd} */ r#"
|
||||
@@ -114,8 +114,8 @@ fn main() {
|
||||
// unwrap is safe because of "+required". clap-rs is cool...
|
||||
let login = args.value_of("LOGIN").unwrap();
|
||||
|
||||
let mut sys_users = AllUsers::authenticator(Config::default()).unwrap_or_exit(1);
|
||||
let mut sys_groups = AllGroups::new(Config::default()).unwrap_or_exit(1);
|
||||
let mut sys_users = AllUsers::authenticator(Config::default().writeable(true)).unwrap_or_exit(1);
|
||||
let mut sys_groups = AllGroups::new(Config::default().writeable(true)).unwrap_or_exit(1);
|
||||
|
||||
let uid = match args.value_of("UID") {
|
||||
Some(uid) => {
|
||||
@@ -161,7 +161,7 @@ fn main() {
|
||||
})
|
||||
};
|
||||
sys_groups
|
||||
.add_group(login, id, &[login])
|
||||
.add_group(GroupBuilder::new(login).gid(id).user(login))
|
||||
.unwrap_or_else(|err| {
|
||||
eprintln!("useradd: {}: {}", err, login);
|
||||
exit(1);
|
||||
@@ -191,8 +191,9 @@ fn main() {
|
||||
.value_of("SHELL")
|
||||
.unwrap_or(DEFAULT_SHELL);
|
||||
|
||||
let user = UserBuilder::new(login).uid(uid).gid(gid).name(gecos).home(userhome).shell(shell);
|
||||
sys_users
|
||||
.add_user(login, uid, gid, gecos, userhome, shell)
|
||||
.add_user(user)
|
||||
.unwrap_or_else(|err| {
|
||||
eprintln!("useradd: {}: {}", err, login);
|
||||
exit(1);
|
||||
|
||||
+2
-2
@@ -48,8 +48,8 @@ fn main() {
|
||||
|
||||
let login = args.value_of("LOGIN").unwrap();
|
||||
|
||||
let mut sys_users = AllUsers::authenticator(Config::default()).unwrap_or_exit(1);
|
||||
let mut sys_groups = AllGroups::new(Config::default()).unwrap_or_exit(1);
|
||||
let mut sys_users = AllUsers::authenticator(Config::default().writeable(true)).unwrap_or_exit(1);
|
||||
let mut sys_groups = AllGroups::new(Config::default().writeable(true)).unwrap_or_exit(1);
|
||||
{
|
||||
sys_groups.remove_user_from_all_groups(login);
|
||||
|
||||
|
||||
+3
-3
@@ -119,18 +119,18 @@ fn main() {
|
||||
let login = args.value_of("LOGIN").unwrap();
|
||||
|
||||
//TODO: Does not always need shadowfile access
|
||||
let mut sys_users = AllUsers::authenticator(Config::default()).unwrap_or_exit(1);
|
||||
let mut sys_users = AllUsers::authenticator(Config::default().writeable(true)).unwrap_or_exit(1);
|
||||
let mut sys_groups;
|
||||
|
||||
if let Some(new_groups) = args.value_of("SET_GROUPS") {
|
||||
sys_groups = AllGroups::new(Config::default()).unwrap_or_exit(1);
|
||||
sys_groups = AllGroups::new(Config::default().writeable(true)).unwrap_or_exit(1);
|
||||
sys_groups.remove_user_from_all_groups(login);
|
||||
sys_groups.add_user_to_groups(login, new_groups.split(',').collect()).unwrap_or_exit(1);
|
||||
sys_groups.save().unwrap_or_exit(1);
|
||||
}
|
||||
|
||||
if let Some(new_groups) = args.value_of("APPEND_GROUPS") {
|
||||
sys_groups = AllGroups::new(Config::default()).unwrap_or_exit(1);
|
||||
sys_groups = AllGroups::new(Config::default().writeable(true)).unwrap_or_exit(1);
|
||||
sys_groups.add_user_to_groups(login, new_groups.split(',').collect()).unwrap_or_exit(1);
|
||||
sys_groups.save().unwrap_or_exit(1);
|
||||
}
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ extern crate syscall;
|
||||
|
||||
use std::io::Result as IoResult;
|
||||
|
||||
use redox_users::{auth, All, AllGroups, Result, User, UsersError};
|
||||
use redox_users::{auth, All, AllGroups, Result, User, Error};
|
||||
use syscall::call::{open, fchmod, fchown};
|
||||
use syscall::error::Result as SysResult;
|
||||
use syscall::flag::{O_CREAT, O_DIRECTORY, O_CLOEXEC};
|
||||
@@ -41,7 +41,7 @@ impl AllGroupsExt for AllGroups {
|
||||
for groupname in new_groups {
|
||||
let group = match self.get_mut_by_name(groupname) {
|
||||
Some(group) => group,
|
||||
None => return Err(UsersError::NotFound.into())
|
||||
None => return Err(Error::UserNotFound)
|
||||
};
|
||||
group.users.push(login.to_string());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user