[Pkg-sysvinit-devel] Bug#343596: sysvinit: [a-z] must be used in maintainer scripts only under C locale

Denis Barbier barbier at debian.org
Fri Dec 16 14:04:51 UTC 2005


Package: sysvinit
Version: 2.86.ds1-6
Severity: normal
Tags: patch

Hi,

[a-z] may not represent all 26 ASCII lowercase letters in regular
expressions, eg. Estonian collation sorts z between s and t:
  $ echo rstuvwxyz | LC_ALL=en_US.UTF-8 sed -e 's/[a-z]//g'

  $ echo rstuvwxyz | LC_ALL=et_EE.UTF-8 sed -e 's/[a-z]//g'
  tuvwxy
As shown above, this applies to sed, but also awk, grep, expr
  $ echo tuv | LC_ALL=et_EE.UTF-8 awk '/[a-z]/ {print}'
  $ echo tuv | LC_ALL=et_EE.UTF-8 grep [a-z]
  $ LC_ALL=et_EE.UTF-8 expr tuv : [a-z]
  $
and many more.
On the other hand, some commands always work with C collation rules,
most notably tr:
  $ echo 1rstuvwxyz2 | LC_ALL=et_EE.UTF-8 tr -d a-z
  12
or perl and python if they are not told to switch to user's locale.

One must then switch to C locale to avoid those collation issues,
see attached patch.  In this particular case, it is very unlikely
that someone gets hit by this bug, but well, it is easy to fix.

Thanks

Denis
-------------- next part --------------
diff -ru debian.orig/initscripts/preinst debian/initscripts/preinst
--- debian.orig/initscripts/preinst	2005-12-16 13:31:48.000000000 +0100
+++ debian/initscripts/preinst	2005-12-16 13:33:34.000000000 +0100
@@ -29,7 +29,7 @@
 	echo "Saving variables from /etc/init.d/boot .."
 	[ ! -d /etc/default ] && mkdir /etc/default
 	rm -f /etc/default/rcS.sed
-	grep '^[A-Z]*=' /etc/init.d/boot | (
+	LC_ALL=C grep '^[A-Z]*=' /etc/init.d/boot | (
 		while read line
 		do
 			var=`echo $line | sed 's/=.*$//'`


More information about the Pkg-sysvinit-devel mailing list