From: Wouter Wijngaards Date: Mon, 13 Jun 2016 13:33:51 +0000 (+0000) Subject: - Fix directory: fix for unbound-checkconf, it restores cwd. X-Git-Tag: release-1.5.10~82 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2fffe65332217470a3958a60a1332c0172a7ed78;p=thirdparty%2Funbound.git - Fix directory: fix for unbound-checkconf, it restores cwd. git-svn-id: file:///svn/unbound/trunk@3783 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/doc/Changelog b/doc/Changelog index 03ccb4f9f..16cc87c75 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -6,6 +6,7 @@ 13 June 2016: Wouter - Fix #778: unbound 1.5.9: -h segfault (null deref). + - Fix directory: fix for unbound-checkconf, it restores cwd. 10 June 2016: Wouter - And delete service.conf.shipped on uninstall. diff --git a/smallapp/unbound-checkconf.c b/smallapp/unbound-checkconf.c index b1c70f507..0a71a6554 100644 --- a/smallapp/unbound-checkconf.c +++ b/smallapp/unbound-checkconf.c @@ -481,14 +481,22 @@ check_hints(struct config_file* cfg) static void checkconf(const char* cfgfile, const char* opt, int final) { + char oldwd[PATH_MAX]; struct config_file* cfg = config_create(); if(!cfg) fatal_exit("out of memory"); + oldwd[0] = 0; + if(!getcwd(oldwd, sizeof(oldwd))) { + log_err("cannot getcwd: %s", strerror(errno)); + oldwd[0] = 0; + } if(!config_read(cfg, cfgfile, NULL)) { /* config_read prints messages to stderr */ config_delete(cfg); exit(1); } + if(oldwd[0] && chdir(oldwd) == -1) + log_err("cannot chdir(%s): %s", oldwd, strerror(errno)); if(opt) { print_option(cfg, opt, final); config_delete(cfg);