conf_mod.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/* conf_mod.c */
/* Written by Stephen Henson (shenson@bigfoot.com) for the OpenSSL
* project 2001.
*/
/* ====================================================================
* Copyright (c) 2001 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
*
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* licensing@OpenSSL.org.
*
* 5. Products derived from this software may not be called "OpenSSL"
* nor may "OpenSSL" appear in their names without prior written
* permission of the OpenSSL Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
*
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This product includes cryptographic software written by Eric Young
* (eay@cryptsoft.com). This product includes software written by Tim
* Hudson (tjh@cryptsoft.com).
*
*/
#include <stdio.h>
#include <ctype.h>
#include "cryptlib.h"
#define DSO_mod_init_name "OPENSSL_init"
#define DSO_mod_finish_name "OPENSSL_finish"
/* This structure contains a data about supported modules.
* entries in this table correspond to either dynamic or
* static modules.
*/
struct conf_module_st
{
/* DSO of this module or NULL if static */
/* Name of the module */
char *name;
/* Init function */
/* Finish function */
/* Number of successfully initialized modules */
int links;
void *usr_data;
};
/* This structure contains information about modules that have been
* successfully initialized. There may be more than one entry for a
* given module.
*/
struct conf_imodule_st
{
char *name;
char *value;
unsigned long flags;
void *usr_data;
};
unsigned long flags);
unsigned long flags);
/* Main function: load modules from a CONF structure */
unsigned long flags)
{
CONF_VALUE *vl;
char *vsection;
int ret, i;
if (!cnf)
return 1;
appname = "openssl_conf";
if (!vsection)
{
return 1;
}
if (!values)
return 0;
for (i = 0; i < sk_CONF_VALUE_num(values); i++)
{
if (ret <= 0)
if(!(flags & CONF_MFLAGS_IGNORE_ERRORS))
return ret;
}
return 1;
}
unsigned long flags)
{
int ret = 0;
if (!conf)
goto err;
{
if (!file)
goto err;
}
else
{
if ((flags & CONF_MFLAGS_IGNORE_MISSING_FILE) &&
{
ret = 1;
}
goto err;
}
err:
return ret;
}
unsigned long flags)
{
int ret;
/* Module not found: try to load DSO */
if (!md)
{
if (!(flags & CONF_MFLAGS_SILENT))
{
}
return -1;
}
if (ret <= 0)
{
if (!(flags & CONF_MFLAGS_SILENT))
{
}
}
return ret;
}
/* Load a module from a DSO */
unsigned long flags)
{
int errcode = 0;
/* Look for alternative path in module section */
if (!path)
{
}
if (!dso)
{
goto err;
}
if (!ifunc)
{
goto err;
}
/* All OK, add module */
if (!md)
goto err;
return md;
err:
if (dso)
return NULL;
}
/* add module to list */
{
if (supported_modules == NULL)
if (supported_modules == NULL)
return NULL;
return NULL;
{
return NULL;
}
return tmod;
}
/* Find a module from the list. We allow module names of the
* form modname.XXXX to just search for modname to allow the
* same module to be initialized more than once.
*/
{
int i, nchar;
char *p;
if (p)
else
for (i = 0; i < sk_CONF_MODULE_num(supported_modules); i++)
{
return tmod;
}
return NULL;
}
/* initialize a module */
{
int ret = 1;
int init_called = 0;
/* Otherwise add initialized module to list */
if (!imod)
goto err;
goto memerr;
/* Try to initialize module */
{
init_called = 1;
/* Error occurred, exit */
if (ret <= 0)
goto err;
}
if (initialized_modules == NULL)
{
if (!initialized_modules)
{
goto err;
}
}
{
goto err;
}
return ret;
err:
/* We've started the module so we'd better finish it */
if (imod)
{
}
return -1;
}
/* Unload any dynamic modules that have a link count of zero:
* i.e. have no active initialized modules. If 'all' is set
* then all modules are unloaded including static ones.
*/
void CONF_modules_unload(int all)
{
int i;
/* unload modules in reverse order */
{
/* If static or in use and 'all' not set ignore it */
continue;
/* Since we're working in reverse this is OK */
}
if (sk_CONF_MODULE_num(supported_modules) == 0)
{
}
}
/* unload a single module */
{
}
/* finish and free up all modules instances */
void CONF_modules_finish(void)
{
while (sk_CONF_IMODULE_num(initialized_modules) > 0)
{
}
}
/* finish a module instance */
{
}
/* Add a static module to OpenSSL */
{
return 1;
else
return 0;
}
void CONF_modules_free(void)
{
}
/* Utility functions */
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
/* Return default config file name */
char *CONF_get1_default_config_file(void)
{
char *file;
int len;
if (file)
return BUF_strdup(file);
#ifndef OPENSSL_SYS_VMS
len++;
#endif
if (!file)
return NULL;
#ifndef OPENSSL_SYS_VMS
#endif
return file;
}
/* This function takes a list separated by 'sep' and calls the
* callback function giving the start and length of each member
* optionally stripping leading and trailing whitespace. This can
* be used to parse comma separated lists for example.
*/
{
int ret;
for(;;)
{
if (nospc)
{
lstart++;
}
else
{
if (p)
tmpend = p - 1;
else
if (nospc)
{
tmpend--;
}
}
if (ret <= 0)
return ret;
if (p == NULL)
return 1;
lstart = p + 1;
}
}