Regain root privileges to unlink PID file at exit

This commit is contained in:
Julien BLACHE 2009-12-31 20:17:22 +01:00
parent 1ac46983b9
commit 207e85c6c0

View File

@ -599,9 +599,15 @@ main(int argc, char **argv)
daemon_fail:
if (background)
{
ret = unlink(pidfile);
ret = seteuid(0);
if (ret < 0)
DPRINTF(E_WARN, L_MAIN, "Could not unlink PID file %s: %s\n", pidfile, strerror(errno));
DPRINTF(E_LOG, L_MAIN, "seteuid() failed: %s\n", strerror(errno));
else
{
ret = unlink(pidfile);
if (ret < 0)
DPRINTF(E_LOG, L_MAIN, "Could not unlink PID file %s: %s\n", pidfile, strerror(errno));
}
}
signal_block_fail: