]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix directory: fix for unbound-checkconf, it restores cwd.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 13 Jun 2016 13:33:51 +0000 (13:33 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 13 Jun 2016 13:33:51 +0000 (13:33 +0000)
git-svn-id: file:///svn/unbound/trunk@3783 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
smallapp/unbound-checkconf.c

index 03ccb4f9f0bc94a806a6233b0312a097d255188f..16cc87c7596db5e474ad21379ad9a3f385e42aa0 100644 (file)
@@ -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.
index b1c70f50787b7c6977a0bd429a42355a05a5f7a8..0a71a65546b381845215a98e1f791959882e28fb 100644 (file)
@@ -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);