]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
dlv anchor file and chroot.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 13 Aug 2008 14:46:33 +0000 (14:46 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 13 Aug 2008 14:46:33 +0000 (14:46 +0000)
git-svn-id: file:///svn/unbound/trunk@1188 be551aaa-1e26-0410-a405-d3ace91eadb9

smallapp/unbound-checkconf.c
validator/val_anchor.c

index 83f84aafeab4487ea391363be8becb90c0b26932..c289226daae70a785f9971c841ff06b9f190e97a 100644 (file)
@@ -276,24 +276,33 @@ basedir(const char* fname, struct config_file* cfg)
        return d;
 }
 
+/** check chroot for a file string */
+static void
+check_chroot_string(const char* desc, char** str,
+       const char* chrootdir, struct config_file* cfg)
+{
+       char* old;
+       char* s = *str;
+       if(s && s[0]) {
+               if(!is_file(fname_after_chroot(s, cfg, 1))) {
+                       fatal_exit("%s: \"%s\" does not exist in chrootdir %s", 
+                               desc, s, chrootdir);
+               }
+               old = s;
+               /* put in a new full path for continued checking */
+               *str = strdup(fname_after_chroot(s, cfg, 1));
+               free(old);
+       }
+}
+
 /** check file list, every file must be inside the chroot location */
 static void
 check_chroot_filelist(const char* desc, struct config_strlist* list,
        const char* chrootdir, struct config_file* cfg)
 {
        struct config_strlist* p;
-       char* old;
        for(p=list; p; p=p->next) {
-               if(p->str && p->str[0]) {
-                       if(!is_file(fname_after_chroot(p->str, cfg, 1))) {
-                               fatal_exit("%s: \"%s\" does not exist in chrootdir %s", 
-                                       desc, p->str, chrootdir);
-                       }
-                       old = p->str;
-                       /* put in a new full path for continued checking */
-                       p->str = strdup(fname_after_chroot(p->str, cfg, 1));
-                       free(old);
-               }
+               check_chroot_string(desc, &p->str, chrootdir, cfg);
        }
 }
 
@@ -360,6 +369,8 @@ morechecks(struct config_file* cfg, char* fname)
                cfg->trust_anchor_file_list, cfg->chrootdir, cfg);
        check_chroot_filelist("trusted-keys-file", 
                cfg->trusted_keys_file_list, cfg->chrootdir, cfg);
+       check_chroot_string("dlv-anchor-file", &cfg->dlv_anchor_file, 
+               cfg->chrootdir, cfg);
        /* remove chroot setting so that modules are not stripping pathnames*/
        free(cfg->chrootdir);
        cfg->chrootdir = NULL;
index ddcdc13a8eb95dff6d2c1c8de4fe3fd095b19852..3ad3c9c7924c1302e6d6374c1d1eb549fb071a39 100644 (file)
@@ -801,8 +801,12 @@ anchors_apply_cfg(struct val_anchors* anchors, struct config_file* cfg)
                }
        }
        if(cfg->dlv_anchor_file && cfg->dlv_anchor_file[0] != 0) {
+               nm = cfg->dlv_anchor_file;
+               if(cfg->chrootdir && cfg->chrootdir[0] && strncmp(nm,
+                       cfg->chrootdir, strlen(cfg->chrootdir)) == 0)
+                       nm += strlen(cfg->chrootdir);
                if(!(anchors->dlv_anchor = anchor_read_file(anchors, parsebuf,
-                       cfg->dlv_anchor_file, 1))) {
+                       nm, 1))) {
                        log_err("error reading dlv-anchor-file: %s", 
                                cfg->dlv_anchor_file);
                        ldns_buffer_free(parsebuf);