userutils: remove temporary login prompt diagnostics

This commit is contained in:
2026-07-07 01:16:31 +03:00
parent 395046ee3f
commit 670693e114
2 changed files with 4 additions and 52 deletions
+3 -21
View File
@@ -2,16 +2,8 @@
extern crate clap;
use std::error::Error;
use std::fs::{File, OpenOptions};
use std::fs::File;
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));
}
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::process::{Child, Command, Stdio};
use std::str;
@@ -216,7 +208,6 @@ fn daemon(tty: &mut File, clear: bool, contain: bool, stderr: &mut Stderr) {
.expect("getty: failed to fevent master PTY");
loop {
dlog("daemon loop");
if clear {
let _ = redox::write(tty_fd as usize, b"\x1Bc");
}
@@ -245,20 +236,14 @@ fn daemon(tty: &mut File, clear: bool, contain: bool, stderr: &mut Stderr) {
match command.spawn() {
Ok(mut process) => {
dlog("login spawned");
handle(&mut event_queue, tty_fd, master_fd, &mut process);
dlog("handle returned");
}
Err(err) => {
dlog(&format!("login spawn failed: {}", err));
fail(&format!("getty: failed to execute login: {}", err), stderr)
}
Err(err) => fail(&format!("getty: failed to execute login: {}", err), stderr),
}
}
}
pub fn main() {
dlog("main started");
let mut stderr = io::stderr();
let args = clap_app!(getty =>
@@ -289,10 +274,7 @@ pub fn main() {
flag::O_CLOEXEC | flag::O_RDWR | flag::O_NONBLOCK,
0,
) {
Ok(fd) => {
dlog(&format!("opened TTY {}", vt_path));
unsafe { File::from_raw_fd(fd as RawFd) }
}
Ok(fd) => unsafe { File::from_raw_fd(fd as RawFd) },
Err(err) => fail(
&format!("getty: failed to open TTY {}: {}", vt_path, err),
&mut stderr,
+1 -31
View File
@@ -2,22 +2,13 @@
extern crate clap;
use libredox::error::Result;
use std::fs::{File, OpenOptions};
use std::fs::File;
use std::io::{self, Write};
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));
}
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} */
@@ -127,7 +118,6 @@ fn load_config_schemes(user: &User<redox_users::auth::Full>) -> Option<Vec<Strin
}
pub fn main() {
dlog("main started");
let mut stdout = io::stdout();
let mut stderr = io::stderr();
@@ -137,29 +127,12 @@ pub fn main() {
)
.get_matches();
dlog("before issue");
if let Ok(mut issue) = File::open(ISSUE_FILE) {
io::copy(&mut issue, &mut stdout).r#try(&mut stderr);
stdout.flush().r#try(&mut stderr);
dlog("issue printed");
} else {
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");
let _ = stdout.flush();
dlog("direct prompt write done");
let user = liner::Context::new()
.read_line(
liner::Prompt::from("\x1B[1mRed Bear login:\x1B[0m "),
@@ -167,10 +140,8 @@ pub fn main() {
&mut liner::BasicCompleter::new(Vec::<String>::new()),
)
.r#try(&mut stderr);
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);
@@ -184,7 +155,6 @@ 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);