|
85 | 85 | */ |
86 | 86 | class Elasticsearch { |
87 | 87 |
|
88 | | - private static final String PLUGIN_POLICY_OVERRIDE_PREFIX = "es.entitlements.policy."; |
89 | | - private static final String SERVER_POLICY_OVERRIDE = "es.entitlements.server_policy"; |
| 88 | + private static final String POLICY_PATCH_PREFIX = "es.entitlements.policy."; |
| 89 | + private static final String SERVER_POLICY_PATCH_NAME = POLICY_PATCH_PREFIX + "server"; |
90 | 90 |
|
91 | 91 | /** |
92 | 92 | * Main entry point for starting elasticsearch. |
@@ -251,10 +251,10 @@ private static void initPhase2(Bootstrap bootstrap) throws IOException { |
251 | 251 | .map(bundle -> new PolicyUtils.PluginData(bundle.getDir(), bundle.pluginDescriptor().isModular(), true)) |
252 | 252 | ).toList(); |
253 | 253 |
|
254 | | - var pluginPolicyOverrides = collectPluginPolicyOverrides(modulesBundles, pluginsBundles, logger); |
255 | | - var pluginPolicies = PolicyUtils.createPluginPolicies(pluginData, pluginPolicyOverrides, Build.current().version()); |
| 254 | + var pluginPolicyPatches = collectPluginPolicyPatches(modulesBundles, pluginsBundles, logger); |
| 255 | + var pluginPolicies = PolicyUtils.createPluginPolicies(pluginData, pluginPolicyPatches, Build.current().version()); |
256 | 256 | var serverPolicyPatch = PolicyUtils.parseEncodedPolicyIfExists( |
257 | | - System.getProperty(SERVER_POLICY_OVERRIDE), |
| 257 | + System.getProperty(SERVER_POLICY_PATCH_NAME), |
258 | 258 | Build.current().version(), |
259 | 259 | false, |
260 | 260 | "server", |
@@ -329,33 +329,36 @@ private static void logSystemInfo() { |
329 | 329 | } |
330 | 330 | } |
331 | 331 |
|
332 | | - private static Map<String, String> collectPluginPolicyOverrides( |
| 332 | + private static Map<String, String> collectPluginPolicyPatches( |
333 | 333 | Set<PluginBundle> modulesBundles, |
334 | 334 | Set<PluginBundle> pluginsBundles, |
335 | 335 | Logger logger |
336 | 336 | ) { |
337 | | - var policyOverrides = new HashMap<String, String>(); |
| 337 | + var policyPatches = new HashMap<String, String>(); |
338 | 338 | var systemProperties = BootstrapInfo.getSystemProperties(); |
339 | 339 | systemProperties.keys().asIterator().forEachRemaining(key -> { |
340 | 340 | var value = systemProperties.get(key); |
341 | | - if (key instanceof String k && k.startsWith(PLUGIN_POLICY_OVERRIDE_PREFIX) && value instanceof String v) { |
342 | | - policyOverrides.put(k.substring(PLUGIN_POLICY_OVERRIDE_PREFIX.length()), v); |
| 341 | + if (key instanceof String k |
| 342 | + && value instanceof String v |
| 343 | + && k.startsWith(POLICY_PATCH_PREFIX) |
| 344 | + && k.equals(SERVER_POLICY_PATCH_NAME) == false) { |
| 345 | + policyPatches.put(k.substring(POLICY_PATCH_PREFIX.length()), v); |
343 | 346 | } |
344 | 347 | }); |
345 | 348 | var pluginNames = Stream.concat(modulesBundles.stream(), pluginsBundles.stream()) |
346 | 349 | .map(bundle -> bundle.pluginDescriptor().getName()) |
347 | 350 | .collect(Collectors.toUnmodifiableSet()); |
348 | 351 |
|
349 | | - for (var overriddenPluginName : policyOverrides.keySet()) { |
350 | | - if (pluginNames.contains(overriddenPluginName) == false) { |
| 352 | + for (var patchedPluginName : policyPatches.keySet()) { |
| 353 | + if (pluginNames.contains(patchedPluginName) == false) { |
351 | 354 | logger.warn( |
352 | | - "Found command-line override for unknown plugin [{}] (available plugins: [{}])", |
353 | | - overriddenPluginName, |
| 355 | + "Found command-line policy patch for unknown plugin [{}] (available plugins: [{}])", |
| 356 | + patchedPluginName, |
354 | 357 | String.join(", ", pluginNames) |
355 | 358 | ); |
356 | 359 | } |
357 | 360 | } |
358 | | - return policyOverrides; |
| 361 | + return policyPatches; |
359 | 362 | } |
360 | 363 |
|
361 | 364 | private static class EntitlementSelfTester { |
|
0 commit comments