]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
fixup pidfile unlink.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 2 Oct 2008 08:47:21 +0000 (08:47 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 2 Oct 2008 08:47:21 +0000 (08:47 +0000)
git-svn-id: file:///svn/unbound/trunk@1278 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/unbound.c
doc/Changelog

index 1bd79cb003c875e56c873f7a01f442dbf0a93b67..6325a5eefcf5e1a01480dc6eb2f1d1176aefdb1f 100644 (file)
@@ -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);
 }
index 994eaa17e9dc32cc8514267d5f4e88a2676a748e..60d9a2c94a4586d4da788c8ce9a582e97d290828 100644 (file)
@@ -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.