]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Correctly set locale before start.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 24 Sep 2015 14:30:04 +0000 (15:30 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 24 Sep 2015 14:30:04 +0000 (15:30 +0100)
src/libutil/util.c
src/rspamd.c

index 496bd0298b857e3b9e4fc096a13e2e8b16f2a2b6..11e3248accc8ad0e0c744c297450920f9d108bc9 100644 (file)
@@ -46,6 +46,9 @@
 #ifdef HAVE_READPASSPHRASE_H
 #include <readpassphrase.h>
 #endif
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif
 
 #ifdef __APPLE__
 #include <mach/mach_time.h>
@@ -1920,12 +1923,17 @@ rspamd_init_libs (void)
        ottery_init (NULL);
 
        rspamd_cryptobox_init ();
-#ifdef HAVE_SETLOCALE
-       /* Set locale setting to C locale to avoid problems in future */
-       setlocale (LC_ALL, "C");
-       setlocale (LC_CTYPE, "C");
-       setlocale (LC_MESSAGES, "C");
-       setlocale (LC_TIME, "C");
+#ifdef HAVE_LOCALE_H
+       if (getenv ("LANG") == NULL) {
+               setlocale (LC_ALL, "C");
+               setlocale (LC_CTYPE, "C");
+               setlocale (LC_MESSAGES, "C");
+               setlocale (LC_TIME, "C");
+       }
+       else {
+               /* Just set the default locale */
+               setlocale (LC_ALL, "");
+       }
 #endif
 
 #ifdef HAVE_OPENSSL
index 48874cffec521baf2aa7687a80698528f7eb24ba..bc13f6e473f2e4ce7490e95a26602c9eada0bdf1 100644 (file)
 #include <openssl/rsa.h>
 #include <openssl/pem.h>
 #endif
-#ifdef HAVE_LOCALE_H
-#include <locale.h>
-#define HAVE_SETLOCALE 1
-#endif
 
 #define msg_err_main(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \
         rspamd_main->server_pool->tag.tagname, rspamd_main->server_pool->tag.uid, \
@@ -101,7 +97,7 @@ static gboolean gen_keypair = FALSE;
 static gboolean encrypt_password = FALSE;
 /* List of workers that are pending to start */
 static GList *workers_pending = NULL;
-static GHashTable *vars = NULL;
+static GHashTable *ucl_vars = NULL;
 
 #ifdef HAVE_SA_SIGINFO
 static siginfo_t static_sg[64];
@@ -805,7 +801,7 @@ load_rspamd_config (struct rspamd_config *cfg, gboolean init_modules)
        cfg->compiled_workers = workers;
 
        if (!rspamd_config_read (cfg, cfg->cfg_name, NULL,
-               config_logger, rspamd_main, vars)) {
+               config_logger, rspamd_main, ucl_vars)) {
                return FALSE;
        }
 
@@ -1117,12 +1113,12 @@ main (gint argc, gchar **argv, gchar **env)
                                v = g_strdup (t + 1);
                                *t = '\0';
 
-                               if (vars == NULL) {
-                                       vars = g_hash_table_new_full (rspamd_strcase_hash,
+                               if (ucl_vars == NULL) {
+                                       ucl_vars = g_hash_table_new_full (rspamd_strcase_hash,
                                                        rspamd_strcase_equal, g_free, g_free);
                                }
 
-                               g_hash_table_insert (vars, k, v);
+                               g_hash_table_insert (ucl_vars, k, v);
                        }
                }
        }