Add a notification facility for watching for key changes

Add keyctl commands and library functions to handle the setting and removal
of watches on keys for notifications of change events.  Five keyctl
commands are defined:

 (1) keyctl watch <key>

     Watch the specified key for changes, logging notifications to stdout.

 (2) keyctl watch_session [-n <name>] <notifylog> <gclog> <fd> prog [<arg>...]

     Create a new session keyring and attach a watch to it that an
     auxiliary logging process monitors.  The nominated program is run with
     the session program with the arguments given.

     The session keyring can be given a name.  The logging process will log
     synchronous events to file notifylog and asynchronous events to file
     gclog.

     The specified file descriptor will be attached to the watch_queue and
     left open across the exec.  This can be made use of by the next few
     commands.

 (3) keyctl watch_add <fd> <key>
 (4) keyctl watch_rm <fd> <key>

     Add/remove a watch on the specified key to/from the given watch_queue
     derived from watch_session.

 (5) keyctl watch_sync <fd>

     Wait for the logging process that's watching the given watch_queue to
     synchronise.

Commands (2) to (5) are primarily provided for the testsuite's purposes.

Signed-off-by: David Howells <dhowells@redhat.com>
12 files changed