Skip to content

Commit

Permalink
[GR-52975] Retain LC_ variables when sanitizing the environment for t…
Browse files Browse the repository at this point in the history
…he image builder.

PullRequest: graal/17398
  • Loading branch information
peter-hofer committed Mar 29, 2024
2 parents c504469 + a1b8b52 commit 9cdc261
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,7 @@ private static void deprecatedSanitizeJVMEnvironment(Map<String, String> environ
}

private static void sanitizeJVMEnvironment(Map<String, String> environment, Map<String, String> imageBuilderEnvironment) {
Set<String> requiredKeys = new HashSet<>(List.of("PATH", "PWD", "HOME", "LANG", "LC_ALL"));
Set<String> requiredKeys = new HashSet<>(List.of("PATH", "PWD", "HOME", "LANG", "LANGUAGE"));
Function<String, String> keyMapper;
if (OS.WINDOWS.isCurrent()) {
requiredKeys.addAll(List.of("TEMP", "INCLUDE", "LIB"));
Expand All @@ -1788,7 +1788,9 @@ private static void sanitizeJVMEnvironment(Map<String, String> environment, Map<
}
Map<String, String> restrictedEnvironment = new HashMap<>();
environment.forEach((key, val) -> {
if (requiredKeys.contains(keyMapper.apply(key))) {
String mappedKey = keyMapper.apply(key);
// LC_* are locale vars that override LANG for specific categories (or all, with LC_ALL)
if (requiredKeys.contains(mappedKey) || mappedKey.startsWith("LC_")) {
restrictedEnvironment.put(key, val);
}
});
Expand Down

0 comments on commit 9cdc261

Please sign in to comment.