src/launcher/java_md_solinux.c
/*
 * Test whether the environment variable needs to be set, see flowchart.
 */
Test whether the environment variable needs to be set, see flowchart.
Test whether the environment variable needs to be set see flowchart .
static jboolean
RequiresSetenv(int wanted, const char *jvmpath) {
    char jpath[PATH_MAX + 1];
    char *llp;
    char *dmllp = NULL;
    char *p; 
#ifdef AIX
    return JNI_TRUE;
#endif
    llp = getenv("LD_LIBRARY_PATH");
#ifdef __solaris__
    dmllp = (CURRENT_DATA_MODEL == 32)
            ? getenv("LD_LIBRARY_PATH_32")
            : getenv("LD_LIBRARY_PATH_64");
#endif 
    if (llp == NULL && dmllp == NULL) {
        return JNI_FALSE;
    }
#ifdef __linux
    if ((getgid() != getegid()) || (getuid() != geteuid())) {
        return JNI_FALSE;
    }
#endif 
    JLI_StrNCpy(jpath, jvmpath, PATH_MAX);
    p = JLI_StrRChr(jpath, '/');
    *p = '\0';
    if (llp != NULL && JLI_StrNCmp(llp, jpath, JLI_StrLen(jpath)) == 0) {
        return JNI_FALSE;
    }
    if (llp != NULL &&  ContainsLibJVM(wanted, llp)) {
        return JNI_TRUE;
    }
    if (dmllp != NULL && ContainsLibJVM(wanted, dmllp)) {
        return JNI_TRUE;
    }
    return JNI_FALSE;
}
static jboolean RequiresSetenv ( int wanted , const char * jvmpath ) { char jpath [ PATH_MAX + 1 ] ; char * llp ; char * dmllp = NULL ; char * p ; #ifdef AIX return JNI_TRUE ; #endif llp = getenv ( " " ) ; #ifdef __solaris__ dmllp = ( CURRENT_DATA_MODEL == 32 ) ? getenv ( " " ) : getenv ( " " ) ; #endif if ( llp == NULL && dmllp == NULL ) { return JNI_FALSE ; } #ifdef __linux if ( ( getgid ( ) != getegid ( ) ) || ( getuid ( ) != geteuid ( ) ) ) { return JNI_FALSE ; } #endif JLI_StrNCpy ( jpath , jvmpath , PATH_MAX ) ; p = JLI_StrRChr ( jpath , ' ' ) ; * p = ' \0 ' ; if ( llp != NULL && JLI_StrNCmp ( llp , jpath , JLI_StrLen ( jpath ) ) == 0 ) { return JNI_FALSE ; } if ( llp != NULL && ContainsLibJVM ( wanted , llp ) ) { return JNI_TRUE ; } if ( dmllp != NULL && ContainsLibJVM ( wanted , dmllp ) ) { return JNI_TRUE ; } return JNI_FALSE ; }
Test whether the environment variable needs to be set, see flowchart.
Test whether the environment variable needs to be set see flowchart .
/* a utility pointer */ /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */ /* __solaris__ */ /* no environment variable is a good environment variable */ /*
     * On linux, if a binary is running as sgid or suid, glibc sets
     * LD_LIBRARY_PATH to the empty string for security purposes. (In contrast,
     * on Solaris the LD_LIBRARY_PATH variable for a privileged binary does not
     * lose its settings; but the dynamic linker does apply more scrutiny to the
     * path.) The launcher uses the value of LD_LIBRARY_PATH to prevent an exec
     * loop, here and further downstream. Therefore, if we are running sgid or
     * suid, this function's setting of LD_LIBRARY_PATH will be ineffective and
     * we should case a return from the calling function.  Getting the right
     * libraries will be handled by the RPATH. In reality, this check is
     * redundant, as the previous check for a non-null LD_LIBRARY_PATH will
     * return back to the calling function forthwith, it is left here to safe
     * guard against any changes, in the glibc's existing security policy.
     */ /* __linux */ /*
     * Prevent recursions. Since LD_LIBRARY_PATH is the one which will be set by
     * previous versions of the JRE, thus it is the only path that matters here.
     * So we check to see if the desired JRE is set.
     */ /* scrutinize all the paths further */