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