mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 20:47:01 +01:00
444 - client's config URI missing and more file open handling (#446)
This commit is contained in:
parent
78f780910e
commit
1f98018513
|
@ -158,7 +158,10 @@ impl KanidmClientBuilder {
|
|||
debug!("Attempting to load configuration from {:#?}", &config_path);
|
||||
// If the file does not exist, we skip this function.
|
||||
let mut f = match File::open(&config_path) {
|
||||
Ok(f) => f,
|
||||
Ok(f) => {
|
||||
debug!("Successfully opened configuration file {:#?}", &config_path);
|
||||
f
|
||||
}
|
||||
Err(e) => {
|
||||
match e.kind() {
|
||||
ErrorKind::NotFound => {
|
||||
|
@ -292,7 +295,7 @@ impl KanidmClientBuilder {
|
|||
let address = match &self.address {
|
||||
Some(a) => a.clone(),
|
||||
None => {
|
||||
eprintln!("uri (-H) missing, can not proceed");
|
||||
eprintln!("Configuration option 'uri' missing, cannot continue client startup.");
|
||||
unimplemented!();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::constants::{
|
|||
};
|
||||
use serde_derive::Deserialize;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::io::{ErrorKind, Read};
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
@ -81,13 +81,33 @@ impl KanidmUnixdConfig {
|
|||
self,
|
||||
config_path: P,
|
||||
) -> Result<Self, ()> {
|
||||
debug!("Attempting to load configuration from {:#?}", &config_path);
|
||||
let mut f = match File::open(&config_path) {
|
||||
Ok(f) => f,
|
||||
Ok(f) => {
|
||||
debug!("Successfully opened configuration file {:#?}", &config_path);
|
||||
f
|
||||
}
|
||||
Err(e) => {
|
||||
debug!(
|
||||
"Unable to open config file {:#?} [{:?}], skipping ...",
|
||||
&config_path, e
|
||||
);
|
||||
match e.kind() {
|
||||
ErrorKind::NotFound => {
|
||||
debug!(
|
||||
"Configuration file {:#?} not found, skipping.",
|
||||
&config_path
|
||||
);
|
||||
}
|
||||
ErrorKind::PermissionDenied => {
|
||||
warn!(
|
||||
"Permission denied loading configuration file {:#?}, skipping.",
|
||||
&config_path
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
debug!(
|
||||
"Unable to open config file {:#?} [{:?}], skipping ...",
|
||||
&config_path, e
|
||||
);
|
||||
}
|
||||
};
|
||||
return Ok(self);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue