Skip to content

Commit

Permalink
Introduce _CEE3164_ENVFILE as a temporary workaround
Browse files Browse the repository at this point in the history
Due to LE limitation, we need to pass environment variables via _CEE_ENVFILE.
Different launchers may unset _CEE_ENVFILE in order for child processes to
pick up LIBPATH updates, we need to copy the _CEE3164_ENVFILE env var
to _CEE_ENVFILE  on first invocation of CEL4RO31.

Signed-off-by: Joran Siu <joransiu@ca.ibm.com>
  • Loading branch information
joransiu committed Mar 8, 2021
1 parent a100900 commit d236e95
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions port/zos390/omrsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,22 @@ omrsl_open_shared_library(struct OMRPortLibrary *portLibrary, char *name, uintpt

DMESSAGE(("omrsl_open_shared_library: Attempt to load 31-bit DLL [%s]\n", openName))

/* Due to temporary LE limitation, we need to pass environment variables via _CEE_ENVFILE.
* Since this could be the first path in establishing 31-bit secondary enclave,
* and launcher may unset _CEE_ENVFILE in order for child processes to
* pick up LIBPATH updates, we need to copy the _CEE3164_ENVFILE env var
* to _CEE_ENVFILE for duration of this CEL4RO31 invocation.
*/
char *CEE_ENVFILE_envvar = getenv("_CEE_ENVFILE");
char *CEE3164_ENVFILE_envvar = getenv("_CEE3164_ENVFILE");
BOOLEAN initCEE_ENVFILE = ((NULL == CEE_ENVFILE_envvar) || ('\0' == CEE_ENVFILE_envvar[0])) && (NULL != CEE3164_ENVFILE_envvar);

if (initCEE_ENVFILE) {
char buf[1024];
snprintf(buf, sizeof(buf), "_CEE_ENVFILE=%s", CEE3164_ENVFILE_envvar);
putenv(buf);
}

ro31InfoBlock = omr_cel4ro31_init(OMR_CEL4RO31_FLAG_LOAD_DLL, openName, NULL, 0);
if (NULL != ro31InfoBlock) {
OMR_CEL4RO31_controlBlock *ro31ControlBlock = &(ro31InfoBlock->ro31ControlBlock);
Expand All @@ -139,6 +155,11 @@ omrsl_open_shared_library(struct OMRPortLibrary *portLibrary, char *name, uintpt
omr_cel4ro31_deinit(ro31InfoBlock);
}

if (initCEE_ENVFILE) {
/* Clear _CEE_ENVFILE to avoid child processes issues with picking up the updated LIBPATH. */
putenv("_CEE_ENVFILE=");
}

DMESSAGE(("omrsl_open_shared_library: Attempted to load 31-bit DLL Return Code: [%d] DLL handle: [%p]\n", ro31InfoBlock->ro31ControlBlock.retcode, handle))
}
#endif /* defined(J9ZOS39064) */
Expand Down

0 comments on commit d236e95

Please sign in to comment.