Skip to content

Commit

Permalink
attempt to fix AccessControlException (doesn't work)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelandis committed Nov 21, 2024
1 parent 46945ee commit 1e57ca2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.apache.hadoop.fs.Options;
import org.apache.hadoop.fs.Options.CreateOpts;
import org.apache.hadoop.fs.Path;
import org.elasticsearch.SpecialPermission;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.common.blobstore.BlobContainer;
import org.elasticsearch.common.blobstore.BlobPath;
Expand All @@ -38,6 +39,9 @@
import java.io.OutputStream;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.NoSuchFileException;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Iterator;
Expand Down Expand Up @@ -262,8 +266,16 @@ public void writeBlobAtomic(OperationPurpose purpose, String blobName, BytesRefe

private void writeToPath(BytesReference bytes, Path blobPath, FileContext fileContext, EnumSet<CreateFlag> createFlags)
throws IOException {
try (FSDataOutputStream stream = fileContext.create(blobPath, createFlags, createOpts)) {
bytes.writeTo(stream);
SpecialPermission.check();
try {
AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
try (FSDataOutputStream stream = fileContext.create(blobPath, createFlags, createOpts)) {
bytes.writeTo(stream);
}
return null;
});
} catch (PrivilegedActionException e) {
throw (IOException) e.getCause();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,6 @@ grant {
// client binds to the address returned from the host name of any principal set up as a service principal
// org.apache.hadoop.ipc.Client.Connection.setupConnection
permission java.net.SocketPermission "localhost:0", "listen,resolve";

permission org.elasticsearch.secure_sm.ThreadPermission, "modifyArbitraryThreadGroup";
};
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,5 @@ grant {
permission java.nio.file.LinkPermission "symbolic";
// needed for keystore tests
permission java.lang.RuntimePermission "accessUserInformation";
permission org.elasticsearch.secure_sm.ThreadPermission, "modifyArbitraryThreadGroup";
};

0 comments on commit 1e57ca2

Please sign in to comment.