Plug possible memory leak.

This is a rarely executed path, but it's still no excuse for it to leak.
There's no reason to restart the loop.

If we've been reading from fd, cstdin.revents will be unset anyway, so we won't
waste time going down that rathole; however, it's possible that cstderr has
stuff for us to read, so it's worth trying that rather than immediately polling.
If nothing else, the "continue" was just plain confusing, as well as
unnecessary.
Set hardening (relro) flags.
Remove undefined variable.

Spotted by Olivier Girondel.
Unbreak message header unfolding.

This was quite broken before, and probably only escaped notice because few
people write regex code against headers that are folded over multiple lines.
Fix a memory leak (free lock_path in lock_exit()).
Close file descriptor.
Missing calls to fclose().
Use the 'mandir' variable.
Use the 'mandir' variable.
Remove unneeded import.
Apparently this makes an obscure way of building things on Debian work.

I don't know why.