aboutsummaryrefslogtreecommitdiffstats
path: root/apps/srp.c
diff options
context:
space:
mode:
authorRich Salz <rsalz@akamai.com>2015-05-28 13:52:55 -0400
committerRich Salz <rsalz@openssl.org>2015-05-28 17:28:33 -0400
commitcc01d21756cc9c79231ef21039782c5fe42008a2 (patch)
treecb92584cc79d9994f9859b15c04a645d0b020389 /apps/srp.c
parentf097f81c891bb1f479426d8ac9c9541390334983 (diff)
downloadopenssl-cc01d21756cc9c79231ef21039782c5fe42008a2.tar.gz
RT3876: Only load config when needed
Create app_load_config(), a routine to load config file. Remove the "always load config" from the main app. Change the places that used to load config to call the new common routine. Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'apps/srp.c')
-rw-r--r--apps/srp.c47
1 files changed, 8 insertions, 39 deletions
diff --git a/apps/srp.c b/apps/srp.c
index 161f2b89ef..b91d7d0765 100644
--- a/apps/srp.c
+++ b/apps/srp.c
@@ -255,14 +255,13 @@ int srp_main(int argc, char **argv)
CA_DB *db = NULL;
DB_ATTR db_attr;
CONF *conf = NULL;
- int gNindex = -1, maxgN = -1, ret = 1, errors = 0, verbose =
- 0, i, doupdatedb = 0;
- int mode = OPT_ERR;
+ int gNindex = -1, maxgN = -1, ret = 1, errors = 0, verbose = 0, i;
+ int doupdatedb = 0, mode = OPT_ERR;
char *user = NULL, *passinarg = NULL, *passoutarg = NULL;
char *passin = NULL, *passout = NULL, *gN = NULL, *userinfo = NULL;
char *randfile = NULL, *tofree = NULL, *section = NULL;
- char **gNrow = NULL, *configfile = NULL, *dbfile = NULL, **pp, *prog;
- long errorline = -1;
+ char **gNrow = NULL, *configfile = default_config_file;
+ char *dbfile = NULL, **pp, *prog;
OPTION_CHOICE o;
prog = opt_init(argc, argv, srp_options);
@@ -349,42 +348,12 @@ int srp_main(int argc, char **argv)
}
if (!dbfile) {
-
- /*****************************************************************/
- tofree = NULL;
- if (configfile == NULL)
- configfile = getenv("OPENSSL_CONF");
- if (configfile == NULL)
- configfile = getenv("SSLEAY_CONF");
- if (configfile == NULL) {
- const char *s = X509_get_default_cert_area();
- size_t len = strlen(s) + 1 + sizeof(CONFIG_FILE);
-
- tofree = app_malloc(len, "config filename space");
-# ifdef OPENSSL_SYS_VMS
- strcpy(tofree, s);
-# else
- BUF_strlcpy(tofree, s, len);
- BUF_strlcat(tofree, "/", len);
-# endif
- BUF_strlcat(tofree, CONFIG_FILE, len);
- configfile = tofree;
- }
-
if (verbose)
- BIO_printf(bio_err, "Using configuration from %s\n", configfile);
- conf = NCONF_new(NULL);
- if (NCONF_load(conf, configfile, &errorline) <= 0) {
- if (errorline <= 0)
- BIO_printf(bio_err, "error loading the config file '%s'\n",
- configfile);
- else
- BIO_printf(bio_err, "error on line %ld of config file '%s'\n",
- errorline, configfile);
+ BIO_printf(bio_err, "Using configuration from %s\n",
+ configfile);
+ conf = app_load_config(configfile);
+ if (conf == NULL)
goto end;
- }
- OPENSSL_free(tofree);
- tofree = NULL;
/* Lets get the config section we are using */
if (section == NULL) {