diff --git a/src/config.c b/src/config.c index 30f80e5..c693d6f 100644 --- a/src/config.c +++ b/src/config.c @@ -94,3 +94,33 @@ int parse_config(oal_config_t * const config, const char *file) { return 0; } + +int check_config(oal_config_t * const config) { + enum { bufsize = 1024 }; + char err[bufsize] = { '\0' }; + + assert(config != NULL); + + if (!config->bindurls) { + snprintf(err, bufsize, "'bindurls' not set in config"); + goto error; + } + if (!config->basedn) { + snprintf(err, bufsize, "'basedn' not set in config"); + goto error; + } + if (!config->userfilter) { + snprintf(err, bufsize, "'userfilter' not set in config"); + goto error; + } + if (config->binddn && !config->bindpass) { + snprintf(err, bufsize, "'bindn' set, but 'bindpass' missing in config"); + goto error; + } + + return 0; + + error: + config->error = strndup(err, bufsize); + return 1; +} diff --git a/src/config.h b/src/config.h index e219d48..987bd1a 100644 --- a/src/config.h +++ b/src/config.h @@ -13,5 +13,6 @@ typedef struct { } oal_config_t; int parse_config(oal_config_t * const config, const char *file); +int check_config(oal_config_t * const config); #endif /* OAL_CONFIG_H_INCLUDED */