Skip to content

Commit

Permalink
Add debug, fix #2
Browse files Browse the repository at this point in the history
  • Loading branch information
kuon committed Aug 27, 2020
1 parent 4d9a655 commit 9c2b51d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
8 changes: 8 additions & 0 deletions config.toml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@
### by root and not readable by anyone else. ###
###############################################################################

# General debug
# This set PAM and NSS debug via syslog
# debug = true

# The radius section defines the Radius server configuration. For the
# auth_radius_client binary, this is the only required section.
[radius]

# Radius debug
# This debug radius as stdout
# debug = true

# The radius shared secret
shared_secret = "testing123"

Expand Down
9 changes: 7 additions & 2 deletions nss_db/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,21 @@ pub struct DefaultUser {
pub group: String,
pub gid: u32,
pub home: String,
pub shell: String
pub shell: String,
}

#[derive(Debug, Deserialize)]
pub struct Mapping {
pub db: Db,
pub users: Vec<UserMapping>,
pub default_user: DefaultUser
pub default_user: DefaultUser,
}

#[derive(Debug, Deserialize)]
pub struct Config {
pub radius: radius::Config,
pub mapping: Mapping,
pub debug: Option<bool>,
}

impl Config {
Expand Down Expand Up @@ -80,4 +81,8 @@ impl Config {

None
}

pub fn debug(&self) -> bool {
self.debug.unwrap_or(false)
}
}
3 changes: 2 additions & 1 deletion nss_db/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ pub fn setup_log<S: Into<String>>(name: S) {

let logger = syslog::unix(formatter).expect("could not connect to syslog");
log::set_boxed_logger(Box::new(BasicLogger::new(logger)))
.map(|()| log::set_max_level(LevelFilter::Info));
.map(|()| log::set_max_level(LevelFilter::Debug));
}

3 changes: 3 additions & 0 deletions nss_db/tests/db_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ use helpers::*;
#[test]
fn it_store_user() -> Result<(), Error> {
let conf = config()?;

assert!(conf.debug());

let mut db = Db::with_config(&conf)?;
let mut user = User::new("testing");
user.attributes.push(Attribute {
Expand Down
2 changes: 2 additions & 0 deletions tests/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
debug = true

[radius]
shared_secret = "testing123"
attributes = ["1.1"]
Expand Down

0 comments on commit 9c2b51d

Please sign in to comment.