[PATCH 0/4] nsswitch.conf reloading refactoring

DJ Delorie dj@redhat.com
Thu Jun 25 04:04:09 GMT 2020

The purpose of this sequence of patches is to allow /etc/nsswitch.conf
to be dynamically reloaded if it changes while a process is running.
Previously, nsswitch.conf is loaded once at first use, but long
running programs and highly mobile devices have caused a need for a
more dynamic approach.

The work was done by Florian and I, and I've kept our work separate.
Florian wrote new implementations of the internal datastructures and
parsers (patches 0001 through 0003), and I did the integration of
those into the rest of the system (patch 0004).

The general idea is that there's a cache of "action lists" which
correspond to the portion of nsswitch.conf after the ":".  There's an
array of the current action lists indexed by database (i.e. "passwd"
or "hosts") which points into the cache.  The action list refers to a
list of loaded service modules, which have all needed ABI functions

Since all the data is loaded once and never changed (since it's
cached), it becomes read-only after load, so no atomics are required
outside of the load code.

The rename of "service_user" to "action_list" was intentional, to
ensure that all use cases were looked at during the conversion.

Tested on x86-64.  Also ran some manual tests which did "gethostname"
while nsswitch changed between hosts and dns.  Also tested nscd

Version 1 :-)

[PATCH 1/4] nss: Introduce <nss_module.h>
      Florian Weimer <fweimer@redhat.com>

   nss_module handles all dynamically loadable service modules and
   their entry points.

[PATCH 2/4] <nss_action.h>: New abstraction for combining NSS modules
      Florian Weimer <fweimer@redhat.com>

   nss_action handles the cache of action lists and action parsing.

[PATCH 3/4] nss: Implement <nss_database.h>
      Florian Weimer <fweimer@redhat.com>

   nss_database controls overall reloading and stores the list of
   currently active action lists for each service.

[PATCH 4/4] nsswitch: use new internal API
      DJ Delorie <dj@redhat.com>

   Removing the old (now unneeded) core code, integrating all users of
   the core code, and adding some remaining core functionality.

More information about the Libc-alpha mailing list