diff --git a/src/config.c b/src/config.c index 09fe28c..1990318 100644 --- a/src/config.c +++ b/src/config.c @@ -72,6 +72,9 @@ int parse_config(oal_config_t * const config, const char *file) { if (strncmp(key, "bindtimeout", 11) == 0) { config->bindtimeout = atoi(value); } else + if (strncmp(key, "debug", 5) == 0) { + config->debug = !!atoi(value); + } else if (strncmp(key, "basedn", 6) == 0) { config->basedn = strndup(value, valsize); } else diff --git a/src/config.h b/src/config.h index 2e883db..5c20441 100644 --- a/src/config.h +++ b/src/config.h @@ -7,6 +7,7 @@ typedef struct { char *bindpass; /** bind with this password */ size_t bindtimeout; /** bind timeout */ char *basedn; /** where to search for users */ + short debug; /** enable ldap debug */ char *userfilter; /** ldap filter for user entry */ char error[1024]; /** parser error */ } oal_config_t; diff --git a/tests/parse_config.c b/tests/parse_config.c index d86eb82..d2eb57b 100644 --- a/tests/parse_config.c +++ b/tests/parse_config.c @@ -16,6 +16,7 @@ int main(void) { } assert(config.bindtimeout == 5); + assert(config.debug == 1); assert(strcmp(config.bindpass, "strong-password") == 0); assert(strcmp(config.bindurls, "ldap://127.0.0.1 ldaps://172.16.17.1") == 0); assert(strcmp(config.binddn, "cn=admin,dc=example,dc=com") == 0); diff --git a/tests/test.conf b/tests/test.conf index 07bf5b9..4bbc791 100644 --- a/tests/test.conf +++ b/tests/test.conf @@ -4,6 +4,8 @@ binddn cn=admin,dc=example,dc=com bindpass strong-password bindtimeout 5 # another comment and empty string below +debug 5 +# ^^ this is actually boolean flag: zero and non-zero basedn ou=users,dc=example,dc=com userfilter (objectClass=inetOrgPerson)