-use std::io::Write;
+use std::io::{IsTerminal, Write};
use std::sync::{Arc, Mutex, RwLock};
use std::time::Duration;
&auth.ticket,
&auth.token,
) {
- if tty::stdout_isatty() {
+ if std::io::stdout().is_terminal() {
log::error!("storing login ticket failed: {}", err);
}
}
&auth.ticket,
&auth.token,
) {
- if tty::stdout_isatty() {
+ if std::io::stdout().is_terminal() {
log::error!("storing login ticket failed: {}", err);
}
}
fn get_password(username: &Userid, interactive: bool) -> Result<String, Error> {
// If we're on a TTY, query the user for a password
- if interactive && tty::stdin_isatty() {
+ if interactive && std::io::stdin().is_terminal() {
let msg = format!("Password for \"{}\": ", username);
return Ok(String::from_utf8(tty::read_password(&msg)?)?);
}
}
// If we're on a TTY, query the user
- if interactive && tty::stdin_isatty() {
+ if interactive && std::io::stdin().is_terminal() {
log::info!("fingerprint: {}", fp_string);
loop {
eprint!("Are you sure you want to continue connecting? (y/n): ");
-use std::io::Read;
+use std::io::{IsTerminal, Read};
use std::os::unix::io::{FromRawFd, RawFd};
use std::path::PathBuf;
}
// If we're on a TTY, query the user for a password
- if tty::stdin_isatty() {
+ if std::io::stdin().is_terminal() {
return tty::read_password("Encryption Key Password: ");
}
+use std::io::IsTerminal;
use std::path::PathBuf;
use anyhow::{bail, format_err, Error};
}
Kdf::Scrypt | Kdf::PBKDF2 => {
// always read passphrase from tty
- if !tty::stdin_isatty() {
+ if !std::io::stdin().is_terminal() {
bail!("unable to read passphrase - no tty");
}
let kdf = kdf.unwrap_or_default();
- if !tty::stdin_isatty() {
+ if !std::io::stdin().is_terminal() {
bail!("unable to change passphrase - no tty");
}
/// encryption key onto the backup server along with each backup.
fn create_master_key() -> Result<(), Error> {
// we need a TTY to query the new password
- if !tty::stdin_isatty() {
+ if !std::io::stdin().is_terminal() {
bail!("unable to create master key - no tty");
}
use std::collections::{HashMap, HashSet};
use std::ffi::{OsStr, OsString};
-use std::io::Write;
+use std::io::{IsTerminal, Write};
use std::iter::FromIterator;
use std::path::{Path, PathBuf};
use std::sync::Arc;
let color_choice = match output_params.color {
ColorMode::Always => ColorChoice::Always,
ColorMode::Auto => {
- if unsafe { libc::isatty(1) == 1 } {
+ if std::io::stdout().is_terminal() {
// Show colors unless `TERM=dumb` or `NO_COLOR` is set.
ColorChoice::Auto
} else {
+use std::io::IsTerminal;
+
use anyhow::{bail, format_err, Error};
use serde_json::Value;
mut param: Value,
rpcenv: &mut dyn RpcEnvironment,
) -> Result<(), Error> {
- if !tty::stdin_isatty() {
+ if !std::io::stdin().is_terminal() {
bail!("unable to change passphrase - no tty");
}
} else if !drive_passed && key.is_none() && key_file.is_none() {
bail!("one of either 'drive' or 'key' parameter must be set!");
}
- if !tty::stdin_isatty() {
+ if !std::io::stdin().is_terminal() {
bail!("no password input mechanism available");
}
)]
/// Create key (read password from stdin)
fn create_key(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
- if !tty::stdin_isatty() {
+ if !std::io::stdin().is_terminal() {
bail!("no password input mechanism available");
}