Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x][Entitlements] Fix "No SecurityManager when entitlements are enabled" #119765

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static List<String> systemJvmOptions(Settings nodeSettings, final Map<String, St
maybeSetActiveProcessorCount(nodeSettings),
maybeSetReplayFile(distroType, isHotspot),
maybeWorkaroundG1Bug(),
maybeAllowSecurityManager(useEntitlements),
maybeAllowSecurityManager(),
maybeAttachEntitlementAgent(useEntitlements)
).flatMap(s -> s).toList();
}
Expand Down Expand Up @@ -148,12 +148,9 @@ private static Stream<String> maybeWorkaroundG1Bug() {
return Stream.of();
}

private static Stream<String> maybeAllowSecurityManager(boolean useEntitlements) {
if (useEntitlements == false) {
// Will become conditional on useEntitlements once entitlements can run without SM
return Stream.of("-Djava.security.manager=allow");
}
return Stream.of();
private static Stream<String> maybeAllowSecurityManager() {
// Will become conditional on useEntitlements once entitlements can run without SM
return Stream.of("-Djava.security.manager=allow");
}

private static Stream<String> maybeAttachEntitlementAgent(boolean useEntitlements) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@
public class ExampleSecurityExtension implements SecurityExtension {

static {
// check that the extension's policy works.
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
System.getSecurityManager().checkPropertyAccess("myproperty");
return null;
});
final boolean useEntitlements = Boolean.parseBoolean(System.getProperty("es.entitlements.enabled"));
if (useEntitlements == false) {
// check that the extension's policy works.
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
System.getSecurityManager().checkPropertyAccess("myproperty");
return null;
});
}
}

@Override
Expand Down