mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-24 04:57:00 +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);
|
debug!("Attempting to load configuration from {:#?}", &config_path);
|
||||||
// If the file does not exist, we skip this function.
|
// If the file does not exist, we skip this function.
|
||||||
let mut f = match File::open(&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) => {
|
Err(e) => {
|
||||||
match e.kind() {
|
match e.kind() {
|
||||||
ErrorKind::NotFound => {
|
ErrorKind::NotFound => {
|
||||||
|
@ -292,7 +295,7 @@ impl KanidmClientBuilder {
|
||||||
let address = match &self.address {
|
let address = match &self.address {
|
||||||
Some(a) => a.clone(),
|
Some(a) => a.clone(),
|
||||||
None => {
|
None => {
|
||||||
eprintln!("uri (-H) missing, can not proceed");
|
eprintln!("Configuration option 'uri' missing, cannot continue client startup.");
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::constants::{
|
||||||
};
|
};
|
||||||
use serde_derive::Deserialize;
|
use serde_derive::Deserialize;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Read;
|
use std::io::{ErrorKind, Read};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
|
@ -81,13 +81,33 @@ impl KanidmUnixdConfig {
|
||||||
self,
|
self,
|
||||||
config_path: P,
|
config_path: P,
|
||||||
) -> Result<Self, ()> {
|
) -> Result<Self, ()> {
|
||||||
|
debug!("Attempting to load configuration from {:#?}", &config_path);
|
||||||
let mut f = match File::open(&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) => {
|
Err(e) => {
|
||||||
debug!(
|
match e.kind() {
|
||||||
"Unable to open config file {:#?} [{:?}], skipping ...",
|
ErrorKind::NotFound => {
|
||||||
&config_path, e
|
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);
|
return Ok(self);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue