From 32935ef03767814ef54c4c1905e00e320261c67c Mon Sep 17 00:00:00 2001
From: Laurent Bercot
Date: Tue, 3 Jul 2018 21:38:08 +0000
Subject: Add some documentation
---
doc/index.html | 59 +++++++++++++++----
doc/libnsss/index.html | 134 +++++++++++++++++++++++++++++++------------
doc/libnsss/nsss-switch.html | 29 ++++++++++
doc/libnsss/nsss-unix.html | 29 ++++++++++
doc/libnsssd/index.html | 102 ++++++++++++++++++++++++++++++++
doc/nsssd-nslcd.html | 85 +++++++++++++++++++++++++++
doc/nsssd-unix.html | 88 ++++++++++++++++++++++++++++
doc/overview.html | 101 +++++++++++++++++++++++++++++++-
8 files changed, 579 insertions(+), 48 deletions(-)
create mode 100644 doc/libnsss/nsss-switch.html
create mode 100644 doc/libnsss/nsss-unix.html
create mode 100644 doc/libnsssd/index.html
create mode 100644 doc/nsssd-nslcd.html
create mode 100644 doc/nsssd-unix.html
diff --git a/doc/index.html b/doc/index.html
index 49cf697..d4b7861 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -31,20 +31,32 @@ function is provided by the system's libc. However, not all libcs implement
a configurable backend for the user/group database. For instance the
musl libc, on Linux, only supports
the standard /etc/passwd mechanism; it also supports the
-nscd protocol but this is not quite enough to implement the
-full set of database access functions with certain backends (such as a
-LDAP server).
+nscd protocol but this is not quite enough:
+
+
+
+ - musl only connects to nscd when it cannot find an answer in
+its files backend
+ - The nscd protocol does not support enumeration, so primitives
+such as getpwent() cannot be implemented over nscd.
+
+
+
+ The mechanism used by glibc, called Name Service Switch
+(abbreviated to nsswitch or NSS), has its own
+set of issues that makes it unsuitable
+in certain situations.
- nsss is a secure implementation of configurable user/group/shadow
-database access, providing getpwnam() et al. functionality
-by communicating over a Unix domain socket with a daemon; the daemon
-can perform lookups in any database it chooses.
+ nsss is a secure implementation of a "name service switch":
+configurable user/group/shadow database access, providing getpwnam()
+et al. functionality by communicating over a Unix domain socket with a daemon;
+the daemon can perform lookups in any database it chooses.
- Unlike NSS, nsss does not perform dynamic module
+ nsss does not perform dynamic module
loading, only adds a small footprint to the application's binary,
and does not add any complex decision engine into the client's address
space. Applications can be statically linked against the nsss
@@ -55,7 +67,8 @@ functions.
@@ -71,6 +84,10 @@ functions.
2.6.5.0 or later. It's a build-time requirement. It's also a run-time
requirement if you link against the shared version of the skalibs
library.
+ s6 version
+2.7.1.1 or later. It's a run-time requirement only, to run
+the nsssd service (and can be done without if you have a suitable replacement
+for s6-ipcserver).
Licensing
@@ -112,14 +129,32 @@ the previous versions of nsss and the current one.
Commands
+
+ The following commands are not meant to be directly invoked on the
+command-line. They are meant to be used behind a Unix domain socket
+super-server such as
+s6-ipcserver
+in order to provide a
+local service.
+Depending on the chosen command, the service will provide a different
+backend to the name service.
+
+
+
+ Future versions of nsss will come with more backends.
+
+
Libraries
- - The nsss library interface
- - The following primitives are also implemented:
+
- The nsss library interface,
+which applications use. A client application using one of the
+following primitives will automatically perform libnsss calls:
- endpwent()
- setpwent()
@@ -144,6 +179,8 @@ the previous versions of nsss and the current one.
- getspnam()
- getspnam_r()
+ The nsssd library interface,
+which can be used to write additional backends.
diff --git a/doc/libnsss/index.html b/doc/libnsss/index.html
index 0307725..ac99e54 100644
--- a/doc/libnsss/index.html
+++ b/doc/libnsss/index.html
@@ -21,23 +21,100 @@
General information
- libnsss is a client library meant to be used by client
-programs needing utmp functionality. It interacts with various
-server-side daemons such as
-nsssd-unix.
+ libnsss is the generic name for the nsss client library.
+This library is made of several parts:
+
+
+
+ - nsss-unix: this is a set of
+functions to access the /etc/passwd, /etc/group
+and /etc/shadow files.
+ - nsss-switch: this is a set of
+functions to connect to a nsssd-service and interact with
+various server-side daemons such as
+nsssd-unix or
+nsssd-nslcd.
+ - nsss-all: this is a set of
+functions that try connecting to a nsssd service first, and fall
+back to the nsss-unix implementation
+if the connection fails (no nsssd service is running).
- Application programs can use it directly, but most existing programs
-simply use the standard
+ Both nsss-unix and
+nsss-switch are made of two parts:
+
+
+
+ - An internal, clean API, that applications can use directly
+if they include the nsss/nsss.h header, or the relevant
+nsss/nsss-unix.h or nsss/nsss-switch.h header.
+ - As a series of thin wrappers around the internal API, an
+implementation of the standard following functions:
+
+ - endpwent()
+ - setpwent()
+ - getpwent()
+ - getpwent_r()
+ - getpwuid()
+ - getpwuid_r()
+ - getpwnam()
+ - getpwnam_r()
+ - endgrent()
+ - setgrent()
+ - getgrent()
+ - getgrent_r()
+ - getgrgid()
+ - getgrgid_r()
+ - getgrnam()
+ - getgrnam_r()
+ - endspent()
+ - setspent()
+ - getspent()
+ - getspent_r()
+ - getspnam()
+ - getspnam_r()
+
+ The functions are prefixed with nsss_unix_ or
+nsss_switch_. For instance, nsss_unix_getpwnam()
+is the implementation of getpwnam() that uses the
+/etc/passwd backend.
+
+
+
+ nsss-all does not have an internal API. It only contains the
+implementation of the above standard functions, as
+nsss_all_getpwnam() and similar.
+
+
+ Compiling
+
+
+ Application programs can use the internal API directly, or
+the prefixed nsss_ functions directly. Most programs,
+however, will simply use the standard
pwd.h,
grp.h or
shadow.h
-interfaces, which in nsss are implemented as a series of thin wrappers
-around the nsss library.
+interfaces. nsss provides a version of these standard headers: if an
+application is built with these headers, then getpwnam()
+will automatically be aliased to nsss_all_getpwnam(), and
+the other functions will be aliased similarly.
- Compiling
+
+ If the NSSS_DISABLE_SWITCH macro is defined before inclusion of the
+nsss headers, then getpwnam() will be aliased to
+nsss_unix_getpwnam() instead, and the other functions will
+follow the same pattern. If, instead, the NSSS_DISABLE_UNIX macro
+is defined before inclusion of the nsss headers, then getpwnam()
+will be aliased to nsss_switch_getpwnam(), and the other
+functions will follow the same pattern.
+
+
+
+ So, the proper steps to compile an application with libnsss are:
+
- Make sure the nsss headers, as well as the skalibs headers,
@@ -48,6 +125,10 @@ just #include <pwd.h>, which will work as long
as the nsss/pwd.h header is accessible in your header
search path.
- Same thing for grp.h and shadow.h.
+ - If don't want to use the nsss-all implementation of
+"try nsss-switch and fall back to nsss-unix if it fails", then
+compile with -DNSSS_DISABLE_SWITCH or -DNSSS_DISABLE_UNIX as
+desired.
Linking
@@ -63,35 +144,16 @@ sysdeps directory.
Programming
-
- The nsss/nsss.h header is actually a collection of headers:
-
-
- - nsss/nsss-unix.h implements basic access to the
-/etc/passwd, /etc/group and /etc/shadow
-database.
- - nsss/nsss-switch.h implements connection via a Unix
-domain socket to a listening nsssd daemon, implementing an
-authentication backend based on what implementation of
-the daemon is listening.
- - nsss/nsss-all.h implements a safe policy: first a
-connection via nsss-switch is attempted, and if no daemon
-is listening, the safe nsss-unix backend is used.
+ - nsss-all, nsss-switch and nsss-unix implement the
+POSIX
+layer of user database access, plus a few
+GNU extensions.
+ - The nsss/nsss-unix.h header
+can be used to access the internal nsss-unix API.
+ - The nsss/nsss-switch.h header
+can be used to access the internal nsss-switch API.
-
- By default, the getpwnam() et al. functions are aliased
-to their nsss-all implementations. You can disable the
-nsss-unix fallback by compiling with the NSSS_DISABLE_UNIX
-macro defined (-DNSSS_DISABLE_UNIX). Or you can disable any
-attempt to connect to a daemon by compiling with the
-NSSS_DISABLE_SWITCH macro defined (-DNSSS_DISABLE_SWITCH).
-
-
-
- (To be completed.)
-
-