X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fconf%2Fconf_mod.c;h=edcc08921c2fe2711ecacc990b4a4460630491cf;hp=23e1f191da5b0cda12e0be9d933d33b248934488;hb=001ab3abad45752c13af5396a47551f46a6ebfdb;hpb=f78d4a35f865d7678a8b8e7a496e72a19f3df014 diff --git a/crypto/conf/conf_mod.c b/crypto/conf/conf_mod.c index 23e1f191da..edcc08921c 100644 --- a/crypto/conf/conf_mod.c +++ b/crypto/conf/conf_mod.c @@ -130,9 +130,11 @@ int CONF_modules_load(const CONF *cnf, const char *appname, int ret, i; - if (!cnf || !appname) + if (!cnf) return 1; + if (appname == NULL) + appname = "openssl_conf"; vsection = NCONF_get_string(cnf, NULL, appname); @@ -163,18 +165,38 @@ int CONF_modules_load(const CONF *cnf, const char *appname, int CONF_modules_load_file(const char *filename, const char *appname, unsigned long flags) { + char *file = NULL; CONF *conf = NULL; int ret = 0; conf = NCONF_new(NULL); if (!conf) goto err; - if (NCONF_load(conf, filename, NULL) <= 0) + if (filename == NULL) + { + file = CONF_get1_default_config_file(); + if (!file) + goto err; + } + else + file = (char *)filename; + + if (NCONF_load(conf, file, NULL) <= 0) + { + if ((flags & CONF_MFLAGS_IGNORE_MISSING_FILE) && + (ERR_GET_REASON(ERR_peek_last_error()) == CONF_R_NO_SUCH_FILE)) + { + ERR_clear_error(); + ret = 1; + } goto err; + } ret = CONF_modules_load(conf, appname, flags); err: + if (filename == NULL) + OPENSSL_free(file); NCONF_free(conf); return ret; @@ -189,7 +211,7 @@ static int module_run(const CONF *cnf, char *name, char *value, md = module_find(name); /* Module not found: try to load DSO */ - if (!md) + if (!md && !(flags & CONF_MFLAGS_NO_DSO)) md = module_load_dso(cnf, name, value, flags); if (!md) @@ -208,7 +230,7 @@ static int module_run(const CONF *cnf, char *name, char *value, { if (!(flags & CONF_MFLAGS_SILENT)) { - char rcode[10]; + char rcode[DECIMAL_SIZE(ret)+1]; CONFerr(CONF_F_CONF_MODULES_LOAD, CONF_R_MODULE_INITIALIZATION_ERROR); sprintf(rcode, "%-8d", ret); ERR_add_error_data(6, "module=", name, ", value=", value, ", retcode=", rcode); @@ -248,11 +270,6 @@ static CONF_MODULE *module_load_dso(const CONF *cnf, char *name, char *value, goto err; } ffunc = (conf_finish_func *)DSO_bind_func(dso, DSO_mod_finish_name); - if (!ffunc) - { - errcode = CONF_R_MISSING_FINISH_FUNCTION; - goto err; - } /* All OK, add module */ md = module_add(dso, name, ifunc, ffunc); @@ -405,6 +422,7 @@ void CONF_modules_unload(int all) { int i; CONF_MODULE *md; + CONF_modules_finish(); /* unload modules in reverse order */ for (i = sk_CONF_MODULE_num(supported_modules) - 1; i >= 0; i--) { @@ -450,7 +468,8 @@ void CONF_modules_finish(void) static void module_finish(CONF_IMODULE *imod) { - imod->pmod->finish(imod); + if (imod->pmod->finish) + imod->pmod->finish(imod); imod->pmod->links--; OPENSSL_free(imod->name); OPENSSL_free(imod->value);