I would create a helper function to be called on return that transforms the error
accordingly. This will allow to write the code _and_ the comment once.
The comment should be changed to something like this in either case:
/* When sssd is stopped return a safe error code as if sss was not
configured at all in nsswitch. This prevents bogus errors from causing
issues in applications, before sssd starts or if it fails to respond. */
No need to mention that sss is by default in nsswitch, as it is not in all
distributions and it really is inconsequential, the same behaviour change
hleps when sss is not the default but is has been manually added and sssd is
stopped or not started yet (for example during boot).
HTH,
Simo.
----- Original Message -----
From: "Lukas Slebodnik" <lslebodn(a)redhat.com>
To: sssd-devel(a)lists.fedorahosted.org
Sent: Wednesday, November 12, 2014 9:10:43 AM
Subject: [SSSD] [PATCH] sss_client: Return a different error when sssd is not running
ehlo,
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
How to test:
* minimal installation of fedora/rhel7 should already contain sss
in /etc/nsswitch.
* grep sss /etc/nsswitch
* package sssd-client should be installed on machine
* test glibc functions whether ther return 0 for nonexisting group.
(there is attached file sssd_error_code_test.c for lazy people :-)
* the same return code should be with and without sss in
/etc/nsswitch.conf
authconfig --disablesssd --update
authconfig --enablesssd --update
NOTE: I just patched functions which returned non-zero return code with
stopped
sssd, because initgroups, getservent_r, getnetgrent_r returned 0 even with
sss
in nsswitch.
There is also alternative solution from Stephen Gallagher which I found after
writing my patch :-)
https://bugzilla.redhat.com/attachment.cgi?id=788567
LS
_______________________________________________
sssd-devel mailing list
sssd-devel(a)lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/sssd-devel
--
Simo Sorce * Red Hat, Inc. * New York