338 char *runpath = NULL; /* existing effective LD_LIBRARY_PATH setting */ |
338 char *runpath = NULL; /* existing effective LD_LIBRARY_PATH setting */ |
339 char* new_runpath = NULL; /* desired new LD_LIBRARY_PATH string */ |
339 char* new_runpath = NULL; /* desired new LD_LIBRARY_PATH string */ |
340 char* newpath = NULL; /* path on new LD_LIBRARY_PATH */ |
340 char* newpath = NULL; /* path on new LD_LIBRARY_PATH */ |
341 char* lastslash = NULL; |
341 char* lastslash = NULL; |
342 char** newenvp = NULL; /* current environment */ |
342 char** newenvp = NULL; /* current environment */ |
|
343 size_t new_runpath_size; |
343 #ifdef __solaris__ |
344 #ifdef __solaris__ |
344 char* dmpath = NULL; /* data model specific LD_LIBRARY_PATH, |
345 char* dmpath = NULL; /* data model specific LD_LIBRARY_PATH, |
345 Solaris only */ |
346 Solaris only */ |
346 #endif /* __solaris__ */ |
347 #endif /* __solaris__ */ |
347 #endif /* SETENV_REQUIRED */ |
348 #endif /* SETENV_REQUIRED */ |
514 #endif /* __solaris__ */ |
515 #endif /* __solaris__ */ |
515 |
516 |
516 /* runpath contains current effective LD_LIBRARY_PATH setting */ |
517 /* runpath contains current effective LD_LIBRARY_PATH setting */ |
517 |
518 |
518 jvmpath = JLI_StringDup(jvmpath); |
519 jvmpath = JLI_StringDup(jvmpath); |
519 new_runpath = JLI_MemAlloc(((runpath != NULL) ? JLI_StrLen(runpath) : 0) + |
520 new_runpath_size = ((runpath != NULL) ? JLI_StrLen(runpath) : 0) + |
520 2 * JLI_StrLen(jrepath) + 2 * JLI_StrLen(arch) + |
521 2 * JLI_StrLen(jrepath) + 2 * JLI_StrLen(arch) + |
521 #ifdef AIX |
522 #ifdef AIX |
522 /* On AIX we additionally need 'jli' in the path because ld doesn't support $ORIGIN. */ |
523 /* On AIX we additionally need 'jli' in the path because ld doesn't support $ORIGIN. */ |
523 JLI_StrLen(jrepath) + JLI_StrLen(arch) + JLI_StrLen("/lib//jli:") + |
524 JLI_StrLen(jrepath) + JLI_StrLen(arch) + JLI_StrLen("/lib//jli:") + |
524 #endif |
525 #endif |
525 JLI_StrLen(jvmpath) + 52); |
526 JLI_StrLen(jvmpath) + 52; |
|
527 new_runpath = JLI_MemAlloc(new_runpath_size); |
526 newpath = new_runpath + JLI_StrLen(LD_LIBRARY_PATH "="); |
528 newpath = new_runpath + JLI_StrLen(LD_LIBRARY_PATH "="); |
527 |
529 |
528 |
530 |
529 /* |
531 /* |
530 * Create desired LD_LIBRARY_PATH value for target data model. |
532 * Create desired LD_LIBRARY_PATH value for target data model. |
575 * Place the desired environment setting onto the prefix of |
577 * Place the desired environment setting onto the prefix of |
576 * LD_LIBRARY_PATH. Note that this prevents any possible infinite |
578 * LD_LIBRARY_PATH. Note that this prevents any possible infinite |
577 * loop of execv() because we test for the prefix, above. |
579 * loop of execv() because we test for the prefix, above. |
578 */ |
580 */ |
579 if (runpath != 0) { |
581 if (runpath != 0) { |
|
582 /* ensure storage for runpath + colon + NULL */ |
|
583 if ((JLI_StrLen(runpath) + 1 + 1) > new_runpath_size) { |
|
584 JLI_ReportErrorMessageSys(JRE_ERROR11); |
|
585 exit(1); |
|
586 } |
580 JLI_StrCat(new_runpath, ":"); |
587 JLI_StrCat(new_runpath, ":"); |
581 JLI_StrCat(new_runpath, runpath); |
588 JLI_StrCat(new_runpath, runpath); |
582 } |
589 } |
583 |
590 |
584 if (putenv(new_runpath) != 0) { |
591 if (putenv(new_runpath) != 0) { |
665 JLI_Snprintf(libjava, sizeof(libjava), "%s/lib/%s/" JAVA_DLL, path, arch); |
672 JLI_Snprintf(libjava, sizeof(libjava), "%s/lib/%s/" JAVA_DLL, path, arch); |
666 if (access(libjava, F_OK) == 0) { |
673 if (access(libjava, F_OK) == 0) { |
667 JLI_TraceLauncher("JRE path is %s\n", path); |
674 JLI_TraceLauncher("JRE path is %s\n", path); |
668 return JNI_TRUE; |
675 return JNI_TRUE; |
669 } |
676 } |
670 |
677 /* ensure storage for path + /jre + NULL */ |
|
678 if ((JLI_StrLen(path) + 4 + 1) > (size_t) pathsize) { |
|
679 JLI_TraceLauncher("Insufficient space to store JRE path\n"); |
|
680 return JNI_FALSE; |
|
681 } |
671 /* Does the app ship a private JRE in <apphome>/jre directory? */ |
682 /* Does the app ship a private JRE in <apphome>/jre directory? */ |
672 JLI_Snprintf(libjava, sizeof(libjava), "%s/jre/lib/%s/" JAVA_DLL, path, arch); |
683 JLI_Snprintf(libjava, sizeof(libjava), "%s/jre/lib/%s/" JAVA_DLL, path, arch); |
673 if (access(libjava, F_OK) == 0) { |
684 if (access(libjava, F_OK) == 0) { |
674 JLI_StrCat(path, "/jre"); |
685 JLI_StrCat(path, "/jre"); |
675 JLI_TraceLauncher("JRE path is %s\n", path); |
686 JLI_TraceLauncher("JRE path is %s\n", path); |