Browse Source

admin: Disable echoing password

ipv6
Denis Drakhnia 1 year ago
parent
commit
e6ae885eb9
  1. 47
      Cargo.lock
  2. 1
      admin/Cargo.toml
  3. 21
      admin/src/main.rs

47
Cargo.lock generated

@ -8,6 +8,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"blake2b_simd", "blake2b_simd",
"getopts", "getopts",
"termion",
"thiserror", "thiserror",
"xash3d-protocol", "xash3d-protocol",
] ]
@ -45,6 +46,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "2.4.0" version = "2.4.0"
@ -175,6 +182,12 @@ dependencies = [
"autocfg", "autocfg",
] ]
[[package]]
name = "numtoa"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef"
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.17.2" version = "1.17.2"
@ -199,6 +212,24 @@ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]]
name = "redox_syscall"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
dependencies = [
"bitflags 1.3.2",
]
[[package]]
name = "redox_termios"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8440d8acb4fd3d277125b4bd01a6f38aee8d814b3b5fc09b3f2b825d37d3fe8f"
dependencies = [
"redox_syscall",
]
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.188" version = "1.0.188"
@ -230,6 +261,18 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "termion"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "659c1f379f3408c7e5e84c7d0da6d93404e3800b6b9d063ba24436419302ec90"
dependencies = [
"libc",
"numtoa",
"redox_syscall",
"redox_termios",
]
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.49" version = "1.0.49"
@ -417,7 +460,7 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
name = "xash3d-master" name = "xash3d-master"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"bitflags", "bitflags 2.4.0",
"chrono", "chrono",
"fastrand", "fastrand",
"getopts", "getopts",
@ -433,7 +476,7 @@ dependencies = [
name = "xash3d-protocol" name = "xash3d-protocol"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"bitflags", "bitflags 2.4.0",
"log", "log",
"thiserror", "thiserror",
] ]

1
admin/Cargo.toml

@ -9,5 +9,6 @@ rust-version = "1.56"
[dependencies] [dependencies]
thiserror = "1.0.49" thiserror = "1.0.49"
getopts = "0.2.21" getopts = "0.2.21"
termion = "2"
blake2b_simd = "<0.6" blake2b_simd = "<0.6"
xash3d-protocol = { path = "../protocol", version = "0.1.0" } xash3d-protocol = { path = "../protocol", version = "0.1.0" }

21
admin/src/main.rs

@ -3,9 +3,10 @@
mod cli; mod cli;
use std::io; use std::io::{self, Write};
use std::net::UdpSocket; use std::net::UdpSocket;
use termion::input::TermRead;
use blake2b_simd::Params; use blake2b_simd::Params;
use thiserror::Error; use thiserror::Error;
use xash3d_protocol::{admin, master}; use xash3d_protocol::{admin, master};
@ -34,12 +35,18 @@ fn send_command(cli: &cli::Cli) -> Result<(), Error> {
_ => return Err(Error::UnexpectedPacket), _ => return Err(Error::UnexpectedPacket),
}; };
println!("Password:"); let stdout = io::stdout();
let mut password = String::new(); let stdin = io::stdin();
io::stdin().read_line(&mut password)?; let mut stdout = stdout.lock();
if password.ends_with('\n') { let mut stdin = stdin.lock();
password.pop();
} stdout.write_all(b"Password:\n")?;
stdout.flush()?;
let password = match stdin.read_passwd(&mut stdout)? {
Some(pass) => pass,
None => return Ok(()),
};
let hash = Params::new() let hash = Params::new()
.hash_length(cli.hash_len) .hash_length(cli.hash_len)

Loading…
Cancel
Save