CID #1198853 *sigh*
Coverity #1198850 #1198851 #1198852
Always set type correctly
Handle embedded NULs in strings for xlat.  Fixes #571
Quotations around strings look nicer
Really not a typo
Check for truncation in more places
Free cast before checking for error
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.
Hold main lock for less time

When we open a file, we grab the mutex for that file, rather than
continuing to hold the main mutex during the open() operation
Make response delay more generic.

For now, it only applies to Access-Reject packets