This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=df60765ed4bc6640b788c796dd0c627d7714f807

commit df60765ed4bc6640b788c796dd0c627d7714f807
Author: Guillem Jover <[email protected]>
AuthorDate: Tue Jul 2 23:21:47 2024 +0200

    Dpkg::Vendor::Debian: Guarantee UTF-8 locale codeset on sanitize-env
    
    If LC_ALL is set move it to LANG (as it is the lowest priority in the
    override stack), and delete all other LC_* variables which would have
    been shadowed anyway. Set LC_CTYPE C.UTF-8.
---
 scripts/Dpkg/Vendor/Debian.pm | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm
index 8d6983485..edf94bc19 100644
--- a/scripts/Dpkg/Vendor/Debian.pm
+++ b/scripts/Dpkg/Vendor/Debian.pm
@@ -1,5 +1,5 @@
 # Copyright © 2009-2011 Raphaël Hertzog <[email protected]>
-# Copyright © 2009, 2011-2017 Guillem Jover <[email protected]>
+# Copyright © 2009-2024 Guillem Jover <[email protected]>
 #
 # Hardening build flags handling derived from work of:
 # Copyright © 2009-2011 Kees Cook <[email protected]>
@@ -88,7 +88,21 @@ sub run_hook {
         # Reset umask to a sane default.
         umask 0022;
         # Reset locale to a sane default.
+        #
+        # We ignore the LANGUAGE GNU extension, as that only affects
+        # LC_MESSAGES which will use LC_CTYPE for its codeset. We need to
+        # move the high priority LC_ALL catch-all into the low-priority
+        # LANG catch-all so that we can override LC_* variables, and remove
+        # any existing LC_* variables which would have been ignored anyway,
+        # and would now take precedence over LANG.
+        if (length $ENV{LC_ALL}) {
+            $ENV{LANG} = delete $ENV{LC_ALL};
+            foreach my $lc (grep { m/^LC_/ } keys %ENV) {
+                delete $ENV{$lc};
+            }
+        }
         $ENV{LC_COLLATE} = 'C.UTF-8';
+        $ENV{LC_CTYPE} = 'C.UTF-8';
     } elsif ($hook eq 'backport-version-regex') {
         return qr/~(bpo|deb)/;
     } else {

-- 
Dpkg.Org's dpkg

Reply via email to