Merge pull request #20 from goyox86/goyox86/better-errors
Goyox86/better errors
This commit is contained in:
Generated
+153
-14
@@ -1,7 +1,7 @@
|
||||
[[package]]
|
||||
name = "arg_parser"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/redox-os/arg-parser.git#d16e2d02e87996bbe2bce4a201c66c0df4a1e866"
|
||||
source = "git+https://github.com/redox-os/arg-parser.git#7503531821b0c111f9fac77a5d2536ea221105fe"
|
||||
|
||||
[[package]]
|
||||
name = "argon2rs"
|
||||
@@ -20,6 +20,29 @@ dependencies = [
|
||||
"nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "backtrace-sys"
|
||||
version = "0.1.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "0.7.0"
|
||||
@@ -34,16 +57,54 @@ dependencies = [
|
||||
"constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "constant_time_eq"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "dbghelp-sys"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "extra"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/redox-os/libextra.git#402932084acd5fef4812945887ceaaa2ddd5f264"
|
||||
|
||||
[[package]]
|
||||
name = "failure"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"backtrace 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "failure_derive"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fuchsia-zircon"
|
||||
version = "0.2.1"
|
||||
@@ -60,9 +121,18 @@ dependencies = [
|
||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kernel32-sys"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.33"
|
||||
version = "0.2.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
@@ -79,18 +149,23 @@ name = "nodrop"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "0.3.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.3.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.31"
|
||||
version = "0.1.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
@@ -98,31 +173,64 @@ name = "redox_termios"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/redox-os/users.git#83ea6d2c6d3ea1e3082e4bd8d15633d0f03d3137"
|
||||
source = "git+https://github.com/redox-os/users.git?branch=goyox86/failure#47a167cdf2aa64a857190274de7d1a03d43405b6"
|
||||
dependencies = [
|
||||
"argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"extra 0.1.0 (git+https://github.com/redox-os/libextra.git)",
|
||||
"redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "scoped_threadpool"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "0.11.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "synom"
|
||||
version = "0.11.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "synstructure"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termion"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@@ -131,6 +239,11 @@ name = "unicode-width"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "userutils"
|
||||
version = "0.1.0"
|
||||
@@ -140,29 +253,55 @@ dependencies = [
|
||||
"extra 0.1.0 (git+https://github.com/redox-os/libextra.git)",
|
||||
"liner 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_users 0.1.0 (git+https://github.com/redox-os/users.git)",
|
||||
"redox_users 0.1.0 (git+https://github.com/redox-os/users.git?branch=goyox86/failure)",
|
||||
"termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-build"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum arg_parser 0.1.0 (git+https://github.com/redox-os/arg-parser.git)" = "<none>"
|
||||
"checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392"
|
||||
"checksum arrayvec 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2f0ef4a9820019a0c91d918918c93dc71d469f581a49b47ddc1d285d4270bbe2"
|
||||
"checksum backtrace 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8709cc7ec06f6f0ae6c2c7e12f6ed41540781f72b488d83734978295ceae182e"
|
||||
"checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661"
|
||||
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
|
||||
"checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400"
|
||||
"checksum cc 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a9b13a57efd6b30ecd6598ebdb302cca617930b5470647570468a65d12ef9719"
|
||||
"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de"
|
||||
"checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e"
|
||||
"checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850"
|
||||
"checksum extra 0.1.0 (git+https://github.com/redox-os/libextra.git)" = "<none>"
|
||||
"checksum failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "934799b6c1de475a012a02dab0ace1ace43789ee4b99bcfbf1a2e3e8ced5de82"
|
||||
"checksum failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7cdda555bb90c9bb67a3b670a0f42de8e73f5981524123ad8578aafec8ddb8b"
|
||||
"checksum fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c0581a4e363262e52b87f59ee2afe3415361c6ec35e665924eb08afe8ff159"
|
||||
"checksum fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "43f3795b4bae048dc6123a6b972cadde2e676f9ded08aef6bb77f5f157684a82"
|
||||
"checksum libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "5ba3df4dcb460b9dfbd070d41c94c19209620c191b0340b929ce748a2bcd42d2"
|
||||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||
"checksum libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)" = "36fbc8a8929c632868295d0178dd8f63fc423fd7537ad0738372bd010b3ac9b0"
|
||||
"checksum liner 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f9e406164c25b420480023985bdf65cef366855666ad4cb12cd3eaee82dcb399"
|
||||
"checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2"
|
||||
"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
|
||||
"checksum rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)" = "6475140dfd8655aeb72e1fd4b7a1cc1c202be65d71669476e392fe62532b9edd"
|
||||
"checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509"
|
||||
"checksum redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "ab105df655884ede59d45b7070c8a65002d921461ee813a024558ca16030eea0"
|
||||
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
|
||||
"checksum redox_users 0.1.0 (git+https://github.com/redox-os/users.git)" = "<none>"
|
||||
"checksum redox_users 0.1.0 (git+https://github.com/redox-os/users.git?branch=goyox86/failure)" = "<none>"
|
||||
"checksum rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aee45432acc62f7b9a108cc054142dac51f979e69e71ddce7d6fc7adf29e817e"
|
||||
"checksum scoped_threadpool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "4ea459fe3ceff01e09534847c49860891d3ff1c12b4eb7731b67f2778fb60190"
|
||||
"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
|
||||
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
|
||||
"checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd"
|
||||
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
|
||||
"checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f"
|
||||
"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
|
||||
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
||||
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
||||
|
||||
+2
-1
@@ -46,5 +46,6 @@ liner = "0.1"
|
||||
rand = "0.3"
|
||||
redox_syscall = "0.1"
|
||||
redox_termios = "0.1"
|
||||
redox_users = { git = "https://github.com/redox-os/users.git" }
|
||||
# TODO: Change this to the master branch
|
||||
redox_users = { git = "https://github.com/redox-os/users.git", branch = "goyox86/failure" }
|
||||
termion = "1.5.1"
|
||||
|
||||
+3
-6
@@ -71,13 +71,10 @@ fn main() {
|
||||
};
|
||||
|
||||
match add_group(groupname, gid, &[""]) {
|
||||
Ok(_) => {},
|
||||
Err(ref err) if err.kind() == io::ErrorKind::AlreadyExists && parser.found("force") => {
|
||||
exit(0);
|
||||
},
|
||||
Ok(_) => { },
|
||||
Err(err) => {
|
||||
eprintln!("groupadd: {}: group {}", err, groupname);
|
||||
exit(1);
|
||||
eprintln!("groupadd: {}", err);
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+71
-25
@@ -97,8 +97,16 @@ pub fn main() {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
let egid = get_egid();
|
||||
let gid = get_gid();
|
||||
let egid = get_egid().unwrap_or_else(|err| {
|
||||
eprintln!("id: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
let gid = get_gid().unwrap_or_else(|err| {
|
||||
eprintln!("id: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
print_msg(&format!("{} {}\n", egid, gid), &mut stdout, &mut stderr);
|
||||
exit(0);
|
||||
}
|
||||
@@ -114,30 +122,44 @@ pub fn main() {
|
||||
// Display effective/real process user ID UNIX user name
|
||||
if parser.found(&'u') && parser.found(&'n') {
|
||||
// Did they pass -r? F so, we show the real
|
||||
let uid = if parser.found(&'r') {
|
||||
let uid_result = if parser.found(&'r') {
|
||||
get_uid()
|
||||
} else {
|
||||
get_euid()
|
||||
};
|
||||
|
||||
get_user_by_id(uid).map(|user| {
|
||||
print_msg(&format!("{}\n", user.user), &mut stdout, &mut stderr);
|
||||
exit(0);
|
||||
}).or_else(|| {
|
||||
fail(&format!("id: no user found for uid: {}", uid), &mut stderr)
|
||||
let uid = uid_result.unwrap_or_else(|err| {
|
||||
eprintln!("id: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
let user = get_user_by_id(uid).unwrap_or_else(|err| {
|
||||
eprintln!("id: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
print_msg(&format!("{}\n", user.user), &mut stdout, &mut stderr);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Display real user ID
|
||||
if parser.found(&'u') && parser.found(&'r') {
|
||||
let uid = get_uid();
|
||||
let uid = get_uid().unwrap_or_else(|err| {
|
||||
eprintln!("id: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
print_msg(&format!("{}\n", uid), &mut stdout, &mut stderr);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Display effective user ID
|
||||
if parser.found(&'u') {
|
||||
let euid = get_euid();
|
||||
let euid = get_euid().unwrap_or_else(|err| {
|
||||
eprintln!("id: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
print_msg(&format!("{}\n", euid), &mut stdout, &mut stderr);
|
||||
exit(0);
|
||||
}
|
||||
@@ -145,30 +167,44 @@ pub fn main() {
|
||||
// Display effective/real process group ID UNIX group name
|
||||
if parser.found(&'g') && parser.found(&'n') {
|
||||
// Did they pass -r? If so we show the real one
|
||||
let gid = if parser.found(&'r') {
|
||||
let gid_result = if parser.found(&'r') {
|
||||
get_gid()
|
||||
} else {
|
||||
get_egid()
|
||||
};
|
||||
|
||||
get_group_by_id(gid).map(|group| {
|
||||
print_msg(&format!("{}\n", group.group), &mut stdout, &mut stderr);
|
||||
exit(0);
|
||||
}).or_else(|| {
|
||||
fail(&format!("id: no group found for gid: {}", gid), &mut stderr)
|
||||
let gid = gid_result.unwrap_or_else(|err| {
|
||||
eprintln!("id: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
let group = get_group_by_id(gid).unwrap_or_else(|err| {
|
||||
eprintln!("id: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
print_msg(&format!("{}\n", group.group), &mut stdout, &mut stderr);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Display the real group ID
|
||||
if parser.found(&'g') && parser.found(&'r') {
|
||||
let gid = get_gid();
|
||||
let gid = get_gid().unwrap_or_else(|err| {
|
||||
eprintln!("id: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
print_msg(&format!("{}\n", gid), &mut stdout, &mut stderr);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Display effective group ID
|
||||
if parser.found(&'g') {
|
||||
let egid = get_egid();
|
||||
let egid = get_egid().unwrap_or_else(|err| {
|
||||
eprintln!("id: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
print_msg(&format!("{}\n", egid), &mut stdout, &mut stderr);
|
||||
exit(0);
|
||||
}
|
||||
@@ -185,15 +221,25 @@ pub fn main() {
|
||||
fail(msg, &mut stderr);
|
||||
}
|
||||
|
||||
// We get everything we can and show that
|
||||
let euid = get_euid();
|
||||
let egid = get_egid();
|
||||
let user = get_user_by_id(euid).unwrap_or_else(|| {
|
||||
fail(&format!("id: no user found for uid: {}", euid), &mut stderr);
|
||||
// We get everything we can and show
|
||||
let euid = get_euid().unwrap_or_else(|err| {
|
||||
eprintln!("id: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
let group = get_group_by_id(egid).unwrap_or_else(|| {
|
||||
fail(&format!("id: no group found for gid: {}", euid), &mut stderr);
|
||||
let egid = get_egid().unwrap_or_else(|err| {
|
||||
eprintln!("id: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
let user = get_user_by_id(euid).unwrap_or_else(|err| {
|
||||
eprintln!("id: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
let group = get_group_by_id(egid).unwrap_or_else(|err| {
|
||||
eprintln!("id: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
let msg = format!("uid={}({}) gid={}({})\n", euid, user.user, egid, group.group);
|
||||
|
||||
+13
-3
@@ -16,7 +16,7 @@ use std::str;
|
||||
use extra::option::OptionalExt;
|
||||
use arg_parser::ArgParser;
|
||||
use termion::input::TermRead;
|
||||
use redox_users::get_user_by_name;
|
||||
use redox_users::{get_user_by_name, UsersError};
|
||||
use userutils::spawn_shell;
|
||||
|
||||
const MAN_PAGE: &'static str = /* @MANSTART{login} */ r#"
|
||||
@@ -71,7 +71,17 @@ pub fn main() {
|
||||
let stdin = io::stdin();
|
||||
let mut stdin = stdin.lock();
|
||||
|
||||
let user_option = get_user_by_name(user);
|
||||
let user_option = match get_user_by_name(user) {
|
||||
Ok(user) => Some(user),
|
||||
Err(ref err) if err.downcast_ref::<UsersError>() == Some(&UsersError::NotFound) => {
|
||||
None
|
||||
},
|
||||
Err(err) => {
|
||||
println!("login: {}", err);
|
||||
exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
match user_option {
|
||||
None => {
|
||||
stdout.write(b"\nLogin incorrect\n").try(&mut stderr);
|
||||
@@ -113,4 +123,4 @@ pub fn main() {
|
||||
stdout.flush().try(&mut stderr);;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-5
@@ -57,17 +57,20 @@ fn main() {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
let uid = get_uid();
|
||||
let uid = get_uid().unwrap_or_else(|err| {
|
||||
eprintln!("passwd: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
let user = if parser.args.is_empty() {
|
||||
get_user_by_id(uid).unwrap_or_else(|| {
|
||||
eprintln!("passwd: current user id {} does not exist", uid);
|
||||
get_user_by_id(uid).unwrap_or_else(|err| {
|
||||
eprintln!("passwd: {}", err);
|
||||
exit(1);
|
||||
})
|
||||
} else {
|
||||
let username = &parser.args[0];
|
||||
get_user_by_name(username).unwrap_or_else(|| {
|
||||
eprintln!("passwd: user '{}' does not exist", username);
|
||||
get_user_by_name(username).unwrap_or_else(|err| {
|
||||
eprintln!("passwd: {}", err);
|
||||
exit(1);
|
||||
})
|
||||
};
|
||||
|
||||
+7
-3
@@ -63,9 +63,13 @@ pub fn main() {
|
||||
parser.args[0].to_string()
|
||||
};
|
||||
|
||||
let uid = get_uid();
|
||||
let user = get_user_by_name(&target_user).unwrap_or_else(|| {
|
||||
eprintln!("su: user {} not found", target_user);
|
||||
let uid = get_uid().unwrap_or_else(|err|{
|
||||
eprintln!("su: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
let user = get_user_by_name(&target_user).unwrap_or_else(|err| {
|
||||
eprintln!("su: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
|
||||
+9
-5
@@ -65,15 +65,19 @@ pub fn main() {
|
||||
exit(1);
|
||||
});
|
||||
|
||||
let uid = get_uid();
|
||||
let user = get_user_by_id(uid).unwrap_or_else(|| {
|
||||
eprintln!("sudo: user not found");
|
||||
let uid = get_uid().unwrap_or_else(|err| {
|
||||
eprintln!("sudo: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
let user = get_user_by_id(uid).unwrap_or_else(|err| {
|
||||
eprintln!("sudo: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
if uid != 0 {
|
||||
let sudo_group = get_group_by_name("sudo").unwrap_or_else(|| {
|
||||
eprintln!("sudo: sudo group not found");
|
||||
let sudo_group = get_group_by_name("sudo").unwrap_or_else(|err| {
|
||||
eprintln!("sudo: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
|
||||
+7
-3
@@ -48,9 +48,13 @@ fn main() {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
let euid = get_euid();
|
||||
let user = get_user_by_id(euid).unwrap_or_else(|| {
|
||||
println!("whoami: no user found for uid: {}", euid);
|
||||
let euid = get_euid().unwrap_or_else(|err| {
|
||||
println!("whoami: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
let user = get_user_by_id(euid).unwrap_or_else(|err| {
|
||||
println!("whoami: {}", err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user