Make no config file not an error. Move /dev/crypto config to ctrl.
authorBen Laurie <ben@openssl.org>
Tue, 22 Jan 2002 22:29:58 +0000 (22:29 +0000)
committerBen Laurie <ben@openssl.org>
Tue, 22 Jan 2002 22:29:58 +0000 (22:29 +0000)
crypto/bio/bio.h
crypto/bio/bio_err.c
crypto/bio/bss_file.c
crypto/conf/conf.h
crypto/conf/conf_def.c
crypto/conf/conf_err.c
crypto/conf/conf_mall.c
crypto/engine/hw_openbsd_dev_crypto.c
crypto/err/err.c
crypto/err/err.h

index 4fa420a6b0b603c243beee721edf546310d5368f..44861f393af8028b90579c8b7d26d035254ca86c 100644 (file)
@@ -618,7 +618,6 @@ int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args);
  * made after this point may be overwritten when the script is next run.
  */
 void ERR_load_BIO_strings(void);
-
 /* Error codes for the BIO functions. */
 
 /* Function codes. */
@@ -673,6 +672,7 @@ void ERR_load_BIO_strings(void);
 #define BIO_R_NO_HOSTNAME_SPECIFIED                     112
 #define BIO_R_NO_PORT_DEFINED                           113
 #define BIO_R_NO_PORT_SPECIFIED                                 114
+#define BIO_R_NO_SUCH_FILE                              128
 #define BIO_R_NULL_PARAMETER                            115
 #define BIO_R_TAG_MISMATCH                              116
 #define BIO_R_UNABLE_TO_BIND_SOCKET                     117
index 927b1ac47678848afcc315a3d1f9316dff5d70d9..99ca3cd0da925ab43974afa98af77b80d455a4c3 100644 (file)
@@ -120,6 +120,7 @@ static ERR_STRING_DATA BIO_str_reasons[]=
 {BIO_R_NO_HOSTNAME_SPECIFIED             ,"no hostname specified"},
 {BIO_R_NO_PORT_DEFINED                   ,"no port defined"},
 {BIO_R_NO_PORT_SPECIFIED                 ,"no port specified"},
+{BIO_R_NO_SUCH_FILE                      ,"no such file"},
 {BIO_R_NULL_PARAMETER                    ,"null parameter"},
 {BIO_R_TAG_MISMATCH                      ,"tag mismatch"},
 {BIO_R_UNABLE_TO_BIND_SOCKET             ,"unable to bind socket"},
index 0dee7fa34874c7decb755b15c66403d4572f5452..e3af936374020385a2e50d991352feeb33ff1fcb 100644 (file)
@@ -103,7 +103,10 @@ BIO *BIO_new_file(const char *filename, const char *mode)
                {
                SYSerr(SYS_F_FOPEN,get_last_sys_error());
                ERR_add_error_data(5,"fopen('",filename,"','",mode,"')");
-               BIOerr(BIO_F_BIO_NEW_FILE,ERR_R_SYS_LIB);
+               if(errno == ENOENT)
+                       BIOerr(BIO_F_BIO_NEW_FILE,BIO_R_NO_SUCH_FILE);
+               else
+                       BIOerr(BIO_F_BIO_NEW_FILE,ERR_R_SYS_LIB);
                return(NULL);
                }
        if ((ret=BIO_new(BIO_s_file_internal())) == NULL)
index a0bbeb4d584b24ba4cb3bc9757f28108049d6bca..a179a5f61263f368bbf7d5456fc3752d6d6556cf 100644 (file)
@@ -232,6 +232,7 @@ void ERR_load_CONF_strings(void);
 #define CONF_R_NO_CONF                                  105
 #define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE          106
 #define CONF_R_NO_SECTION                               107
+#define CONF_R_NO_SUCH_FILE                             114
 #define CONF_R_NO_VALUE                                         108
 #define CONF_R_UNABLE_TO_CREATE_NEW_SECTION             103
 #define CONF_R_UNKNOWN_MODULE_NAME                      113
index 04d128bc75b529a5216dd395c55f2764418b887a..20b0760fcd958f835b99a4640d74aa4db240f6b4 100644 (file)
@@ -192,7 +192,10 @@ static int def_load(CONF *conf, const char *name, long *line)
 #endif
        if (in == NULL)
                {
-               CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB);
+               if(ERR_GET_REASON(ERR_peek_top_error()) == BIO_R_NO_SUCH_FILE)
+                       CONFerr(CONF_F_CONF_LOAD,CONF_R_NO_SUCH_FILE);
+               else
+                       CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB);
                return 0;
                }
 
index e1bd8b3b2cd7cbae8d30404fe9960300c1f6b641..ee07bfe9d9326b40baf3db6e7edaed5d1fea6901 100644 (file)
@@ -100,6 +100,7 @@ static ERR_STRING_DATA CONF_str_reasons[]=
 {CONF_R_NO_CONF                          ,"no conf"},
 {CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE  ,"no conf or environment variable"},
 {CONF_R_NO_SECTION                       ,"no section"},
+{CONF_R_NO_SUCH_FILE                     ,"no such file"},
 {CONF_R_NO_VALUE                         ,"no value"},
 {CONF_R_UNABLE_TO_CREATE_NEW_SECTION     ,"unable to create new section"},
 {CONF_R_UNKNOWN_MODULE_NAME              ,"unknown module name"},
index 814d5df8774c070fd73133935cfe2a4229d47400..59c7cfb966bace733a923059c0d2dacd2f0e5e15 100644 (file)
@@ -92,9 +92,10 @@ void OPENSSL_config(void)
        if (!file)
                return;
 
-       ret = CONF_modules_load_file(file, "openssl_config", 0);
+       ret=CONF_modules_load_file(file, "openssl_config", 0) <= 0
+         && ERR_GET_REASON(ERR_peek_top_error()) != CONF_R_NO_SUCH_FILE;
        OPENSSL_free(file);
-       if (ret <= 0)
+       if (ret)
                {
                BIO *bio_err;
                ERR_load_crypto_strings();
index 8085323ed191d22797d471306da4e195f9f358dd..f946389b8a31bc9e867702d9cbb7ecfb2687d006 100644 (file)
@@ -96,12 +96,25 @@ static const char dev_crypto_name[] = "OpenBSD /dev/crypto";
 
 static long allow_misaligned;
 
-static int init_conf(CONF_IMODULE *md,const CONF *conf)
+#define DEV_CRYPTO_CMD_ALLOW_MISALIGNED                ENGINE_CMD_BASE
+static const ENGINE_CMD_DEFN dev_crypto_cmd_defns[]=
        {
-       if(!NCONF_get_number(conf,CONF_imodule_get_value(md),"allow_misaligned",
-                                                &allow_misaligned))
-               return 0;
-       printf("allow misaligned=%ld\n",allow_misaligned);
+       { DEV_CRYPTO_CMD_ALLOW_MISALIGNED,
+         "allow_misaligned",
+         "Permit misaligned data to be used",
+         ENGINE_CMD_FLAG_NUMERIC },
+       { 0, NULL, NULL, 0 }
+       };
+
+static int dev_crypto_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
+       {
+       switch(cmd)
+               {
+       case DEV_CRYPTO_CMD_ALLOW_MISALIGNED:
+               allow_misaligned=i;
+               printf("allow misaligned=%ld\n",allow_misaligned);
+               break;
+               }
 
        return 1;
        }
@@ -110,11 +123,12 @@ static ENGINE *engine_openbsd_dev_crypto(void)
        {
        ENGINE *engine=ENGINE_new();
 
-       CONF_module_add(dev_crypto_id,init_conf,NULL);
        if(!ENGINE_set_id(engine, dev_crypto_id) ||
-                       !ENGINE_set_name(engine, dev_crypto_name) ||
-                       !ENGINE_set_ciphers(engine, dev_crypto_ciphers) ||
-                       !ENGINE_set_digests(engine, dev_crypto_digests))
+          !ENGINE_set_name(engine, dev_crypto_name) ||
+          !ENGINE_set_ciphers(engine, dev_crypto_ciphers) ||
+          !ENGINE_set_digests(engine, dev_crypto_digests) ||
+          !ENGINE_set_ctrl_function(engine, dev_crypto_ctrl) ||
+          !ENGINE_set_cmd_defns(engine, dev_crypto_cmd_defns))
                {
                ENGINE_free(engine);
                return NULL;
index f38d1a61da65434c079db21f2d5d590f1e139107..1b1e9bbcb0cdac4e5e354c52f67dfa34bdc047c2 100644 (file)
@@ -679,6 +679,13 @@ unsigned long ERR_get_error_line_data(const char **file, int *line,
 unsigned long ERR_peek_error(void)
        { return(get_error_values(0,NULL,NULL,NULL,NULL)); }
 
+unsigned long ERR_peek_top_error(void)
+       {
+       ERR_STATE *es=ERR_get_state();
+
+       return es->err_buffer[es->top];
+       }
+
 unsigned long ERR_peek_error_line(const char **file,
             int *line)
        { return(get_error_values(0,file,line,NULL,NULL)); }
index c20546be51b33806ef13b9ad0f3d706fdee92f69..4456e0e97176a3a8058bc86ef3d66662ed679934 100644 (file)
@@ -243,6 +243,7 @@ unsigned long ERR_get_error_line(const char **file,int *line);
 unsigned long ERR_get_error_line_data(const char **file,int *line,
                                      const char **data, int *flags);
 unsigned long ERR_peek_error(void );
+unsigned long ERR_peek_top_error(void);
 unsigned long ERR_peek_error_line(const char **file,int *line);
 unsigned long ERR_peek_error_line_data(const char **file,int *line,
                                       const char **data,int *flags);