Add argument to OPENSSL_config() and add flag to
authorDr. Stephen Henson <steve@openssl.org>
Thu, 14 Feb 2002 23:39:36 +0000 (23:39 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Thu, 14 Feb 2002 23:39:36 +0000 (23:39 +0000)
tolerate missing config file.

CHANGES
crypto/conf/conf.h
crypto/conf/conf_mall.c
crypto/conf/conf_mod.c

diff --git a/CHANGES b/CHANGES
index 03ed082e306ea142e3ae8d9a347f772938226f7d..bfb55629206fb0a6cca25b7b20667b186bc09202 100644 (file)
--- a/CHANGES
+++ b/CHANGES
          *) applies to 0.9.6a/0.9.6b/0.9.6c and 0.9.7
          +) applies to 0.9.7 only
 
+  +) Add an argument to OPENSSL_config() to allow the use of an alternative
+     config section name. Add a new flag to tolerate a missing config file
+     and move code to CONF_modules_load_file().
+     [Steve Henson]
+
   *) Add information about CygWin 1.3 and on, and preserve proper
      configuration for the versions before that.
      [Corinna Vinschen <vinschen@redhat.com> and Richard Levitte]
index 2c6f5733490c30802f55a0772afcbbaec6ac6578..176d64b57912d826fc0a33258c56a66b9c9a2cd3 100644 (file)
@@ -112,6 +112,7 @@ typedef void conf_finish_func(CONF_IMODULE *md);
 #define CONF_MFLAGS_IGNORE_RETURN_CODES        0x2
 #define CONF_MFLAGS_SILENT             0x4
 #define CONF_MFLAGS_NO_DSO             0x8
+#define CONF_MFLAGS_IGNORE_MISSING_FILE        0x10
 
 int CONF_set_default_method(CONF_METHOD *meth);
 void CONF_set_nconf(CONF *conf,LHASH *hash);
@@ -127,7 +128,7 @@ void CONF_free(LHASH *conf);
 int CONF_dump_fp(LHASH *conf, FILE *out);
 int CONF_dump_bio(LHASH *conf, BIO *out);
 
-void OPENSSL_config(void);
+void OPENSSL_config(char *config_name);
 
 /* New conf code.  The semantics are different from the functions above.
    If that wasn't the case, the above functions would have been replaced */
index 01cff6946a44d8ddd347306c6d379a6446b75b63..18dbf11614c8e7dac785d3f5a03e2e908d73ac53 100644 (file)
@@ -81,7 +81,7 @@ void OPENSSL_load_builtin_modules(void)
 
 static int openssl_configured = 0;
 
-void OPENSSL_config(void)
+void OPENSSL_config(char *config_name)
        {
        int err_exit = 0;
        char *file;
@@ -93,15 +93,13 @@ void OPENSSL_config(void)
        file = CONF_get1_default_config_file();
        if (!file)
                return;
+       if (config_name == NULL)
+               config_name = "openssl_conf";
 
        ERR_clear_error();
-       if (CONF_modules_load_file(file, "openssl_config", 0) <= 0)
-               {
-               if (ERR_GET_REASON(ERR_peek_last_error()) == CONF_R_NO_SUCH_FILE)
-                       ERR_clear_error();
-               else
+       if (CONF_modules_load_file(file, config_name,
+                       CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0)
                        err_exit = 1;
-               }
 
        OPENSSL_free(file);
        if (err_exit)
@@ -113,6 +111,7 @@ void OPENSSL_config(void)
                        BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
                        BIO_printf(bio_err,"Auto configuration failed\n");
                        ERR_print_errors(bio_err);
+                       BIO_free(bio_err);
                        }
                exit(1);
                }
index 23e1f191da5b0cda12e0be9d933d33b248934488..426d69337f7307339c1913bb82c59e9ed591ed9d 100644 (file)
@@ -170,7 +170,15 @@ int CONF_modules_load_file(const char *filename, const char *appname,
                goto err;
 
        if (NCONF_load(conf, filename, 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);