Merge branch 'libredox' into 'master'
Switch to libredox See merge request redox-os/userutils!43
This commit is contained in:
Generated
+185
-43
@@ -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,31 @@ 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",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libredox"
|
||||
version = "0.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3af92c55d7d839293953fcd0fda5ecfe93297cfde6ffbdec13b41d99c0ba6607"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "numtoa"
|
||||
@@ -159,74 +187,94 @@ checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef"
|
||||
|
||||
[[package]]
|
||||
name = "orbclient"
|
||||
version = "0.3.46"
|
||||
version = "0.3.47"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8378ac0dfbd4e7895f2d2c1f1345cab3836910baf3a300b000d04250f0c8428f"
|
||||
checksum = "52f0d54bde9774d3a51dcf281a5def240c71996bc6ca05d2c847ec8b2b216166"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"redox_syscall 0.3.5",
|
||||
"libredox 0.0.2",
|
||||
"sdl2",
|
||||
"sdl2-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox-daemon"
|
||||
version = "0.1.1"
|
||||
name = "proc-macro2"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "811fd0d382a70c9e9192166ee794567b65ef34cc7309c86a49b071779ca9b5f3"
|
||||
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.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "353178b5771a301b9d2b318914ab5dfeb21dd6e65930faedde19248cfceca5a7"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"redox_syscall 0.3.5",
|
||||
"libredox 0.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_event"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b78fedc17aea72caee38ac1208e0f709fa1641af1bbe0205e7d434413a60621d"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"libredox 0.0.1",
|
||||
"redox_syscall",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_liner"
|
||||
version = "0.5.1"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f014f6b014591f45bdd86377ab2f01b840ddd9e33421222b84d06e244b111327"
|
||||
checksum = "63c3dc5996de1508c9dad60461f6a5b9611d9c31610c29d3ff4ec97df408671c"
|
||||
dependencies = [
|
||||
"bytecount",
|
||||
"itertools",
|
||||
"strip-ansi-escapes",
|
||||
"termion",
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.16"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
|
||||
checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
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_termios"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8440d8acb4fd3d277125b4bd01a6f38aee8d814b3b5fc09b3f2b825d37d3fe8f"
|
||||
dependencies = [
|
||||
"redox_syscall 0.2.16",
|
||||
]
|
||||
checksum = "20145670ba436b55d91fc92d25e71160fbfbdd57831631c8d7d36377a476f1cb"
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.4.0"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
|
||||
checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"redox_syscall 0.2.16",
|
||||
"libredox 0.0.1",
|
||||
"rust-argon2",
|
||||
"thiserror",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -247,7 +295,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",
|
||||
@@ -264,6 +312,15 @@ dependencies = [
|
||||
"version-compare",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strip-ansi-escapes"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "011cbb39cf7c1f62871aea3cc46e5817b0937b49e9447370c93cacbe93a766d8"
|
||||
dependencies = [
|
||||
"vte",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.8.0"
|
||||
@@ -271,14 +328,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
|
||||
[[package]]
|
||||
name = "termion"
|
||||
version = "1.5.6"
|
||||
name = "syn"
|
||||
version = "2.0.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "077185e2eac69c3f8379a4298e1e07cd36beb962290d4a51199acf0fdc10607e"
|
||||
checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termion"
|
||||
version = "2.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4648c7def6f2043b2568617b9f9b75eae88ca185dbc1f1fda30e95a85d49d7d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"libredox 0.0.2",
|
||||
"numtoa",
|
||||
"redox_syscall 0.2.16",
|
||||
"redox_termios",
|
||||
]
|
||||
|
||||
@@ -292,10 +360,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"
|
||||
@@ -303,15 +397,22 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"extra",
|
||||
"libredox 0.0.2",
|
||||
"orbclient",
|
||||
"redox-daemon",
|
||||
"redox_event",
|
||||
"redox_liner",
|
||||
"redox_syscall 0.3.5",
|
||||
"redox_termios",
|
||||
"redox_users",
|
||||
"termion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.2"
|
||||
@@ -324,6 +425,27 @@ version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29"
|
||||
|
||||
[[package]]
|
||||
name = "vte"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6cbce692ab4ca2f1f3047fcf732430249c0e971bfdd2b234cf2c47ad93af5983"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"utf8parse",
|
||||
"vte_generate_state_changes",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vte_generate_state_changes"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d257817081c7dffcdbab24b9e62d2def62e2ff7d00b1c20062551e6cccc145ff"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
@@ -351,3 +473,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",
|
||||
]
|
||||
|
||||
+8
-7
@@ -53,13 +53,14 @@ path = "src/bin/usermod.rs"
|
||||
[dependencies]
|
||||
clap = "2.33.0"
|
||||
extra = { git = "https://gitlab.redox-os.org/redox-os/libextra.git" }
|
||||
orbclient = "0.3.45"
|
||||
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
|
||||
termion = "1.5.6"
|
||||
orbclient = "0.3.47"
|
||||
redox-daemon = "0.1.2"
|
||||
redox_liner = "0.5.2"
|
||||
libredox = "0.0.2"
|
||||
redox_termios = "0.1.3"
|
||||
redox_event = "0.2"
|
||||
redox_users = "0.4.4"
|
||||
termion = "2.0.3"
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
|
||||
+46
-62
@@ -1,21 +1,24 @@
|
||||
#[macro_use]
|
||||
extern crate clap;
|
||||
extern crate extra;
|
||||
extern crate libredox;
|
||||
extern crate orbclient;
|
||||
extern crate redox_termios;
|
||||
extern crate syscall;
|
||||
extern crate event;
|
||||
|
||||
use std::fs::{File, OpenOptions};
|
||||
use std::io::{self, ErrorKind, Read, Stderr, Write};
|
||||
use std::io::{self, ErrorKind, Stderr};
|
||||
use std::process::{Child, Command, Stdio};
|
||||
use std::str;
|
||||
|
||||
use std::os::unix::io::{FromRawFd, RawFd};
|
||||
|
||||
use event::{EventFlags, RawEventQueue};
|
||||
use libredox::errno::EAGAIN;
|
||||
use orbclient::{Event, EventOption};
|
||||
|
||||
use extra::io::fail;
|
||||
use syscall::O_RDONLY;
|
||||
use libredox::flag::{O_RDONLY, self};
|
||||
use libredox::call as redox;
|
||||
|
||||
const _MAN_PAGE: &'static str = /* @MANSTART{getty} */
|
||||
r#"
|
||||
@@ -119,7 +122,7 @@ fn process_events(ctrl: &mut bool, events: &[Event]) -> Vec<u8> {
|
||||
}
|
||||
|
||||
pub fn handle(
|
||||
event_file: &mut File,
|
||||
event_queue: &mut RawEventQueue,
|
||||
tty_fd: RawFd,
|
||||
consumer_fd: Option<RawFd>,
|
||||
master_fd: RawFd,
|
||||
@@ -134,28 +137,28 @@ pub fn handle(
|
||||
if event_id as RawFd == tty_fd {
|
||||
let mut packet = [0; 4096];
|
||||
loop {
|
||||
let count = match syscall::read(tty_fd as usize, &mut packet) {
|
||||
let count = match redox::read(tty_fd as usize, &mut packet) {
|
||||
Ok(0) => return,
|
||||
Ok(count) => count,
|
||||
Err(ref err) if err.errno == syscall::EAGAIN => break,
|
||||
Err(ref err) if err.errno == EAGAIN => break,
|
||||
Err(_) => panic!("getty: failed to read from TTY"),
|
||||
};
|
||||
syscall::write(master_fd as usize, &packet[..count])
|
||||
redox::write(master_fd as usize, &packet[..count])
|
||||
.expect("getty: failed to write master PTY");
|
||||
}
|
||||
} else if event_id as RawFd == master_fd {
|
||||
let mut packet = [0; 4096];
|
||||
loop {
|
||||
let count = match syscall::read(master_fd as usize, &mut packet) {
|
||||
let count = match redox::read(master_fd as usize, &mut packet) {
|
||||
Ok(0) => return,
|
||||
Ok(count) => count,
|
||||
Err(ref err) if err.errno == syscall::EAGAIN => break,
|
||||
Err(ref err) if err.errno == EAGAIN => break,
|
||||
Err(_) => panic!("getty: failed to read from master TTY"),
|
||||
};
|
||||
syscall::write(tty_fd as usize, &packet[1..count])
|
||||
redox::write(tty_fd as usize, &packet[1..count])
|
||||
.expect("getty: failed to write to TTY");
|
||||
if packet[0] & 1 == 1 {
|
||||
let _ = syscall::fsync(tty_fd as usize);
|
||||
let _ = redox::fsync(tty_fd as usize);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -166,10 +169,10 @@ pub fn handle(
|
||||
|
||||
let mut packet = [0; 4096];
|
||||
loop {
|
||||
let count = match syscall::read(consumer_fd as usize, &mut packet) {
|
||||
let count = match redox::read(consumer_fd as usize, &mut packet) {
|
||||
Ok(0) => return,
|
||||
Ok(count) => count,
|
||||
Err(ref err) if err.errno == syscall::EAGAIN => break,
|
||||
Err(ref err) if err.errno == EAGAIN => break,
|
||||
Err(_) => panic!("getty: failed to read from master TTY"),
|
||||
};
|
||||
|
||||
@@ -181,11 +184,11 @@ pub fn handle(
|
||||
};
|
||||
|
||||
let buf = process_events(&mut ctrl, events);
|
||||
syscall::write(master_fd as usize, buf.as_slice())
|
||||
redox::write(master_fd as usize, buf.as_slice())
|
||||
.expect("getty: failed to write to TTY");
|
||||
|
||||
if packet[0] & 1 == 1 {
|
||||
let _ = syscall::fsync(tty_fd as usize);
|
||||
let _ = redox::fsync(tty_fd as usize);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -202,11 +205,10 @@ pub fn handle(
|
||||
}
|
||||
|
||||
'events: loop {
|
||||
let mut sys_event = syscall::Event::default();
|
||||
event_file
|
||||
.read(&mut sys_event)
|
||||
let sys_event = event_queue
|
||||
.next().expect("getty: event queue stopped")
|
||||
.expect("getty: failed to read event file");
|
||||
handle_event(sys_event.id);
|
||||
handle_event(sys_event.fd);
|
||||
|
||||
match process.try_wait() {
|
||||
Ok(status) => match status {
|
||||
@@ -225,25 +227,26 @@ pub fn handle(
|
||||
}
|
||||
|
||||
pub fn getpty(columns: u32, lines: u32) -> (RawFd, String) {
|
||||
let master = syscall::open(
|
||||
let master = redox::open(
|
||||
"pty:",
|
||||
syscall::O_CLOEXEC | syscall::O_RDWR | syscall::O_CREAT | syscall::O_NONBLOCK,
|
||||
flag::O_CLOEXEC | flag::O_RDWR | flag::O_CREAT | flag::O_NONBLOCK,
|
||||
0,
|
||||
)
|
||||
.expect("getty: failed to create PTY");
|
||||
|
||||
if let Ok(winsize_fd) = syscall::dup(master, b"winsize") {
|
||||
let _ = syscall::write(
|
||||
if let Ok(winsize_fd) = redox::dup(master, b"winsize") {
|
||||
let _ = redox::write(
|
||||
winsize_fd,
|
||||
&redox_termios::Winsize {
|
||||
ws_row: lines as u16,
|
||||
ws_col: columns as u16,
|
||||
},
|
||||
);
|
||||
let _ = syscall::close(winsize_fd);
|
||||
let _ = redox::close(winsize_fd);
|
||||
}
|
||||
|
||||
let mut buf: [u8; 4096] = [0; 4096];
|
||||
let count = syscall::fpath(master, &mut buf).unwrap();
|
||||
let count = redox::fpath(master, &mut buf).unwrap();
|
||||
(master as RawFd, unsafe {
|
||||
String::from_utf8_unchecked(Vec::from(&buf[..count]))
|
||||
})
|
||||
@@ -252,7 +255,7 @@ pub fn getpty(columns: u32, lines: u32) -> (RawFd, String) {
|
||||
fn daemon(tty_fd: RawFd, consumer_fd: Option<RawFd>, clear: bool, stderr: &mut Stderr) {
|
||||
let (columns, lines) = {
|
||||
let mut path = [0; 4096];
|
||||
if let Ok(count) = syscall::fpath(tty_fd as usize, &mut path) {
|
||||
if let Ok(count) = redox::fpath(tty_fd as usize, &mut path) {
|
||||
let path_str = str::from_utf8(&path[..count]).unwrap_or("");
|
||||
let reference = path_str.split(':').nth(1).unwrap_or("");
|
||||
let mut parts = reference.split('/').skip(1);
|
||||
@@ -266,49 +269,29 @@ fn daemon(tty_fd: RawFd, consumer_fd: Option<RawFd>, clear: bool, stderr: &mut S
|
||||
|
||||
let (master_fd, pty) = getpty(columns, lines);
|
||||
|
||||
let mut event_file = OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.open("event:")
|
||||
.expect("getty: failed to open event file");
|
||||
let mut event_queue = event::RawEventQueue::new().expect("getty: failed to open event queue");
|
||||
|
||||
if let Some(consumer_fd) = consumer_fd {
|
||||
event_file
|
||||
.write(&syscall::Event {
|
||||
id: consumer_fd as usize,
|
||||
flags: syscall::flag::EVENT_READ,
|
||||
data: 0,
|
||||
})
|
||||
.expect("getty: failed to fevent TTY");
|
||||
event_queue.subscribe(consumer_fd as usize, 0, EventFlags::READ).expect("getty: failed to fevent TTY");
|
||||
}
|
||||
|
||||
event_file
|
||||
.write(&syscall::Event {
|
||||
id: tty_fd as usize,
|
||||
flags: syscall::flag::EVENT_READ,
|
||||
data: 0,
|
||||
})
|
||||
.expect("getty: failed to fevent TTY");
|
||||
event_queue.subscribe(tty_fd as usize, 0, EventFlags::READ).expect("getty: failed to fevent TTY");
|
||||
|
||||
event_file
|
||||
.write(&syscall::Event {
|
||||
id: master_fd as usize,
|
||||
flags: syscall::flag::EVENT_READ,
|
||||
data: 0,
|
||||
})
|
||||
event_queue
|
||||
.subscribe(master_fd as usize, 0, EventFlags::READ)
|
||||
.expect("getty: failed to fevent master PTY");
|
||||
|
||||
loop {
|
||||
if clear {
|
||||
let _ = syscall::write(tty_fd as usize, b"\x1Bc");
|
||||
let _ = redox::write(tty_fd as usize, b"\x1Bc");
|
||||
}
|
||||
let _ = syscall::fsync(tty_fd as usize);
|
||||
let _ = redox::fsync(tty_fd as usize);
|
||||
|
||||
let slave_stdin = syscall::open(&pty, syscall::O_CLOEXEC | syscall::O_RDONLY)
|
||||
let slave_stdin = redox::open(&pty, flag::O_CLOEXEC | flag::O_RDONLY, 0)
|
||||
.expect("getty: failed to open slave stdin");
|
||||
let slave_stdout = syscall::open(&pty, syscall::O_CLOEXEC | syscall::O_WRONLY)
|
||||
let slave_stdout = redox::open(&pty, flag::O_CLOEXEC | flag::O_WRONLY, 0)
|
||||
.expect("getty: failed to open slave stdout");
|
||||
let slave_stderr = syscall::open(&pty, syscall::O_CLOEXEC | syscall::O_WRONLY)
|
||||
let slave_stderr = redox::open(&pty, flag::O_CLOEXEC | flag::O_WRONLY, 0)
|
||||
.expect("getty: failed to open slave stderr");
|
||||
|
||||
let mut command = Command::new("login");
|
||||
@@ -326,7 +309,7 @@ fn daemon(tty_fd: RawFd, consumer_fd: Option<RawFd>, clear: bool, stderr: &mut S
|
||||
match command.spawn() {
|
||||
Ok(mut process) => {
|
||||
handle(
|
||||
&mut event_file,
|
||||
&mut event_queue,
|
||||
tty_fd,
|
||||
consumer_fd,
|
||||
master_fd,
|
||||
@@ -355,10 +338,10 @@ pub fn main() {
|
||||
|
||||
let mut buf = [0; 1024];
|
||||
let (vt_path, consumer) = if vt.parse::<usize>().is_ok() {
|
||||
let consumer = syscall::open(format!("input:consumer/{vt}"), O_RDONLY)
|
||||
let consumer = redox::open(format!("input:consumer/{vt}"), O_RDONLY, 0)
|
||||
.expect("getty: failed to open consumer");
|
||||
|
||||
let written = syscall::fpath(consumer, &mut buf).expect("getty: failed to get the display");
|
||||
let written = redox::fpath(consumer, &mut buf).expect("getty: failed to get the display");
|
||||
assert!(written <= buf.len());
|
||||
|
||||
(
|
||||
@@ -370,9 +353,10 @@ pub fn main() {
|
||||
(vt, None)
|
||||
};
|
||||
|
||||
let tty_fd = match syscall::open(
|
||||
let tty_fd = match redox::open(
|
||||
vt_path,
|
||||
syscall::O_CLOEXEC | syscall::flag::O_RDWR | syscall::flag::O_NONBLOCK,
|
||||
flag::O_CLOEXEC | flag::O_RDWR | flag::O_NONBLOCK,
|
||||
0,
|
||||
) {
|
||||
Ok(fd) => fd,
|
||||
Err(err) => fail(
|
||||
|
||||
+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
@@ -54,7 +54,7 @@ pub fn main() {
|
||||
loop {
|
||||
let user = liner::Context::new()
|
||||
.read_line(
|
||||
"\x1B[1mredox login:\x1B[0m ",
|
||||
liner::Prompt::from("\x1B[1mredox login:\x1B[0m "),
|
||||
None,
|
||||
&mut liner::BasicCompleter::new(Vec::<String>::new())
|
||||
)
|
||||
|
||||
+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") {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
extern crate extra;
|
||||
extern crate syscall;
|
||||
extern crate termion;
|
||||
extern crate redox_users;
|
||||
|
||||
|
||||
+6
-6
@@ -1,14 +1,13 @@
|
||||
#[macro_use]
|
||||
extern crate clap;
|
||||
extern crate extra;
|
||||
extern crate syscall;
|
||||
extern crate redox_users;
|
||||
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 +113,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 +160,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 +190,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);
|
||||
}
|
||||
|
||||
+7
-8
@@ -17,14 +17,14 @@
|
||||
//! - `whoami`: Display effective user ID.
|
||||
|
||||
extern crate redox_users;
|
||||
extern crate syscall;
|
||||
extern crate libredox;
|
||||
|
||||
use std::io::Result as IoResult;
|
||||
|
||||
use redox_users::{auth, All, AllGroups, Result, User, UsersError};
|
||||
use syscall::call::{open, fchmod, fchown};
|
||||
use syscall::error::Result as SysResult;
|
||||
use syscall::flag::{O_CREAT, O_DIRECTORY, O_CLOEXEC};
|
||||
use redox_users::{auth, All, AllGroups, Result, User, Error};
|
||||
use libredox::call::{open, fchown};
|
||||
use libredox::error::Result as SysResult;
|
||||
use libredox::flag::{O_CREAT, O_DIRECTORY, O_CLOEXEC};
|
||||
|
||||
const DEFAULT_MODE: u16 = 0o700;
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
@@ -89,8 +89,7 @@ pub fn spawn_shell(user: &User<auth::Full>) -> IoResult<i32> {
|
||||
pub fn create_user_dir<T>(user: &User<auth::Full>, dir: T) -> SysResult<()>
|
||||
where T: AsRef<str> + std::convert::AsRef<[u8]>
|
||||
{
|
||||
let fd = open(dir, O_CREAT | O_DIRECTORY | O_CLOEXEC)?;
|
||||
fchmod(fd, DEFAULT_MODE)?;
|
||||
let fd = open(dir, O_CREAT | O_DIRECTORY | O_CLOEXEC, DEFAULT_MODE)?;
|
||||
fchown(fd, user.uid as u32, user.gid as u32)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user