Minor fmt
This commit is contained in:
@@ -26,7 +26,7 @@ pub struct Config {
|
||||
pub enum VtSelection {
|
||||
Next,
|
||||
Current,
|
||||
Specific(usize)
|
||||
Specific(usize),
|
||||
}
|
||||
|
||||
impl Config {
|
||||
@@ -36,8 +36,7 @@ impl Config {
|
||||
"next" => VtSelection::Next,
|
||||
"current" => VtSelection::Current,
|
||||
_ => panic!("unknown value of vt, expect next, current, or vt number"),
|
||||
|
||||
}
|
||||
},
|
||||
toml::Value::Integer(u) => VtSelection::Specific(*u as usize),
|
||||
_ => panic!("unknown value of vt, expect next, current, or vt number"),
|
||||
}
|
||||
|
@@ -96,8 +96,15 @@ impl<'a> Context<'a> {
|
||||
return Err(io::Error::new(io::ErrorKind::Other, "session already active").into());
|
||||
}
|
||||
|
||||
let pending_session =
|
||||
Session::new("login", "user", &username, &password, cmd, provided_env, self.vt)?;
|
||||
let pending_session = Session::new(
|
||||
"login",
|
||||
"user",
|
||||
&username,
|
||||
&password,
|
||||
cmd,
|
||||
provided_env,
|
||||
self.vt,
|
||||
)?;
|
||||
password.scramble();
|
||||
self.pending_session = Some(pending_session);
|
||||
|
||||
|
@@ -42,8 +42,6 @@ impl Pollable for Listener {
|
||||
Err(_) => return Ok(PollRunResult::Uneventful),
|
||||
};
|
||||
|
||||
Ok(PollRunResult::NewPollable(Box::new(
|
||||
Client::new(stream)?,
|
||||
)))
|
||||
Ok(PollRunResult::NewPollable(Box::new(Client::new(stream)?)))
|
||||
}
|
||||
}
|
||||
|
@@ -4,8 +4,8 @@ use std::fs::remove_file;
|
||||
use nix::poll::{poll, PollFd};
|
||||
use nix::unistd::chown;
|
||||
|
||||
mod config;
|
||||
mod client;
|
||||
mod config;
|
||||
mod context;
|
||||
mod listener;
|
||||
mod pam;
|
||||
@@ -33,12 +33,11 @@ fn main() {
|
||||
|
||||
let signals = signals::Signals::new().expect("unable to create signalfd");
|
||||
|
||||
let term = terminal::Terminal::open(0)
|
||||
.expect("unable to open controlling terminal");
|
||||
let term = terminal::Terminal::open(0).expect("unable to open controlling terminal");
|
||||
let vt = match config.vt() {
|
||||
config::VtSelection::Current => term.vt_get_current().expect("unable to get current VT"),
|
||||
config::VtSelection::Next => term.vt_get_next().expect("unable to get next VT"),
|
||||
config::VtSelection::Specific(v) => v
|
||||
config::VtSelection::Specific(v) => v,
|
||||
};
|
||||
drop(term);
|
||||
|
||||
@@ -48,10 +47,8 @@ fn main() {
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
let mut pollables: Vec<Box<dyn pollable::Pollable>> = vec![
|
||||
Box::new(listener),
|
||||
Box::new(signals),
|
||||
];
|
||||
let mut pollables: Vec<Box<dyn pollable::Pollable>> =
|
||||
vec![Box::new(listener), Box::new(signals)];
|
||||
|
||||
let mut fds: Vec<PollFd> = Vec::new();
|
||||
let mut fds_changed = true;
|
||||
@@ -83,14 +80,14 @@ fn main() {
|
||||
// not require index compensation.
|
||||
pollables.push(p);
|
||||
fds_changed = true;
|
||||
},
|
||||
}
|
||||
Ok(pollable::PollRunResult::Dead) => {
|
||||
// We remove a pollable at the current index, so
|
||||
// compensate the index of future accesses.
|
||||
idx_compensation -= 1;
|
||||
pollables.remove(idx);
|
||||
fds_changed = true;
|
||||
},
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("task failed: {}", e);
|
||||
terminal::restore(vt).expect("unable to reset vt");
|
||||
|
@@ -149,7 +149,6 @@ impl<'a> Session<'a> {
|
||||
/// responsible for the entirety of the session setup and execution. It is
|
||||
/// started by Session::start.
|
||||
fn session_worker(&mut self, childfd: RawFd) -> Result<(), Box<dyn Error>> {
|
||||
|
||||
// Clear the signal masking that was inherited from the parent.
|
||||
blocked_sigset()
|
||||
.thread_unblock()
|
||||
@@ -371,8 +370,7 @@ impl<'a> Session<'a> {
|
||||
|
||||
// Run the child entrypoint.
|
||||
if let Err(e) = self.session_worker(childfd) {
|
||||
writeln!(stderr, "session worker: {}", e)
|
||||
.expect("could not write log output");
|
||||
writeln!(stderr, "session worker: {}", e).expect("could not write log output");
|
||||
std::process::exit(1);
|
||||
}
|
||||
std::process::exit(0);
|
||||
|
Reference in New Issue
Block a user