Java Code Examples for com.oracle.java.testlibrary.Utils#fileAsString()

The following examples show how to use com.oracle.java.testlibrary.Utils#fileAsString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Platform.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * On Linux, first check the SELinux boolean "deny_ptrace" and return false
 * as we expect to be denied if that is "1".  Then expect permission to attach
 * if we are root, so return true.  Then return false for an expected denial
 * if "ptrace_scope" is 1, and true otherwise.
 */
public static boolean canPtraceAttachLinux() throws Exception {

    // SELinux deny_ptrace:
    String deny_ptrace = Utils.fileAsString("/sys/fs/selinux/booleans/deny_ptrace");
    if (deny_ptrace != null && deny_ptrace.contains("1")) {
        // ptrace will be denied:
        return false;
    }

    if (userName.equals("root")) {
        return true;
    }

    // ptrace_scope:
    String ptrace_scope = Utils.fileAsString("/proc/sys/kernel/yama/ptrace_scope");
    if (ptrace_scope != null && ptrace_scope.contains("1")) {
        // ptrace will be denied:
        return false;
    }

    // Otherwise expect to be permitted:
    return true;
}
 
Example 2
Source File: Platform.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * On Linux, first check the SELinux boolean "deny_ptrace" and return false
 * as we expect to be denied if that is "1".  Then expect permission to attach
 * if we are root, so return true.  Then return false for an expected denial
 * if "ptrace_scope" is 1, and true otherwise.
 */
public static boolean canPtraceAttachLinux() throws Exception {

    // SELinux deny_ptrace:
    String deny_ptrace = Utils.fileAsString("/sys/fs/selinux/booleans/deny_ptrace");
    if (deny_ptrace != null && deny_ptrace.contains("1")) {
        // ptrace will be denied:
        return false;
    }

    if (userName.equals("root")) {
        return true;
    }

    // ptrace_scope:
    String ptrace_scope = Utils.fileAsString("/proc/sys/kernel/yama/ptrace_scope");
    if (ptrace_scope != null && ptrace_scope.contains("1")) {
        // ptrace will be denied:
        return false;
    }

    // Otherwise expect to be permitted:
    return true;
}
 
Example 3
Source File: Platform.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * On Linux, first check the SELinux boolean "deny_ptrace" and return false
 * as we expect to be denied if that is "1".  Then expect permission to attach
 * if we are root, so return true.  Then return false for an expected denial
 * if "ptrace_scope" is 1, and true otherwise.
 */
public static boolean canPtraceAttachLinux() throws Exception {

    // SELinux deny_ptrace:
    String deny_ptrace = Utils.fileAsString("/sys/fs/selinux/booleans/deny_ptrace");
    if (deny_ptrace != null && deny_ptrace.contains("1")) {
        // ptrace will be denied:
        return false;
    }

    if (userName.equals("root")) {
        return true;
    }

    // ptrace_scope:
    String ptrace_scope = Utils.fileAsString("/proc/sys/kernel/yama/ptrace_scope");
    if (ptrace_scope != null && ptrace_scope.contains("1")) {
        // ptrace will be denied:
        return false;
    }

    // Otherwise expect to be permitted:
    return true;
}
 
Example 4
Source File: Platform.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * On Linux, first check the SELinux boolean "deny_ptrace" and return false
 * as we expect to be denied if that is "1".  Then expect permission to attach
 * if we are root, so return true.  Then return false for an expected denial
 * if "ptrace_scope" is 1, and true otherwise.
 */
public static boolean canPtraceAttachLinux() throws Exception {

    // SELinux deny_ptrace:
    String deny_ptrace = Utils.fileAsString("/sys/fs/selinux/booleans/deny_ptrace");
    if (deny_ptrace != null && deny_ptrace.contains("1")) {
        // ptrace will be denied:
        return false;
    }

    if (userName.equals("root")) {
        return true;
    }

    // ptrace_scope:
    String ptrace_scope = Utils.fileAsString("/proc/sys/kernel/yama/ptrace_scope");
    if (ptrace_scope != null && ptrace_scope.contains("1")) {
        // ptrace will be denied:
        return false;
    }

    // Otherwise expect to be permitted:
    return true;
}
 
Example 5
Source File: Platform.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * On Linux, first check the SELinux boolean "deny_ptrace" and return false
 * as we expect to be denied if that is "1".  Then expect permission to attach
 * if we are root, so return true.  Then return false for an expected denial
 * if "ptrace_scope" is 1, and true otherwise.
 */
public static boolean canPtraceAttachLinux() throws Exception {

    // SELinux deny_ptrace:
    String deny_ptrace = Utils.fileAsString("/sys/fs/selinux/booleans/deny_ptrace");
    if (deny_ptrace != null && deny_ptrace.contains("1")) {
        // ptrace will be denied:
        return false;
    }

    if (userName.equals("root")) {
        return true;
    }

    // ptrace_scope:
    String ptrace_scope = Utils.fileAsString("/proc/sys/kernel/yama/ptrace_scope");
    if (ptrace_scope != null && ptrace_scope.contains("1")) {
        // ptrace will be denied:
        return false;
    }

    // Otherwise expect to be permitted:
    return true;
}