From 9739014da16758bace524dc25c3b370844b277ed Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Mon, 21 Apr 2008 11:34:25 +0000 Subject: [PATCH] fixup chroot and kill-HUP reread of config file. git-svn-id: file:///svn/unbound/trunk@1061 be551aaa-1e26-0410-a405-d3ace91eadb9 --- daemon/unbound.c | 8 ++++++-- doc/Changelog | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/daemon/unbound.c b/daemon/unbound.c index 492cc88e5..74b49bae2 100644 --- a/daemon/unbound.c +++ b/daemon/unbound.c @@ -284,7 +284,8 @@ detach(struct config_file* cfg) /** daemonize, drop user priviliges and chroot if needed */ static void -do_chroot(struct daemon* daemon, struct config_file* cfg, int debug_mode) +do_chroot(struct daemon* daemon, struct config_file* cfg, int debug_mode, + char** cfgfile) { uid_t uid; gid_t gid; @@ -314,6 +315,9 @@ do_chroot(struct daemon* daemon, struct config_file* cfg, int debug_mode) fatal_exit("unable to chroot to %s: %s", cfg->chrootdir, strerror(errno)); verbose(VERB_QUERY, "chroot to %s", cfg->chrootdir); + if(strncmp(*cfgfile, cfg->chrootdir, + strlen(cfg->chrootdir)) == 0) + (*cfgfile) += strlen(cfg->chrootdir); } if(cfg->username && cfg->username[0]) { if(setgid(gid) != 0) @@ -382,7 +386,7 @@ run_daemon(char* cfgfile, int cmdline_verbose, int debug_mode) if(!daemon_open_shared_ports(daemon)) fatal_exit("could not open ports"); if(!done_chroot) { - do_chroot(daemon, cfg, debug_mode); + do_chroot(daemon, cfg, debug_mode, &cfgfile); done_chroot = 1; } else log_init(cfg->logfile, cfg->use_syslog, cfg->chrootdir); /* work */ diff --git a/doc/Changelog b/doc/Changelog index baf77ead7..8d3ffef6a 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,5 +1,7 @@ 21 April 2008: Wouter - FEATURES document. + - fixup reread of config file if it was given as a full path + and chroot was used. 16 April 2008: Wouter - requirements doc, updated clean query returns. -- 2.47.2