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:
+4
-5
@@ -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)?;
|
||||
|
||||
Reference in New Issue
Block a user