Skip to content
Snippets Groups Projects
Verified Commit 6450d545 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Always fall back to higher configuration level

parent 48e74427
No related branches found
No related tags found
No related merge requests found
...@@ -60,6 +60,12 @@ pub fn argv_to_config(argv: &Vec<String>) -> config::Config { ...@@ -60,6 +60,12 @@ pub fn argv_to_config(argv: &Vec<String>) -> config::Config {
pub fn get_optional<'de, T: Deserialize<'de>>(conf: &config::Config, key: &str) -> Option<T> { pub fn get_optional<'de, T: Deserialize<'de>>(conf: &config::Config, key: &str) -> Option<T> {
match conf.get(key) { match conf.get(key) {
Ok(v) => Some(v), Ok(v) => Some(v),
Err(_) => None, Err(_) => {
// Try falling back to parent block
match key.find('.') {
Some(i) => get_optional(conf, &key[i+1..]),
None => None,
}
},
} }
} }
...@@ -133,7 +133,7 @@ fn pam_sm_prepare(argv: &Vec<String>) -> Config { ...@@ -133,7 +133,7 @@ fn pam_sm_prepare(argv: &Vec<String>) -> Config {
let conf = get_config(Some(conf_args)); let conf = get_config(Some(conf_args));
let mut log_level = log::LevelFilter::Error; let mut log_level = log::LevelFilter::Error;
if conf.get_bool("debug").unwrap_or_default() || conf.get_bool("pam.debug").unwrap_or_default() { if get_optional(&conf, "pam.debug").unwrap_or_default() {
log_level = log::LevelFilter::Debug; log_level = log::LevelFilter::Debug;
} }
setup_log(log_level); setup_log(log_level);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment