Allow unset auth_type to mean local
Log files are 0640, not 0666.  WTF?
Added logging API

So that multiple threads can log to files with (a) no thread
race conditions, and (b) file locks for external processes.

We do this by opening a file descriptor for each file, and leaving
it open for a long time.  When a thread needs to log to a file,
it passes the filename to the API, and gets an FD in return.
That FD is then left open, for re-use by other threads.

The FD is also protected by a mutex, so that other threads which
try to log to the same file have to wait until the current one
is finished.

This nonsense is required because the POSIX file lock API is
per process, so that locks in one thread don't block other threads.
The POSIX API also releases *all* locks on a file when ANY FD for
that file.  So the threads can't rely on just file locks to prevent
readers from reading the wrong thing.  They have to have ONE FD
for all threads.

Since the FD is never closed, the locks on it always apply.
Since the FD is protected by a mutex, only one thread at a time
can write to the file.

And peace reigns in the land.
Use the new logfile API
Use the new logfile API
Use mode_t, and create any necessary directories
re-open the file if someone has deleted it

i.e. while we waited for the lock, or while we were doing
something else.
Use the new logfile API
Check lock for error
Lock from the start of the file.