From: Wouter Wijngaards Date: Thu, 2 Oct 2008 08:47:21 +0000 (+0000) Subject: fixup pidfile unlink. X-Git-Tag: release-1.1.0~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74909b66b42cb901d24aac888835a7f3b9586eeb;p=thirdparty%2Funbound.git fixup pidfile unlink. git-svn-id: file:///svn/unbound/trunk@1278 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/daemon/unbound.c b/daemon/unbound.c index 1bd79cb00..6325a5eef 100644 --- a/daemon/unbound.c +++ b/daemon/unbound.c @@ -407,6 +407,17 @@ perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode, if(strncmp(*cfgfile, cfg->chrootdir, strlen(cfg->chrootdir)) == 0) (*cfgfile) += strlen(cfg->chrootdir); + + /* adjust stored pidfile for chroot */ + if(daemon->pidfile && daemon->pidfile[0] && + strncmp(daemon->pidfile, cfg->chrootdir, + strlen(cfg->chrootdir))==0) { + char* old = daemon->pidfile; + daemon->pidfile = strdup(old+strlen(cfg->chrootdir)); + free(old); + if(!daemon->pidfile) + log_err("out of memory in pidfile adjust"); + } } #else (void)cfgfile; @@ -510,16 +521,12 @@ run_daemon(char* cfgfile, int cmdline_verbose, int debug_mode) * of the chroot/workdir or we no longer have permissions */ if(daemon->pidfile) { int fd; - char* pf = daemon->pidfile; - if(cfg->chrootdir && cfg->chrootdir[0] && - strncmp(pf, cfg->chrootdir, strlen(cfg->chrootdir)==0)) - pf += strlen(cfg->chrootdir); /* truncate pidfile */ - fd = open(pf, O_WRONLY | O_TRUNC, 0644); + fd = open(daemon->pidfile, O_WRONLY | O_TRUNC, 0644); if(fd != -1) close(fd); /* delete pidfile */ - unlink(pf); + unlink(daemon->pidfile); } daemon_delete(daemon); } diff --git a/doc/Changelog b/doc/Changelog index 994eaa17e..60d9a2c94 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,6 @@ +2 October 2008: Wouter + - fixup unlink of pidfile. + 30 September 2008: Wouter - fixup SHA256 DS downgrade, no longer possible to downgrade to SHA1. - tests for sha256 support and downgrade resistance.