Hi,

attached is patch to fix ticket:
https://fedorahosted.org/sssd/ticket/2785

And one additional patch to add DEBUG message.

Michal
>From 3227027c3680b4503477135608969ca904e491c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20=C5=BDidek?= <mzi...@redhat.com>
Date: Mon, 19 Oct 2015 15:38:08 +0200
Subject: [PATCH 1/2] util: Continue if setlocale fails

Fixes:
https://fedorahosted.org/sssd/ticket/2785

setlocale needs some environment variables
to be set in order to work. These variables
are not present in some special cases. We
should not fail completely in these cases
but continue with the compatible C locale.
---
 src/sss_client/ssh/sss_ssh_client.c | 4 +++-
 src/tools/tools_util.c              | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/sss_client/ssh/sss_ssh_client.c b/src/sss_client/ssh/sss_ssh_client.c
index 0d206ef..ea7a1cc 100644
--- a/src/sss_client/ssh/sss_ssh_client.c
+++ b/src/sss_client/ssh/sss_ssh_client.c
@@ -50,7 +50,9 @@ int set_locale(void)
 
     c = setlocale(LC_ALL, "");
     if (c == NULL) {
-        return EIO;
+        /* If setlocale fails, continue with the compatible
+         * C locale. */
+        DEBUG(SSSDBG_MINOR_FAILURE, "Unable to set locale\n");
     }
 
     errno = 0;
diff --git a/src/tools/tools_util.c b/src/tools/tools_util.c
index 68f6588..ab14e8d 100644
--- a/src/tools/tools_util.c
+++ b/src/tools/tools_util.c
@@ -259,7 +259,9 @@ int set_locale(void)
 
     c = setlocale(LC_ALL, "");
     if (c == NULL) {
-        return EIO;
+        /* If setlocale fails, continue with the compatible
+         * C locale. */
+        DEBUG(SSSDBG_MINOR_FAILURE, "Unable to set locale\n");
     }
 
     errno = 0;
-- 
2.1.0

>From a5d8bd4c0a1152475808b38cfd8175d18840a3f9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20=C5=BDidek?= <mzi...@redhat.com>
Date: Mon, 19 Oct 2015 15:49:02 +0200
Subject: [PATCH 2/2] server_setup: Log failed attempt to set locale

Failed setlocale call could cause unexpected
behaviour. It is better to generate DEBUG
message if this happens.
---
 src/util/server.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/util/server.c b/src/util/server.c
index 036dace..03796be 100644
--- a/src/util/server.c
+++ b/src/util/server.c
@@ -458,6 +458,7 @@ int server_setup(const char *name, int flags,
     bool dm;
     struct tevent_signal *tes;
     struct logrotate_ctx *lctx;
+    char *locale;
 
     ret = chown_debug_file(NULL, uid, gid);
     if (ret != EOK) {
@@ -508,7 +509,12 @@ int server_setup(const char *name, int flags,
     }
 
     /* Set up locale */
-    setlocale(LC_ALL, "");
+    locale = setlocale(LC_ALL, "");
+    if (locale == NULL) {
+        /* Just print debug message and continue */
+        DEBUG(SSSDBG_MINOR_FAILURE, "Unable to set locale\n");
+    }
+
     bindtextdomain(PACKAGE, LOCALEDIR);
     textdomain(PACKAGE);
 
-- 
2.1.0

_______________________________________________
sssd-devel mailing list
sssd-devel@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/sssd-devel

Reply via email to