2002-07-15 15:35:40 +00:00
|
|
|
/* dso_vms.c -*- mode:C; c-file-style: "eay" -*- */
|
2000-09-15 21:22:50 +00:00
|
|
|
/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
|
|
|
|
* project 2000.
|
|
|
|
*/
|
|
|
|
/* ====================================================================
|
|
|
|
* Copyright (c) 2000 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
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* 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 <string.h>
|
|
|
|
#include <errno.h>
|
2001-02-20 13:23:42 +00:00
|
|
|
#include "cryptlib.h"
|
|
|
|
#include <openssl/dso.h>
|
2001-02-20 08:13:47 +00:00
|
|
|
#ifdef OPENSSL_SYS_VMS
|
2000-09-17 14:42:46 +00:00
|
|
|
#pragma message disable DOLLARID
|
2002-07-15 15:35:40 +00:00
|
|
|
#include <rms.h>
|
2000-09-15 21:22:50 +00:00
|
|
|
#include <lib$routines.h>
|
|
|
|
#include <stsdef.h>
|
|
|
|
#include <descrip.h>
|
|
|
|
#include <starlet.h>
|
2000-09-15 22:12:53 +00:00
|
|
|
#endif
|
2000-09-15 21:22:50 +00:00
|
|
|
|
2001-02-20 08:13:47 +00:00
|
|
|
#ifndef OPENSSL_SYS_VMS
|
2000-09-15 21:22:50 +00:00
|
|
|
DSO_METHOD *DSO_METHOD_vms(void)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#pragma message disable DOLLARID
|
|
|
|
|
This changes the behaviour of the DSO mechanism for determining an
appropriate filename translation on the host system. Apart from this point,
users should also note that there's a slight change in the API functions
too. The DSO now contains its own to-be-converted filename
("dso->filename"), and at the time the DSO loads the "dso->loaded_filename"
value is set to the translated form. As such, this also provides an impicit
way of determining if the DSO is currently loaded or not. Except, perhaps,
VMS .... :-)
The various DSO_METHODs have been updated for this mechanism except VMS
which is deliberately broken for now, Richard is going to look at how to
fit it in (the source comments in there explain "the issue").
Basically, the new callback scheme allows the filename conversion to
(a) be turned off altogether through the use of the
DSO_FLAG_NO_NAME_TRANSLATION flag,
(b) be handled in the default way using the default DSO_METHOD's converter
(c) overriden per-DSO by setting the override callback
(d) a mix of (b) and (c) - eg. implement an override callback that;
(i) checks if we're win32 "if(strstr(dso->meth->name, "win32"))..."
and if so, convert "blah" into "blah32.dll" (the default is
otherwise to make it "blah.dll").
(ii) default to the normal behaviour - eg. we're not on win32, so
finish with (return dso->meth->dso_name_converter(dso,NULL)).
(e) be retried a number of times by writing a new DSO_METHOD where the
"dso_load()" handler will call the converter repeatedly. Then the
custom converter could use state information in the DSO to suggest
different conversions or paths each time it is invoked.
2000-10-26 17:38:59 +00:00
|
|
|
static int vms_load(DSO *dso);
|
2000-09-15 21:22:50 +00:00
|
|
|
static int vms_unload(DSO *dso);
|
|
|
|
static void *vms_bind_var(DSO *dso, const char *symname);
|
|
|
|
static DSO_FUNC_TYPE vms_bind_func(DSO *dso, const char *symname);
|
|
|
|
#if 0
|
|
|
|
static int vms_unbind_var(DSO *dso, char *symname, void *symptr);
|
|
|
|
static int vms_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr);
|
|
|
|
static int vms_init(DSO *dso);
|
|
|
|
static int vms_finish(DSO *dso);
|
|
|
|
static long vms_ctrl(DSO *dso, int cmd, long larg, void *parg);
|
2000-10-08 22:36:49 +00:00
|
|
|
#endif
|
2001-02-20 13:23:42 +00:00
|
|
|
static char *vms_name_converter(DSO *dso, const char *filename);
|
2002-07-15 15:35:40 +00:00
|
|
|
static char *vms_merger(DSO *dso, const char *filespec1,
|
|
|
|
const char *filespec2);
|
2000-09-15 21:22:50 +00:00
|
|
|
|
|
|
|
static DSO_METHOD dso_meth_vms = {
|
|
|
|
"OpenSSL 'VMS' shared library method",
|
|
|
|
vms_load,
|
|
|
|
NULL, /* unload */
|
|
|
|
vms_bind_var,
|
|
|
|
vms_bind_func,
|
|
|
|
/* For now, "unbind" doesn't exist */
|
|
|
|
#if 0
|
|
|
|
NULL, /* unbind_var */
|
|
|
|
NULL, /* unbind_func */
|
|
|
|
#endif
|
2000-10-08 22:36:49 +00:00
|
|
|
NULL, /* ctrl */
|
This changes the behaviour of the DSO mechanism for determining an
appropriate filename translation on the host system. Apart from this point,
users should also note that there's a slight change in the API functions
too. The DSO now contains its own to-be-converted filename
("dso->filename"), and at the time the DSO loads the "dso->loaded_filename"
value is set to the translated form. As such, this also provides an impicit
way of determining if the DSO is currently loaded or not. Except, perhaps,
VMS .... :-)
The various DSO_METHODs have been updated for this mechanism except VMS
which is deliberately broken for now, Richard is going to look at how to
fit it in (the source comments in there explain "the issue").
Basically, the new callback scheme allows the filename conversion to
(a) be turned off altogether through the use of the
DSO_FLAG_NO_NAME_TRANSLATION flag,
(b) be handled in the default way using the default DSO_METHOD's converter
(c) overriden per-DSO by setting the override callback
(d) a mix of (b) and (c) - eg. implement an override callback that;
(i) checks if we're win32 "if(strstr(dso->meth->name, "win32"))..."
and if so, convert "blah" into "blah32.dll" (the default is
otherwise to make it "blah.dll").
(ii) default to the normal behaviour - eg. we're not on win32, so
finish with (return dso->meth->dso_name_converter(dso,NULL)).
(e) be retried a number of times by writing a new DSO_METHOD where the
"dso_load()" handler will call the converter repeatedly. Then the
custom converter could use state information in the DSO to suggest
different conversions or paths each time it is invoked.
2000-10-26 17:38:59 +00:00
|
|
|
vms_name_converter,
|
2002-07-15 15:35:40 +00:00
|
|
|
vms_merger,
|
2000-09-15 21:22:50 +00:00
|
|
|
NULL, /* init */
|
|
|
|
NULL /* finish */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* On VMS, the only "handle" is the file name. LIB$FIND_IMAGE_SYMBOL depends
|
|
|
|
* on the reference to the file name being the same for all calls regarding
|
|
|
|
* one shared image, so we'll just store it in an instance of the following
|
|
|
|
* structure and put a pointer to that instance in the meth_data stack.
|
|
|
|
*/
|
|
|
|
typedef struct dso_internal_st
|
|
|
|
{
|
|
|
|
/* This should contain the name only, no directory,
|
|
|
|
* no extension, nothing but a name. */
|
|
|
|
struct dsc$descriptor_s filename_dsc;
|
|
|
|
char filename[FILENAME_MAX+1];
|
|
|
|
/* This contains whatever is not in filename, if needed.
|
|
|
|
* Normally not defined. */
|
|
|
|
struct dsc$descriptor_s imagename_dsc;
|
|
|
|
char imagename[FILENAME_MAX+1];
|
|
|
|
} DSO_VMS_INTERNAL;
|
|
|
|
|
|
|
|
|
|
|
|
DSO_METHOD *DSO_METHOD_vms(void)
|
|
|
|
{
|
|
|
|
return(&dso_meth_vms);
|
|
|
|
}
|
|
|
|
|
This changes the behaviour of the DSO mechanism for determining an
appropriate filename translation on the host system. Apart from this point,
users should also note that there's a slight change in the API functions
too. The DSO now contains its own to-be-converted filename
("dso->filename"), and at the time the DSO loads the "dso->loaded_filename"
value is set to the translated form. As such, this also provides an impicit
way of determining if the DSO is currently loaded or not. Except, perhaps,
VMS .... :-)
The various DSO_METHODs have been updated for this mechanism except VMS
which is deliberately broken for now, Richard is going to look at how to
fit it in (the source comments in there explain "the issue").
Basically, the new callback scheme allows the filename conversion to
(a) be turned off altogether through the use of the
DSO_FLAG_NO_NAME_TRANSLATION flag,
(b) be handled in the default way using the default DSO_METHOD's converter
(c) overriden per-DSO by setting the override callback
(d) a mix of (b) and (c) - eg. implement an override callback that;
(i) checks if we're win32 "if(strstr(dso->meth->name, "win32"))..."
and if so, convert "blah" into "blah32.dll" (the default is
otherwise to make it "blah.dll").
(ii) default to the normal behaviour - eg. we're not on win32, so
finish with (return dso->meth->dso_name_converter(dso,NULL)).
(e) be retried a number of times by writing a new DSO_METHOD where the
"dso_load()" handler will call the converter repeatedly. Then the
custom converter could use state information in the DSO to suggest
different conversions or paths each time it is invoked.
2000-10-26 17:38:59 +00:00
|
|
|
static int vms_load(DSO *dso)
|
2000-09-15 21:22:50 +00:00
|
|
|
{
|
2000-12-31 01:55:46 +00:00
|
|
|
void *ptr = NULL;
|
|
|
|
/* See applicable comments in dso_dl.c */
|
|
|
|
char *filename = DSO_convert_filename(dso, NULL);
|
2000-09-15 21:22:50 +00:00
|
|
|
DSO_VMS_INTERNAL *p;
|
|
|
|
const char *sp1, *sp2; /* Search result */
|
|
|
|
|
2000-12-31 01:55:46 +00:00
|
|
|
if(filename == NULL)
|
|
|
|
{
|
|
|
|
DSOerr(DSO_F_DLFCN_LOAD,DSO_R_NO_FILENAME);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2000-09-15 21:22:50 +00:00
|
|
|
/* A file specification may look like this:
|
|
|
|
*
|
|
|
|
* node::dev:[dir-spec]name.type;ver
|
|
|
|
*
|
|
|
|
* or (for compatibility with TOPS-20):
|
|
|
|
*
|
|
|
|
* node::dev:<dir-spec>name.type;ver
|
|
|
|
*
|
|
|
|
* and the dir-spec uses '.' as separator. Also, a dir-spec
|
|
|
|
* may consist of several parts, with mixed use of [] and <>:
|
|
|
|
*
|
|
|
|
* [dir1.]<dir2>
|
|
|
|
*
|
|
|
|
* We need to split the file specification into the name and
|
|
|
|
* the rest (both before and after the name itself).
|
|
|
|
*/
|
|
|
|
/* Start with trying to find the end of a dir-spec, and save the
|
|
|
|
position of the byte after in sp1 */
|
|
|
|
sp1 = strrchr(filename, ']');
|
|
|
|
sp2 = strrchr(filename, '>');
|
|
|
|
if (sp1 == NULL) sp1 = sp2;
|
|
|
|
if (sp2 != NULL && sp2 > sp1) sp1 = sp2;
|
|
|
|
if (sp1 == NULL) sp1 = strrchr(filename, ':');
|
|
|
|
if (sp1 == NULL)
|
|
|
|
sp1 = filename;
|
|
|
|
else
|
|
|
|
sp1++; /* The byte after the found character */
|
|
|
|
/* Now, let's see if there's a type, and save the position in sp2 */
|
|
|
|
sp2 = strchr(sp1, '.');
|
|
|
|
/* If we found it, that's where we'll cut. Otherwise, look for a
|
|
|
|
version number and save the position in sp2 */
|
|
|
|
if (sp2 == NULL) sp2 = strchr(sp1, ';');
|
|
|
|
/* If there was still nothing to find, set sp2 to point at the end of
|
|
|
|
the string */
|
|
|
|
if (sp2 == NULL) sp2 = sp1 + strlen(sp1);
|
|
|
|
|
|
|
|
/* Check that we won't get buffer overflows */
|
|
|
|
if (sp2 - sp1 > FILENAME_MAX
|
|
|
|
|| (sp1 - filename) + strlen(sp2) > FILENAME_MAX)
|
|
|
|
{
|
|
|
|
DSOerr(DSO_F_VMS_LOAD,DSO_R_FILENAME_TOO_BIG);
|
2000-12-31 01:55:46 +00:00
|
|
|
goto err;
|
2000-09-15 21:22:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
p = (DSO_VMS_INTERNAL *)OPENSSL_malloc(sizeof(DSO_VMS_INTERNAL));
|
|
|
|
if(p == NULL)
|
|
|
|
{
|
|
|
|
DSOerr(DSO_F_VMS_LOAD,ERR_R_MALLOC_FAILURE);
|
2000-12-31 01:55:46 +00:00
|
|
|
goto err;
|
2000-09-15 21:22:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
strncpy(p->filename, sp1, sp2-sp1);
|
|
|
|
p->filename[sp2-sp1] = '\0';
|
|
|
|
|
|
|
|
strncpy(p->imagename, filename, sp1-filename);
|
|
|
|
p->imagename[sp1-filename] = '\0';
|
|
|
|
strcat(p->imagename, sp2);
|
|
|
|
|
|
|
|
p->filename_dsc.dsc$w_length = strlen(p->filename);
|
|
|
|
p->filename_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
|
|
|
|
p->filename_dsc.dsc$b_class = DSC$K_CLASS_S;
|
|
|
|
p->filename_dsc.dsc$a_pointer = p->filename;
|
|
|
|
p->imagename_dsc.dsc$w_length = strlen(p->imagename);
|
|
|
|
p->imagename_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
|
|
|
|
p->imagename_dsc.dsc$b_class = DSC$K_CLASS_S;
|
|
|
|
p->imagename_dsc.dsc$a_pointer = p->imagename;
|
|
|
|
|
|
|
|
if(!sk_push(dso->meth_data, (char *)p))
|
|
|
|
{
|
|
|
|
DSOerr(DSO_F_VMS_LOAD,DSO_R_STACK_ERROR);
|
2000-12-31 01:55:46 +00:00
|
|
|
goto err;
|
2000-09-15 21:22:50 +00:00
|
|
|
}
|
2000-12-31 01:55:46 +00:00
|
|
|
|
|
|
|
/* Success (for now, we lie. We actually do not know...) */
|
|
|
|
dso->loaded_filename = filename;
|
2000-09-15 21:22:50 +00:00
|
|
|
return(1);
|
2000-12-31 01:55:46 +00:00
|
|
|
err:
|
|
|
|
/* Cleanup! */
|
|
|
|
if(p != NULL)
|
|
|
|
OPENSSL_free(p);
|
|
|
|
if(filename != NULL)
|
|
|
|
OPENSSL_free(filename);
|
|
|
|
return(0);
|
2000-09-15 21:22:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Note that this doesn't actually unload the shared image, as there is no
|
|
|
|
* such thing in VMS. Next time it get loaded again, a new copy will
|
|
|
|
* actually be loaded.
|
|
|
|
*/
|
|
|
|
static int vms_unload(DSO *dso)
|
|
|
|
{
|
|
|
|
DSO_VMS_INTERNAL *p;
|
|
|
|
if(dso == NULL)
|
|
|
|
{
|
|
|
|
DSOerr(DSO_F_VMS_UNLOAD,ERR_R_PASSED_NULL_PARAMETER);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
if(sk_num(dso->meth_data) < 1)
|
|
|
|
return(1);
|
|
|
|
p = (DSO_VMS_INTERNAL *)sk_pop(dso->meth_data);
|
|
|
|
if(p == NULL)
|
|
|
|
{
|
|
|
|
DSOerr(DSO_F_VMS_UNLOAD,DSO_R_NULL_HANDLE);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
/* Cleanup */
|
|
|
|
OPENSSL_free(p);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We must do this in a separate function because of the way the exception
|
|
|
|
handler works (it makes this function return */
|
|
|
|
static int do_find_symbol(DSO_VMS_INTERNAL *ptr,
|
|
|
|
struct dsc$descriptor_s *symname_dsc, void **sym,
|
|
|
|
unsigned long flags)
|
|
|
|
{
|
|
|
|
/* Make sure that signals are caught and returned instead of
|
|
|
|
aborting the program. The exception handler gets unestablished
|
|
|
|
automatically on return from this function. */
|
|
|
|
lib$establish(lib$sig_to_ret);
|
|
|
|
|
|
|
|
if(ptr->imagename_dsc.dsc$w_length)
|
|
|
|
return lib$find_image_symbol(&ptr->filename_dsc,
|
|
|
|
symname_dsc, sym,
|
|
|
|
&ptr->imagename_dsc, flags);
|
|
|
|
else
|
|
|
|
return lib$find_image_symbol(&ptr->filename_dsc,
|
|
|
|
symname_dsc, sym,
|
|
|
|
0, flags);
|
|
|
|
}
|
|
|
|
|
2000-09-17 14:42:46 +00:00
|
|
|
void vms_bind_sym(DSO *dso, const char *symname, void **sym)
|
2000-09-15 21:22:50 +00:00
|
|
|
{
|
|
|
|
DSO_VMS_INTERNAL *ptr;
|
|
|
|
int status;
|
2001-11-16 13:12:19 +00:00
|
|
|
#if 0
|
2001-04-03 08:31:39 +00:00
|
|
|
int flags = (1<<4); /* LIB$M_FIS_MIXEDCASE, but this symbol isn't
|
|
|
|
defined in VMS older than 7.0 or so */
|
2001-11-16 13:12:19 +00:00
|
|
|
#else
|
|
|
|
int flags = 0;
|
|
|
|
#endif
|
2000-09-15 21:22:50 +00:00
|
|
|
struct dsc$descriptor_s symname_dsc;
|
2000-09-17 14:42:46 +00:00
|
|
|
*sym = NULL;
|
2000-09-15 21:22:50 +00:00
|
|
|
|
|
|
|
symname_dsc.dsc$w_length = strlen(symname);
|
|
|
|
symname_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
|
|
|
|
symname_dsc.dsc$b_class = DSC$K_CLASS_S;
|
|
|
|
symname_dsc.dsc$a_pointer = (char *)symname; /* The cast is needed */
|
|
|
|
|
|
|
|
if((dso == NULL) || (symname == NULL))
|
|
|
|
{
|
|
|
|
DSOerr(DSO_F_VMS_BIND_VAR,ERR_R_PASSED_NULL_PARAMETER);
|
2000-09-17 14:42:46 +00:00
|
|
|
return;
|
2000-09-15 21:22:50 +00:00
|
|
|
}
|
|
|
|
if(sk_num(dso->meth_data) < 1)
|
|
|
|
{
|
|
|
|
DSOerr(DSO_F_VMS_BIND_VAR,DSO_R_STACK_ERROR);
|
2000-09-17 14:42:46 +00:00
|
|
|
return;
|
2000-09-15 21:22:50 +00:00
|
|
|
}
|
|
|
|
ptr = (DSO_VMS_INTERNAL *)sk_value(dso->meth_data,
|
|
|
|
sk_num(dso->meth_data) - 1);
|
|
|
|
if(ptr == NULL)
|
|
|
|
{
|
|
|
|
DSOerr(DSO_F_VMS_BIND_VAR,DSO_R_NULL_HANDLE);
|
2000-09-17 14:42:46 +00:00
|
|
|
return;
|
2000-09-15 21:22:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(dso->flags & DSO_FLAG_UPCASE_SYMBOL) flags = 0;
|
|
|
|
|
2000-09-17 14:42:46 +00:00
|
|
|
status = do_find_symbol(ptr, &symname_dsc, sym, flags);
|
2000-09-15 21:22:50 +00:00
|
|
|
|
|
|
|
if(!$VMS_STATUS_SUCCESS(status))
|
|
|
|
{
|
|
|
|
unsigned short length;
|
|
|
|
char errstring[257];
|
|
|
|
struct dsc$descriptor_s errstring_dsc;
|
|
|
|
|
|
|
|
errstring_dsc.dsc$w_length = sizeof(errstring);
|
|
|
|
errstring_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
|
|
|
|
errstring_dsc.dsc$b_class = DSC$K_CLASS_S;
|
|
|
|
errstring_dsc.dsc$a_pointer = errstring;
|
|
|
|
|
2000-09-17 14:42:46 +00:00
|
|
|
*sym = NULL;
|
|
|
|
|
2000-09-15 21:22:50 +00:00
|
|
|
status = sys$getmsg(status, &length, &errstring_dsc, 1, 0);
|
|
|
|
|
|
|
|
if (!$VMS_STATUS_SUCCESS(status))
|
|
|
|
lib$signal(status); /* This is really bad. Abort! */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
errstring[length] = '\0';
|
|
|
|
|
|
|
|
DSOerr(DSO_F_VMS_BIND_VAR,DSO_R_SYM_FAILURE);
|
|
|
|
if (ptr->imagename_dsc.dsc$w_length)
|
|
|
|
ERR_add_error_data(9,
|
|
|
|
"Symbol ", symname,
|
|
|
|
" in ", ptr->filename,
|
|
|
|
" (", ptr->imagename, ")",
|
|
|
|
": ", errstring);
|
|
|
|
else
|
|
|
|
ERR_add_error_data(6,
|
|
|
|
"Symbol ", symname,
|
|
|
|
" in ", ptr->filename,
|
|
|
|
": ", errstring);
|
|
|
|
}
|
2000-09-17 14:42:46 +00:00
|
|
|
return;
|
2000-09-15 21:22:50 +00:00
|
|
|
}
|
2000-09-17 14:42:46 +00:00
|
|
|
return;
|
2000-09-15 21:22:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *vms_bind_var(DSO *dso, const char *symname)
|
|
|
|
{
|
2000-09-17 14:42:46 +00:00
|
|
|
void *sym = 0;
|
|
|
|
vms_bind_sym(dso, symname, &sym);
|
|
|
|
return sym;
|
2000-09-15 21:22:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static DSO_FUNC_TYPE vms_bind_func(DSO *dso, const char *symname)
|
|
|
|
{
|
2000-09-17 14:42:46 +00:00
|
|
|
DSO_FUNC_TYPE sym = 0;
|
2000-09-18 08:40:55 +00:00
|
|
|
vms_bind_sym(dso, symname, (void **)&sym);
|
2000-09-17 14:42:46 +00:00
|
|
|
return sym;
|
2000-09-15 21:22:50 +00:00
|
|
|
}
|
|
|
|
|
2002-07-15 15:35:40 +00:00
|
|
|
static char *vms_merger(DSO *dso, const char *filespec1, const char *filespec2)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
int filespec1len, filespec2len;
|
|
|
|
struct FAB fab;
|
|
|
|
#ifdef NAML$C_MAXRSS
|
|
|
|
struct NAML nam;
|
|
|
|
char esa[NAML$C_MAXRSS];
|
|
|
|
#else
|
|
|
|
struct NAM nam;
|
|
|
|
char esa[NAM$C_MAXRSS];
|
|
|
|
#endif
|
|
|
|
char *merged;
|
|
|
|
|
|
|
|
if (!filespec1) filespec1 = "";
|
|
|
|
if (!filespec2) filespec2 = "";
|
|
|
|
filespec1len = strlen(filespec1);
|
|
|
|
filespec2len = strlen(filespec2);
|
|
|
|
|
|
|
|
fab = cc$rms_fab;
|
|
|
|
#ifdef NAML$C_MAXRSS
|
|
|
|
nam = cc$rms_naml;
|
|
|
|
#else
|
|
|
|
nam = cc$rms_nam;
|
|
|
|
#endif
|
|
|
|
|
2002-07-19 11:57:17 +00:00
|
|
|
fab.fab$l_fna = (char *)filespec1;
|
2002-07-15 15:35:40 +00:00
|
|
|
fab.fab$b_fns = filespec1len;
|
2002-07-19 11:57:17 +00:00
|
|
|
fab.fab$l_dna = (char *)filespec2;
|
2002-07-15 15:35:40 +00:00
|
|
|
fab.fab$b_dns = filespec2len;
|
|
|
|
#ifdef NAML$C_MAXRSS
|
|
|
|
if (filespec1len > NAM$C_MAXRSS)
|
|
|
|
{
|
2002-07-19 11:57:17 +00:00
|
|
|
fab.fab$l_fna = 0;
|
2002-07-15 15:35:40 +00:00
|
|
|
fab.fab$b_fns = 0;
|
2002-07-19 11:57:17 +00:00
|
|
|
nam.naml$l_long_filename = (char *)filespec1;
|
2002-07-15 15:35:40 +00:00
|
|
|
nam.naml$l_long_filename_size = filespec1len;
|
|
|
|
}
|
|
|
|
if (filespec2len > NAM$C_MAXRSS)
|
|
|
|
{
|
2002-07-19 11:57:17 +00:00
|
|
|
fab.fab$l_dna = 0;
|
2002-07-15 15:35:40 +00:00
|
|
|
fab.fab$b_dns = 0;
|
2002-07-19 11:57:17 +00:00
|
|
|
nam.naml$l_long_defname = (char *)filespec2;
|
2002-07-15 15:35:40 +00:00
|
|
|
nam.naml$l_long_defname_size = filespec2len;
|
|
|
|
}
|
|
|
|
nam.naml$l_esa = esa;
|
|
|
|
nam.naml$b_ess = NAM$C_MAXRSS;
|
|
|
|
nam.naml$l_long_expand = esa;
|
|
|
|
nam.naml$l_long_expand_alloc = sizeof(esa);
|
|
|
|
nam.naml$b_nop = NAM$M_SYNCHK | NAM$M_PWD;
|
2002-07-19 11:57:17 +00:00
|
|
|
nam.naml$v_no_short_upcase = 1;
|
|
|
|
fab.fab$l_naml = &nam;
|
2002-07-15 15:35:40 +00:00
|
|
|
#else
|
|
|
|
nam.nam$l_esa = esa;
|
|
|
|
nam.nam$b_ess = NAM$C_MAXRSS;
|
|
|
|
nam.nam$b_nop = NAM$M_SYNCHK | NAM$M_PWD;
|
|
|
|
fab.fab$l_nam = &nam;
|
2002-07-19 11:57:17 +00:00
|
|
|
#endif
|
2002-07-15 15:35:40 +00:00
|
|
|
|
|
|
|
status = sys$parse(&fab, 0, 0);
|
|
|
|
|
|
|
|
if(!$VMS_STATUS_SUCCESS(status))
|
|
|
|
{
|
|
|
|
unsigned short length;
|
|
|
|
char errstring[257];
|
|
|
|
struct dsc$descriptor_s errstring_dsc;
|
|
|
|
|
|
|
|
errstring_dsc.dsc$w_length = sizeof(errstring);
|
|
|
|
errstring_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
|
|
|
|
errstring_dsc.dsc$b_class = DSC$K_CLASS_S;
|
|
|
|
errstring_dsc.dsc$a_pointer = errstring;
|
|
|
|
|
|
|
|
status = sys$getmsg(status, &length, &errstring_dsc, 1, 0);
|
|
|
|
|
|
|
|
if (!$VMS_STATUS_SUCCESS(status))
|
|
|
|
lib$signal(status); /* This is really bad. Abort! */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
errstring[length] = '\0';
|
|
|
|
|
|
|
|
DSOerr(DSO_F_VMS_MERGER,DSO_R_FAILURE);
|
2002-07-19 11:57:17 +00:00
|
|
|
ERR_add_error_data(7,
|
|
|
|
"filespec \"", filespec1, "\", ",
|
|
|
|
"defaults \"", filespec2, "\": ",
|
|
|
|
errstring);
|
2002-07-15 15:35:40 +00:00
|
|
|
}
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
#ifdef NAML$C_MAXRSS
|
|
|
|
if (nam.naml$l_long_expand_size)
|
|
|
|
{
|
|
|
|
merged = OPENSSL_malloc(nam.naml$l_long_expand_size + 1);
|
|
|
|
if(!merged)
|
|
|
|
goto malloc_err;
|
|
|
|
strncpy(merged, nam.naml$l_long_expand,
|
|
|
|
nam.naml$l_long_expand_size);
|
|
|
|
merged[nam.naml$l_long_expand_size] = '\0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-07-19 11:57:17 +00:00
|
|
|
merged = OPENSSL_malloc(nam.naml$b_esl + 1);
|
2002-07-15 15:35:40 +00:00
|
|
|
if(!merged)
|
|
|
|
goto malloc_err;
|
|
|
|
strncpy(merged, nam.naml$l_esa,
|
2002-07-19 11:57:17 +00:00
|
|
|
nam.naml$b_esl);
|
|
|
|
merged[nam.naml$b_esl] = '\0';
|
2002-07-15 15:35:40 +00:00
|
|
|
}
|
|
|
|
#else
|
2002-07-19 11:57:17 +00:00
|
|
|
merged = OPENSSL_malloc(nam.nam$b_esl + 1);
|
2002-07-15 15:35:40 +00:00
|
|
|
if(!merged)
|
|
|
|
goto malloc_err;
|
|
|
|
strncpy(merged, nam.nam$l_esa,
|
2002-07-19 11:57:17 +00:00
|
|
|
nam.nam$b_esl);
|
|
|
|
merged[nam.nam$b_esl] = '\0';
|
2002-07-15 15:35:40 +00:00
|
|
|
#endif
|
|
|
|
return(merged);
|
|
|
|
malloc_err:
|
|
|
|
DSOerr(DSO_F_VMS_MERGER,
|
|
|
|
ERR_R_MALLOC_FAILURE);
|
|
|
|
}
|
|
|
|
|
2000-12-31 01:55:46 +00:00
|
|
|
static char *vms_name_converter(DSO *dso, const char *filename)
|
This changes the behaviour of the DSO mechanism for determining an
appropriate filename translation on the host system. Apart from this point,
users should also note that there's a slight change in the API functions
too. The DSO now contains its own to-be-converted filename
("dso->filename"), and at the time the DSO loads the "dso->loaded_filename"
value is set to the translated form. As such, this also provides an impicit
way of determining if the DSO is currently loaded or not. Except, perhaps,
VMS .... :-)
The various DSO_METHODs have been updated for this mechanism except VMS
which is deliberately broken for now, Richard is going to look at how to
fit it in (the source comments in there explain "the issue").
Basically, the new callback scheme allows the filename conversion to
(a) be turned off altogether through the use of the
DSO_FLAG_NO_NAME_TRANSLATION flag,
(b) be handled in the default way using the default DSO_METHOD's converter
(c) overriden per-DSO by setting the override callback
(d) a mix of (b) and (c) - eg. implement an override callback that;
(i) checks if we're win32 "if(strstr(dso->meth->name, "win32"))..."
and if so, convert "blah" into "blah32.dll" (the default is
otherwise to make it "blah.dll").
(ii) default to the normal behaviour - eg. we're not on win32, so
finish with (return dso->meth->dso_name_converter(dso,NULL)).
(e) be retried a number of times by writing a new DSO_METHOD where the
"dso_load()" handler will call the converter repeatedly. Then the
custom converter could use state information in the DSO to suggest
different conversions or paths each time it is invoked.
2000-10-26 17:38:59 +00:00
|
|
|
{
|
2001-02-20 13:23:42 +00:00
|
|
|
int len = strlen(filename);
|
|
|
|
char *not_translated = OPENSSL_malloc(len+1);
|
|
|
|
strcpy(not_translated,filename);
|
|
|
|
return(not_translated);
|
This changes the behaviour of the DSO mechanism for determining an
appropriate filename translation on the host system. Apart from this point,
users should also note that there's a slight change in the API functions
too. The DSO now contains its own to-be-converted filename
("dso->filename"), and at the time the DSO loads the "dso->loaded_filename"
value is set to the translated form. As such, this also provides an impicit
way of determining if the DSO is currently loaded or not. Except, perhaps,
VMS .... :-)
The various DSO_METHODs have been updated for this mechanism except VMS
which is deliberately broken for now, Richard is going to look at how to
fit it in (the source comments in there explain "the issue").
Basically, the new callback scheme allows the filename conversion to
(a) be turned off altogether through the use of the
DSO_FLAG_NO_NAME_TRANSLATION flag,
(b) be handled in the default way using the default DSO_METHOD's converter
(c) overriden per-DSO by setting the override callback
(d) a mix of (b) and (c) - eg. implement an override callback that;
(i) checks if we're win32 "if(strstr(dso->meth->name, "win32"))..."
and if so, convert "blah" into "blah32.dll" (the default is
otherwise to make it "blah.dll").
(ii) default to the normal behaviour - eg. we're not on win32, so
finish with (return dso->meth->dso_name_converter(dso,NULL)).
(e) be retried a number of times by writing a new DSO_METHOD where the
"dso_load()" handler will call the converter repeatedly. Then the
custom converter could use state information in the DSO to suggest
different conversions or paths each time it is invoked.
2000-10-26 17:38:59 +00:00
|
|
|
}
|
|
|
|
|
2001-02-20 08:13:47 +00:00
|
|
|
#endif /* OPENSSL_SYS_VMS */
|