This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] ldconfig: set LC_COLLATE to C
- From: Aurelien Jarno <aurelien at aurel32 dot net>
- To: libc-alpha at sourceware dot org
- Cc: Aurelien Jarno <aurelien at aurel32 dot net>
- Date: Sun, 26 Nov 2017 12:32:04 +0100
- Subject: [PATCH] ldconfig: set LC_COLLATE to C
- Authentication-results: sourceware.org; auth=none
ldconfig supports "include" directives and use the glob function to
process them. The glob function sort entries according to the LC_COLLATE
category. When using a standard "include /etc/ld.so.conf.d/*.conf" entry
in /etc/ld.so.conf, the order therefore depends on the locale used to
ldconfig. Prefixing the files that have to be processed last with "z"
or "zz" (as it is often used) therefore doesn't work correctly as "z"
is not always the last letter. For example in the et_EE locale, it is
sorted after the "s".
This patch fixes that by setting LC_COLLATE to C in order to process
files in deterministic order, independently of the locale used to launch
ldconfig.
---
elf/ldconfig.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index 89042351f8..2c01ab567b 100644
--- a/elf/ldconfig.c
+++ b/elf/ldconfig.c
@@ -1259,6 +1259,10 @@ main (int argc, char **argv)
/* Set locale via LC_ALL. */
setlocale (LC_ALL, "");
+ /* But keep the C collation. That way `include' directives using
+ globbing patterns are processed in a locale-independent order. */
+ setlocale (LC_COLLATE, "C");
+
/* Set the text message domain. */
textdomain (_libc_intl_domainname);
--
2.15.0