Skip to content

Commit 1f2a906

Browse files
authored
Force property expansion for security policy (#87396) (#87489)
When resolving the security policy files for server and components of Elasticsearch, each jar file location is put into a special system property value so that policy files may contain codeBase specific grants. The mechanism for substituting system properties is part of the JDK's policy parser. However, a security property exists, policy.expandProperties, which controls whether properties will actually be expanded. If a user ends up setting this, Elasticsearch will fail to start. This commit forces the value of the security property to ensure the policy files can always be parsed correctly.
1 parent de3f122 commit 1f2a906

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

docs/changelog/87396.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 87396
2+
summary: Force property expansion for security policy
3+
area: Infra/Core
4+
type: enhancement
5+
issues: []

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class Elasticsearch extends EnvironmentAwareCommand {
5959
* Main entry point for starting elasticsearch
6060
*/
6161
public static void main(final String[] args) throws Exception {
62-
overrideDnsCachePolicyProperties();
62+
bootstrapSecurityProperties();
6363
org.elasticsearch.bootstrap.Security.prepopulateSecurityCaller();
6464

6565
/*
@@ -103,7 +103,7 @@ static void printLogsSuggestion() {
103103
}
104104
}
105105

106-
private static void overrideDnsCachePolicyProperties() {
106+
private static void bootstrapSecurityProperties() {
107107
for (final String property : new String[] { "networkaddress.cache.ttl", "networkaddress.cache.negative.ttl" }) {
108108
final String overrideProperty = "es." + property;
109109
final String overrideValue = System.getProperty(overrideProperty);
@@ -116,6 +116,9 @@ private static void overrideDnsCachePolicyProperties() {
116116
}
117117
}
118118
}
119+
120+
// policy file codebase declarations in security.policy rely on property expansion, see PolicyUtil.readPolicy
121+
Security.setProperty("policy.expandProperties", "true");
119122
}
120123

121124
static int main(final String[] args, final Elasticsearch elasticsearch, final Terminal terminal) throws Exception {

0 commit comments

Comments
 (0)