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;
* 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);
}
+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.