Skip to content

Commit

Permalink
Reduce the overhead of the custom security manager #SCL-20064
Browse files Browse the repository at this point in the history
Changes from facebookarchive#149.
  • Loading branch information
vasilmkd committed Jan 30, 2023
1 parent 884e868 commit 710ee7d
Showing 1 changed file with 161 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package com.facebook.nailgun;

import java.io.FileDescriptor;
import java.net.InetAddress;
import java.security.Permission;

/**
Expand All @@ -37,6 +39,7 @@ public NGSecurityManager(SecurityManager base) {
this.base = base;
}

@Override
public void checkExit(int status) {
if (base != null) {
base.checkExit(status);
Expand All @@ -45,22 +48,179 @@ public void checkExit(int status) {
throw new NGExitException(status);
}

@Override
public void checkPermission(Permission perm) {
if (base != null) {
base.checkPermission(perm);
}
}

@Override
public void checkPermission(Permission perm, Object context) {
if (base != null) {
base.checkPermission(perm, context);
}
}

/** Avoid constructing a FilePermission object in checkRead if base manager is null. */
@Override
public void checkRead(String file) {
if (base != null) {
super.checkRead(file);
base.checkRead(file);
}
}

@Override
public void checkCreateClassLoader() {
if (base != null) {
base.checkCreateClassLoader();
}
}

@Override
public void checkAccess(Thread t) {
if (base != null) {
base.checkAccess(t);
}
}

@Override
public void checkAccess(ThreadGroup g) {
if (base != null) {
base.checkAccess(g);
}
}

@Override
public void checkExec(String cmd) {
if (base != null) {
base.checkExec(cmd);
}
}

@Override
public void checkLink(String lib) {
if (base != null) {
base.checkLink(lib);
}
}

@Override
public void checkRead(FileDescriptor fd) {
if (base != null) {
base.checkRead(fd);
}
}

@Override
public void checkRead(String file, Object context) {
if (base != null) {
base.checkRead(file, context);
}
}

@Override
public void checkWrite(FileDescriptor fd) {
if (base != null) {
base.checkWrite(fd);
}
}

@Override
public void checkWrite(String file) {
if (base != null) {
base.checkWrite(file);
}
}

@Override
public void checkDelete(String file) {
if (base != null) {
base.checkDelete(file);
}
}

@Override
public void checkConnect(String host, int port) {
if (base != null) {
base.checkConnect(host, port);
}
}

@Override
public void checkConnect(String host, int port, Object context) {
if (base != null) {
base.checkConnect(host, port, context);
}
}

@Override
public void checkListen(int port) {
if (base != null) {
base.checkListen(port);
}
}

@Override
public void checkAccept(String host, int port) {
if (base != null) {
base.checkAccept(host, port);
}
}

@Override
public void checkMulticast(InetAddress maddr) {
if (base != null) {
base.checkMulticast(maddr);
}
}

@Override
public void checkPropertiesAccess() {
if (base != null) {
base.checkPropertiesAccess();
}
}

@Override
public void checkPropertyAccess(String key) {
if (base != null) {
base.checkPropertyAccess(key);
}
}

@Override
public void checkPrintJobAccess() {
if (base != null) {
base.checkPrintJobAccess();
}
}

@Override
public void checkPackageAccess(String pkg) {
if (base != null) {
base.checkPackageAccess(pkg);
}
}

@Override
public void checkPackageDefinition(String pkg) {
if (base != null) {
base.checkPackageDefinition(pkg);
}
}

@Override
public void checkSetFactory() {
if (base != null) {
base.checkSetFactory();
}
}

@Override
public void checkSecurityAccess(String target) {
if (base != null) {
base.checkSecurityAccess(target);
}
}
}

0 comments on commit 710ee7d

Please sign in to comment.