Skip to content

Commit b54edd1

Browse files
committed
Remove entitlements flag from startup
Entitlements are now always enabled, so we no longer need a flag. This commit also removes the now defunct bootstrap check that ensured AllPermission was never granted in the SM policy.
1 parent 6263f44 commit b54edd1

File tree

4 files changed

+3
-66
lines changed

4 files changed

+3
-66
lines changed

server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class Bootstrap {
3333

3434
// arguments from the CLI process
3535
private final ServerArgs args;
36-
private final boolean useEntitlements;
3736

3837
// controller for spawning component subprocesses
3938
private final Spawner spawner = new Spawner();
@@ -47,11 +46,10 @@ class Bootstrap {
4746
// loads information about plugins required for entitlements in phase 2, used by plugins service in phase 3
4847
private final SetOnce<PluginsLoader> pluginsLoader = new SetOnce<>();
4948

50-
Bootstrap(PrintStream out, PrintStream err, ServerArgs args, boolean useEntitlements) {
49+
Bootstrap(PrintStream out, PrintStream err, ServerArgs args) {
5150
this.out = out;
5251
this.err = err;
5352
this.args = args;
54-
this.useEntitlements = useEntitlements;
5553
}
5654

5755
ServerArgs args() {
@@ -62,10 +60,6 @@ Spawner spawner() {
6260
return spawner;
6361
}
6462

65-
public boolean useEntitlements() {
66-
return useEntitlements;
67-
}
68-
6963
void setSecureSettings(SecureSettings secureSettings) {
7064
this.secureSettings.set(secureSettings);
7165
}

server/src/main/java/org/elasticsearch/bootstrap/BootstrapChecks.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -711,36 +711,6 @@ public ReferenceDocs referenceDocs() {
711711

712712
}
713713

714-
static class AllPermissionCheck implements BootstrapCheck {
715-
716-
@Override
717-
public final BootstrapCheckResult check(BootstrapContext context) {
718-
if (isAllPermissionGranted()) {
719-
return BootstrapCheck.BootstrapCheckResult.failure("granting the all permission effectively disables security");
720-
}
721-
return BootstrapCheckResult.success();
722-
}
723-
724-
boolean isAllPermissionGranted() {
725-
if (RuntimeVersionFeature.isSecurityManagerAvailable() == false) {
726-
return false;
727-
}
728-
final SecurityManager sm = System.getSecurityManager();
729-
assert sm != null;
730-
try {
731-
sm.checkPermission(new AllPermission());
732-
} catch (final SecurityException e) {
733-
return false;
734-
}
735-
return true;
736-
}
737-
738-
@Override
739-
public ReferenceDocs referenceDocs() {
740-
return ReferenceDocs.BOOTSTRAP_CHECK_ALL_PERMISSION;
741-
}
742-
}
743-
744714
static class DiscoveryConfiguredCheck implements BootstrapCheck {
745715
@Override
746716
public BootstrapCheckResult check(BootstrapContext context) {

server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ private static Bootstrap initPhase1() {
128128
final PrintStream err = getStderr();
129129
final ServerArgs args;
130130

131-
final boolean useEntitlements = true;
132131
try {
133132
initSecurityProperties();
134133
LogConfigurator.registerErrorListener();
@@ -156,7 +155,7 @@ private static Bootstrap initPhase1() {
156155
return null; // unreachable, to satisfy compiler
157156
}
158157

159-
return new Bootstrap(out, err, args, useEntitlements);
158+
return new Bootstrap(out, err, args);
160159
}
161160

162161
/**
@@ -402,11 +401,7 @@ protected void validateNodeBeforeAcceptingRequests(
402401
final BoundTransportAddress boundTransportAddress,
403402
List<BootstrapCheck> checks
404403
) throws NodeValidationException {
405-
var additionalChecks = new ArrayList<>(checks);
406-
if (bootstrap.useEntitlements() == false) {
407-
additionalChecks.add(new BootstrapChecks.AllPermissionCheck());
408-
}
409-
BootstrapChecks.check(context, boundTransportAddress, additionalChecks);
404+
BootstrapChecks.check(context, boundTransportAddress, checks);
410405
}
411406
};
412407
INSTANCE = new Elasticsearch(bootstrap.spawner(), node);

server/src/test/java/org/elasticsearch/bootstrap/BootstrapChecksTests.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -657,28 +657,6 @@ String javaVersion() {
657657

658658
}
659659

660-
public void testAllPermissionCheck() throws NodeValidationException {
661-
final AtomicBoolean isAllPermissionGranted = new AtomicBoolean(true);
662-
final BootstrapChecks.AllPermissionCheck allPermissionCheck = new BootstrapChecks.AllPermissionCheck() {
663-
@Override
664-
boolean isAllPermissionGranted() {
665-
return isAllPermissionGranted.get();
666-
}
667-
};
668-
669-
final List<BootstrapCheck> checks = Collections.singletonList(allPermissionCheck);
670-
final NodeValidationException e = expectThrows(
671-
NodeValidationException.class,
672-
() -> BootstrapChecks.check(emptyContext, true, checks)
673-
);
674-
assertThat(e, hasToString(containsString("granting the all permission effectively disables security")));
675-
assertThat(e.getMessage(), containsString("; for more information see [https://www.elastic.co/docs/"));
676-
677-
// if all permissions are not granted, nothing should happen
678-
isAllPermissionGranted.set(false);
679-
BootstrapChecks.check(emptyContext, true, checks);
680-
}
681-
682660
public void testAlwaysEnforcedChecks() {
683661
final BootstrapCheck check = new BootstrapCheck() {
684662
@Override

0 commit comments

Comments
 (0)