protected void checkNativeLink(SecurityManager sm, String os) {
   if (os.equals("SunOS") || os.equals("Linux")) {
     // link "saproc" - SA native library on SunOS and Linux?
     sm.checkLink("saproc");
   } else if (os.startsWith("Windows")) {
     // link "sawindbg" - SA native library on Windows.
     sm.checkLink("sawindbg");
   } else {
     throw new RuntimeException(os + " is not yet supported");
   }
 }
示例#2
0
 // security check to see whether the caller can perform attach
 private void checkProcessAttach(int pid) {
   SecurityManager sm = System.getSecurityManager();
   if (sm != null) {
     String os = System.getProperty("os.name");
     try {
       // Whether the caller can perform link against SA native library?
       checkNativeLink(sm, os);
       if (os.equals("SunOS") || os.equals("Linux")) {
         // Whether the caller can read /proc/<pid> file?
         sm.checkRead("/proc/" + pid);
       }
     } catch (SecurityException se) {
       throw new SecurityException("permission denied to attach to " + pid);
     }
   }
 }