>From 6e4ea98aa5c3375bc156e5e25fd25175fde889c3 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Tue, 11 Nov 2014 13:57:26 +0100 Subject: [PATCH] sss_client: Return a different error when sssd is not running The sss nss plugin is present in nsswitch by default due to glibc caching and problem with long living applications (e.g. GNOME). The SSSD nss plugin should behave as if it was functioning but had no data even thought sssd is not running. The errors have to be passed from nss plugin up to the user with minimal moidiffication. Resolves: https://fedorahosted.org/sssd/ticket/2439 --- src/sss_client/nss_group.c | 16 ++++++++++++++++ src/sss_client/nss_passwd.c | 16 ++++++++++++++++ src/sss_client/nss_services.c | 16 ++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/src/sss_client/nss_group.c b/src/sss_client/nss_group.c index 1614c33b5388326d82f1c9c1baaeee472a676cb9..eed19b0e9359fd7d3e5e5b7b012a4bacd0c9c22d 100644 --- a/src/sss_client/nss_group.c +++ b/src/sss_client/nss_group.c @@ -439,6 +439,14 @@ enum nss_status _nss_sss_getgrnam_r(const char *name, struct group *result, nret = NSS_STATUS_SUCCESS; out: + /* sss is by default in nsswitch. + * This is a workaround for problem with stopped sssd. + */ + if (nret == NSS_STATUS_UNAVAIL) { + nret = NSS_STATUS_NOTFOUND; + errno = 0; + } + sss_nss_unlock(); return nret; } @@ -530,6 +538,14 @@ enum nss_status _nss_sss_getgrgid_r(gid_t gid, struct group *result, nret = NSS_STATUS_SUCCESS; out: + /* sss is by default in nsswitch. + * This is a workaround for problem with stopped sssd. + */ + if (nret == NSS_STATUS_UNAVAIL) { + nret = NSS_STATUS_NOTFOUND; + errno = 0; + } + sss_nss_unlock(); return nret; } diff --git a/src/sss_client/nss_passwd.c b/src/sss_client/nss_passwd.c index 290aed80e0ddd817a0b2c818fdd0816cd2673a41..58e3a2085df4bea22e595b1368bc940a9699345b 100644 --- a/src/sss_client/nss_passwd.c +++ b/src/sss_client/nss_passwd.c @@ -218,6 +218,14 @@ enum nss_status _nss_sss_getpwnam_r(const char *name, struct passwd *result, nret = NSS_STATUS_SUCCESS; out: + /* sss is by default in nsswitch. + * This is a workaround for problem with stopped sssd. + */ + if (nret == NSS_STATUS_UNAVAIL) { + nret = NSS_STATUS_NOTFOUND; + errno = 0; + } + sss_nss_unlock(); return nret; } @@ -301,6 +309,14 @@ enum nss_status _nss_sss_getpwuid_r(uid_t uid, struct passwd *result, nret = NSS_STATUS_SUCCESS; out: + /* sss is by default in nsswitch. + * This is a workaround for problem with stopped sssd. + */ + if (nret == NSS_STATUS_UNAVAIL) { + nret = NSS_STATUS_NOTFOUND; + errno = 0; + } + sss_nss_unlock(); return nret; } diff --git a/src/sss_client/nss_services.c b/src/sss_client/nss_services.c index 64e0b43e1643e4e76d2381a6b062335c3d513a21..1984cf431ca2444de29b23ff516d1a818c201870 100644 --- a/src/sss_client/nss_services.c +++ b/src/sss_client/nss_services.c @@ -255,6 +255,14 @@ _nss_sss_getservbyname_r(const char *name, nret = NSS_STATUS_SUCCESS; out: + /* sss is by default in nsswitch. + * This is a workaround for problem with stopped sssd. + */ + if (nret == NSS_STATUS_UNAVAIL) { + nret = NSS_STATUS_NOTFOUND; + errno = 0; + } + sss_nss_unlock(); return nret; } @@ -354,6 +362,14 @@ _nss_sss_getservbyport_r(int port, const char *protocol, nret = NSS_STATUS_SUCCESS; out: + /* sss is by default in nsswitch. + * This is a workaround for problem with stopped sssd. + */ + if (nret == NSS_STATUS_UNAVAIL) { + nret = NSS_STATUS_NOTFOUND; + errno = 0; + } + sss_nss_unlock(); return nret; } -- 2.1.0