From a1b8b52f4d6d67bdaade6b5cf49c42313913ccf9 Mon Sep 17 00:00:00 2001 From: Peter Hofer Date: Thu, 28 Mar 2024 17:54:28 +0100 Subject: [PATCH] Retain LC_ variables when sanitizing the environment for the image builder. --- .../src/com/oracle/svm/driver/NativeImage.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java index e6dbbe5d371c..dec65d1e42f6 100644 --- a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java +++ b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java @@ -1778,7 +1778,7 @@ private static void deprecatedSanitizeJVMEnvironment(Map environ } private static void sanitizeJVMEnvironment(Map environment, Map imageBuilderEnvironment) { - Set requiredKeys = new HashSet<>(List.of("PATH", "PWD", "HOME", "LANG", "LC_ALL")); + Set requiredKeys = new HashSet<>(List.of("PATH", "PWD", "HOME", "LANG", "LANGUAGE")); Function keyMapper; if (OS.WINDOWS.isCurrent()) { requiredKeys.addAll(List.of("TEMP", "INCLUDE", "LIB")); @@ -1788,7 +1788,9 @@ private static void sanitizeJVMEnvironment(Map environment, Map< } Map 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); } });