Use once_cell to allow for global static immutable options

So they don't have to be passed around all over the place
This commit is contained in:
Barry Pederson
2022-03-01 10:03:38 -08:00
parent a244e714ea
commit b9c091f71f
6 changed files with 27 additions and 23 deletions
+4 -5
View File
@@ -3,19 +3,18 @@ use std::io::{BufRead, BufReader, Error, ErrorKind, Read, Write};
use std::net::Shutdown;
use std::os::unix::net::UnixStream;
use crate::options::Opt;
use crate::options::OPTIONS;
const RESPONSE_NO: [u8; 4] = [0x0, 0x2, b'N', b'O'];
const RESPONSE_OK: [u8; 4] = [0x0, 0x2, b'O', b'K'];
pub struct Server {
options: Opt,
stream: UnixStream,
}
impl Server {
pub fn new(options: Opt, stream: UnixStream) -> Result<Server, Error> {
Ok(Server { options, stream })
pub fn new(stream: UnixStream) -> Result<Server, Error> {
Ok(Server { stream })
}
/// The saslauthd protocol transmits strings as
@@ -60,7 +59,7 @@ impl Server {
return Ok(false);
}
let mut password_file = self.options.passwords.clone();
let mut password_file = OPTIONS.passwords.clone();
password_file.push(&userid);
let file = File::open(password_file)?;