]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: init: don't use environment locale
authorMaxime de Roucy <maxime.deroucy@gmail.com>
Wed, 18 May 2016 21:13:38 +0000 (23:13 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 19 May 2016 05:19:19 +0000 (07:19 +0200)
This patch removes setlocale from the main function. It was introduced
by commit 379d9c7 ("MEDIUM: init: allow directory as argument of -f")
in 1.7-dev a few commits ago after a discussion on the mailing list.

Some regex may have different behaviours depending on the
locale. Some LUA scripts may change their behaviour too
(http://lua-users.org/wiki/LuaLocales).

Without this patch (haproxy is using setlocale) :

$ cat locale.cfg
defaults
  mode http

frontend test
  bind :9000
  mode http
  use_backend testbk if { hdr_reg(X-Test) ^\w+$ }

backend testbk
  mode http
  server s 127.0.0.1:80

$ LANG=fr_FR.UTF-8 ./haproxy -f locale.cfg
$ curl -i -H "X-Test: échec" localhost:9000
HTTP/1.1 200 OK
...

$ LANG=C ./haproxy -f locale.cfg
$ curl -i -H "X-Test: échec" localhost:9000
HTTP/1.0 503 Service Unavailable
...

doc/haproxy.1
doc/management.txt
src/haproxy.c

index cc9c702b3a0fe03b443d4ea782b839c638c046dc..73c2aee767825fbfff4060e7dc26e6669351c796 100644 (file)
@@ -35,8 +35,8 @@ instances without risking the system's stability.
 .TP
 \fB\-f <configuration file|dir>\fP
 Specify configuration file or directory path. If the argument is a directory
-the files (and only files) it containes are added in lexical order (respecting
-LC_COLLATE) ; only non hidden files with ".cfg" extension are added.
+the files (and only files) it containes are added in lexical order (using
+LC_COLLATE=C) ; only non hidden files with ".cfg" extension are added.
 
 .TP
 \fB\-L <name>\fP
index 4f0af1062bc6096508b4daf69a695b65550beb1b..119c3fa6da71ff180dae58228372cca549d8af18 100644 (file)
@@ -136,7 +136,7 @@ list of options is :
 
   -f <cfgfile|cfgdir> : adds <cfgfile> to the list of configuration files to be
     loaded. If <cfgdir> is a directory, all the files (and only files) it
-    containes are added in lexical order (respecting LC_COLLATE) to the list of
+    containes are added in lexical order (using LC_COLLATE=C) to the list of
     configuration files to be loaded ; only files with ".cfg" extension are
     added, only non hidden files (not prefixed with ".") are added.
     Configuration files are loaded and processed in their declaration order.
index 582ad8203460abc1b1c4b2b9c1e644b7831a8c73..c6d1505d98c57c27b40c577cb67e0ae5fc8df8c3 100644 (file)
@@ -32,7 +32,6 @@
 #include <string.h>
 #include <ctype.h>
 #include <dirent.h>
-#include <locale.h>
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/types.h>
@@ -1752,9 +1751,6 @@ int main(int argc, char **argv)
        char errmsg[100];
        int pidfd = -1;
 
-       /* get the locale from the environment variables */
-       setlocale(LC_ALL, "");
-
        init(argc, argv);
        signal_register_fct(SIGQUIT, dump, SIGQUIT);
        signal_register_fct(SIGUSR1, sig_soft_stop, SIGUSR1);