getty/login: diagnostic logging for login prompt tracing
This commit is contained in:
@@ -8,6 +8,7 @@ use std::io::{self, ErrorKind, Read, Stderr, Write};
|
||||
fn dlog(msg: &str) {
|
||||
let _ = OpenOptions::new()
|
||||
.write(true)
|
||||
.append(true)
|
||||
.open("/scheme/debug/no-preserve")
|
||||
.and_then(|mut f| writeln!(f, "GETTY {}", msg));
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use std::str;
|
||||
fn dlog(msg: &str) {
|
||||
let _ = OpenOptions::new()
|
||||
.write(true)
|
||||
.append(true)
|
||||
.open("/scheme/debug/no-preserve")
|
||||
.and_then(|mut f| writeln!(f, "LOGIN {}", msg));
|
||||
}
|
||||
@@ -16,6 +17,7 @@ fn dlog(msg: &str) {
|
||||
use extra::option::OptionalExt;
|
||||
use redox_users::{All, AllUsers, Config, User};
|
||||
use termion::input::TermRead;
|
||||
use termion::raw::IntoRawMode;
|
||||
use userutils::spawn_shell;
|
||||
|
||||
const _MAN_PAGE: &'static str = /* @MANSTART{login} */
|
||||
@@ -144,6 +146,15 @@ pub fn main() {
|
||||
dlog("no issue file");
|
||||
}
|
||||
|
||||
match termion::terminal_size() {
|
||||
Ok((w, h)) => dlog(&format!("terminal_size {}x{}", w, h)),
|
||||
Err(e) => dlog(&format!("terminal_size error: {}", e)),
|
||||
}
|
||||
match io::stdout().into_raw_mode() {
|
||||
Ok(_rt) => dlog("raw mode ok"),
|
||||
Err(e) => dlog(&format!("raw mode error: {}", e)),
|
||||
}
|
||||
|
||||
loop {
|
||||
dlog("before liner read_line");
|
||||
let _ = stdout.write_all(b"DIRECT_PROMPT_TEST");
|
||||
@@ -159,6 +170,7 @@ pub fn main() {
|
||||
dlog("after liner read_line");
|
||||
|
||||
if !user.is_empty() {
|
||||
dlog(&format!("read user: {}", user));
|
||||
let stdin = io::stdin();
|
||||
let mut stdin = stdin.lock();
|
||||
let sys_users = AllUsers::authenticator(Config::default()).unwrap_or_exit(1);
|
||||
@@ -172,6 +184,7 @@ pub fn main() {
|
||||
}
|
||||
Some(user) => {
|
||||
if user.is_passwd_blank() {
|
||||
dlog("user blank password, spawning shell");
|
||||
if let Ok(mut motd) = File::open(MOTD_FILE) {
|
||||
io::copy(&mut motd, &mut stdout).r#try(&mut stderr);
|
||||
stdout.flush().r#try(&mut stderr);
|
||||
|
||||
Reference in New Issue
Block a user