Fix PID file writing in Haskell daemons
Fix PID file writing in Haskell daemons

Currently, the code uses createFile, which has the effect of always
truncating the file. This is bad, as the content of the PID file is
wiped even when we wouldn't be able to lock it!

We switch to openFd (createFile is just a wrapper over that), and we
use an explicit set of flags; defaultFileFlags is already safe
(trunc=False), but I prefer to set it explicitly with our desired
flags.

Note that this bug doesn't manifest in normal usage, as daemon-util
won't try to start the daemon if already running. But if anyone or
anything does call ganeti-confd explicitly, the pid file will be
emptied and the daemon will keep trying to be restarted forever…

Signed-off-by: Iustin Pop <acf83a5274f31a43af6b914614365999469c1a31@google.com>
Reviewed-by: Guido Trotter <f62ca4d5358bdaeef0e50e57f9f7e231de63727e@google.com>

yiannist/ganeti,mbakke/ganeti,mbakke/ganeti,ganeti-github-testing/ganeti-test-1,ganeti-github-testing/ganeti-test-1,andir/ganeti,andir/ganeti,leshchevds/ganeti,mbakke/ganeti,grnet/snf-ganeti,onponomarev/ganeti,ganeti/ganeti,andir/ganeti,leshchevds/ganeti,apyrgio/ganeti,yiannist/ganeti,leshchevds/ganeti,apyrgio/snf-ganeti,yiannist/ganeti,ganeti/ganeti,apyrgio/snf-ganeti,bitemyapp/ganeti,dimara/ganeti,grnet/snf-ganeti,apyrgio/ganeti,ganeti/ganeti,onponomarev/ganeti,dimara/ganeti,bitemyapp/ganeti