Blame SOURCES/0132-sss_client-Work-around-glibc-bug.patch

905b4d
From 2e84796d8e23ee6e406c0625288655e056b0d90d Mon Sep 17 00:00:00 2001
905b4d
From: Lukas Slebodnik <lslebodn@redhat.com>
905b4d
Date: Tue, 18 Nov 2014 12:02:10 +0100
905b4d
Subject: [PATCH 132/132] sss_client: Work around glibc bug
905b4d
905b4d
glibc is inconsistent with how it treats and returns NSS_STATUS_UNAVAIL.
905b4d
905b4d
The sss nss plugin is present in nsswitch by default on some platforms
905b4d
due to glibc caching and problem with long living applications (e.g. GNOME).
905b4d
But sssd needn't be configuread and it cause problems in some programs.
905b4d
In this situation, the SSSD nss plugin should behave as if it was functioning
905b4d
but had no data even thought sssd is not running. The errors have to be passed
905b4d
from nss plugin up to the user with minimal moidiffication.
905b4d
905b4d
Thanks to Stephen Gallagher for initial patch.
905b4d
905b4d
Resolves:
905b4d
https://fedorahosted.org/sssd/ticket/2439
905b4d
905b4d
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
905b4d
---
905b4d
 src/conf_macros.m4      | 13 +++++++++++++
905b4d
 src/sss_client/common.c | 10 ++++++++++
905b4d
 2 files changed, 23 insertions(+)
905b4d
905b4d
diff --git a/src/conf_macros.m4 b/src/conf_macros.m4
905b4d
index df9d1ddf89be38709e56ad4b214e5f7c6cbb0f97..027490e524f321b9d444395e788aa7476dd916e9 100644
905b4d
--- a/src/conf_macros.m4
905b4d
+++ b/src/conf_macros.m4
905b4d
@@ -708,6 +708,19 @@ AC_ARG_ENABLE([dbus-tests],
905b4d
               [build_dbus_tests=yes])
905b4d
 AM_CONDITIONAL([BUILD_DBUS_TESTS], [test x$build_dbus_tests = xyes])
905b4d
 
905b4d
+AC_ARG_ENABLE([sss-default-nss-plugin],
905b4d
+              [AS_HELP_STRING([--enable-sss-default-nss-plugin],
905b4d
+                              [This option change standard behaviour of sss nss
905b4d
+                               plugin. If this option is enabled the sss nss
905b4d
+                               plugin will behave as it was not in
905b4d
+                               nsswitch.conf when sssd is not running.
905b4d
+                               [default=no]])],
905b4d
+              [enable_sss_default_nss_plugin=$enableval],
905b4d
+              [enable_sss_default_nss_plugin=no])
905b4d
+AS_IF([test x$enable_sss_default_nss_plugin = xyes],
905b4d
+      AC_DEFINE_UNQUOTED([NONSTANDARD_SSS_NSS_BEHAVIOUR], [1],
905b4d
+          [whether to build sssd nss plugin with nonstandard glibc behaviour]))
905b4d
+
905b4d
 AC_DEFUN([WITH_NFS],
905b4d
   [ AC_ARG_WITH([nfsv4-idmapd-plugin],
905b4d
                 [AC_HELP_STRING([--with-nfsv4-idmapd-plugin],
905b4d
diff --git a/src/sss_client/common.c b/src/sss_client/common.c
905b4d
index ebe783aba9cfa3dc11a529e7875966f139eea1af..7c4bb7ab8769a72f943158366f358b108bfc3bdc 100644
905b4d
--- a/src/sss_client/common.c
905b4d
+++ b/src/sss_client/common.c
905b4d
@@ -724,7 +724,12 @@ enum nss_status sss_nss_make_request(enum sss_cli_command cmd,
905b4d
 
905b4d
     ret = sss_cli_check_socket(errnop, SSS_NSS_SOCKET_NAME);
905b4d
     if (ret != SSS_STATUS_SUCCESS) {
905b4d
+#ifdef NONSTANDARD_SSS_NSS_BEHAVIOUR
905b4d
+        errno = 0;
905b4d
+        return NSS_STATUS_NOTFOUND;
905b4d
+#else
905b4d
         return NSS_STATUS_UNAVAIL;
905b4d
+#endif
905b4d
     }
905b4d
 
905b4d
     ret = sss_cli_make_request_nochecks(cmd, rd, repbuf, replen, errnop);
905b4d
@@ -735,7 +740,12 @@ enum nss_status sss_nss_make_request(enum sss_cli_command cmd,
905b4d
         return NSS_STATUS_SUCCESS;
905b4d
     case SSS_STATUS_UNAVAIL:
905b4d
     default:
905b4d
+#ifdef NONSTANDARD_SSS_NSS_BEHAVIOUR
905b4d
+        errno = 0;
905b4d
+        return NSS_STATUS_NOTFOUND;
905b4d
+#else
905b4d
         return NSS_STATUS_UNAVAIL;
905b4d
+#endif
905b4d
     }
905b4d
 }
905b4d
 
905b4d
-- 
905b4d
1.9.3
905b4d