Browse Source

admin: Disable echoing password

ipv6
Denis Drakhnia 11 months 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" @@ -8,6 +8,7 @@ version = "0.1.0"
dependencies = [
"blake2b_simd",
"getopts",
"termion",
"thiserror",
"xash3d-protocol",
]
@ -45,6 +46,12 @@ version = "1.1.0" @@ -45,6 +46,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.4.0"
@ -175,6 +182,12 @@ dependencies = [ @@ -175,6 +182,12 @@ dependencies = [
"autocfg",
]
[[package]]
name = "numtoa"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef"
[[package]]
name = "once_cell"
version = "1.17.2"
@ -199,6 +212,24 @@ dependencies = [ @@ -199,6 +212,24 @@ dependencies = [
"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]]
name = "serde"
version = "1.0.188"
@ -230,6 +261,18 @@ dependencies = [ @@ -230,6 +261,18 @@ dependencies = [
"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]]
name = "thiserror"
version = "1.0.49"
@ -417,7 +460,7 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" @@ -417,7 +460,7 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
name = "xash3d-master"
version = "0.1.0"
dependencies = [
"bitflags",
"bitflags 2.4.0",
"chrono",
"fastrand",
"getopts",
@ -433,7 +476,7 @@ dependencies = [ @@ -433,7 +476,7 @@ dependencies = [
name = "xash3d-protocol"
version = "0.1.0"
dependencies = [
"bitflags",
"bitflags 2.4.0",
"log",
"thiserror",
]

1
admin/Cargo.toml

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

21
admin/src/main.rs

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

Loading…
Cancel
Save