Change option names for clarity

This commit is contained in:
Barry Pederson
2022-03-01 10:23:17 -08:00
parent b9c091f71f
commit 8134df29b7
3 changed files with 11 additions and 10 deletions
+6 -6
View File
@@ -13,15 +13,15 @@ pub struct Listener {
impl Listener { impl Listener {
pub fn new() -> Result<Listener, Error> { pub fn new() -> Result<Listener, Error> {
if OPTIONS.socket.exists() { if OPTIONS.socket_name.exists() {
std::fs::remove_file(&OPTIONS.socket)?; std::fs::remove_file(&OPTIONS.socket_name)?;
} }
let listener = UnixListener::bind(&OPTIONS.socket)?; let listener = UnixListener::bind(&OPTIONS.socket_name)?;
let mut perms = metadata(&OPTIONS.socket)?.permissions(); let mut perms = metadata(&OPTIONS.socket_name)?.permissions();
perms.set_mode(0o0777); perms.set_mode(0o0777);
set_permissions(&OPTIONS.socket, perms)?; set_permissions(&OPTIONS.socket_name, perms)?;
Ok(Listener { listener }) Ok(Listener { listener })
} }
@@ -46,7 +46,7 @@ impl Listener {
impl Drop for Listener { impl Drop for Listener {
fn drop(&mut self) { fn drop(&mut self) {
let _result = std::fs::remove_file(&OPTIONS.socket); let _result = std::fs::remove_file(&OPTIONS.socket_name);
println!("Shutting down"); println!("Shutting down");
} }
} }
+4 -3
View File
@@ -1,5 +1,6 @@
use once_cell::sync::Lazy;
use std::path::PathBuf; use std::path::PathBuf;
use once_cell::sync::Lazy;
use structopt::StructOpt; use structopt::StructOpt;
#[derive(StructOpt, Clone, Debug)] #[derive(StructOpt, Clone, Debug)]
@@ -12,7 +13,7 @@ pub struct Opt {
default_value = "/tmp/saslauthd.sock", default_value = "/tmp/saslauthd.sock",
parse(from_os_str) parse(from_os_str)
)] )]
pub socket: PathBuf, pub socket_name: PathBuf,
#[structopt( #[structopt(
short = "p", short = "p",
@@ -20,7 +21,7 @@ pub struct Opt {
default_value = "./passwords", default_value = "./passwords",
parse(from_os_str) parse(from_os_str)
)] )]
pub passwords: PathBuf, pub password_dir: PathBuf,
} }
pub static OPTIONS: Lazy<Opt> = Lazy::new(Opt::from_args); pub static OPTIONS: Lazy<Opt> = Lazy::new(Opt::from_args);
+1 -1
View File
@@ -59,7 +59,7 @@ impl Server {
return Ok(false); return Ok(false);
} }
let mut password_file = OPTIONS.passwords.clone(); let mut password_file = OPTIONS.password_dir.clone();
password_file.push(&userid); password_file.push(&userid);
let file = File::open(password_file)?; let file = File::open(password_file)?;