* STICHTING NLNET BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE * USE OR PERFORMANCE OF THIS SOFTWARE. * The development of Dynamically Loadable Zones (DLZ) for Bind 9 was * conceived and contributed by Rob Butler. * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all * THE SOFTWARE IS PROVIDED "AS IS" AND ROB BUTLER * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL * ROB BUTLER BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE * USE OR PERFORMANCE OF THIS SOFTWARE. * Copyright (C) 1999-2001, 2013, 2016 Internet Systems Consortium, Inc. ("ISC") * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * This provides the externally loadable filesystem DLZ module, without /* Helper functions from the dlz_dlopen driver */ /* check that only allowed characters are in the domain name */ for (i = 0; i <
len; i++) {
/* '.' is allowed, but has special requirements */ /* '.' is not allowed as first char */ /* '..', two dots together is not allowed. */ else if (
input[i-
1] ==
'.')
/* '.' is not allowed as last char */ /* only 1 dot in ok location, continue at next char */ /* '-' is allowed, continue at next char */ /* 0-9 is allowed, continue at next char */ /* A-Z uppercase is allowed, continue at next char */ /* a-z lowercase is allowed, continue at next char */ * colon needs to be allowed for IPV6 client * addresses. Not dangerous in domain names, as not a * '@' needs to be allowed for in zone data. Not * dangerous in domain names, as not a special char. * if we reach this point we have encountered a * don't forget is_safe guarantees '.' will NOT be the /* handle the "first" label properly */ * Checks to make sure zone and host are safe. If safe, then * hashes zone and host strings to build a path. If zone / host * are not safe an error is returned. /* special case for root zone */ /* if the requested zone is "unsafe", return error */ /* if host was passed, verify that it is safe */ /* if client was passed, verify that it is safe */ /* Determine how much memory the split up string will require */ * even though datadir and xfrdir will never be in the same * string we only waste a few bytes by allocating for both, * and then we are safe from buffer overruns. /* if we are splitting names, we will need extra space. */ /* write error message */ "Filesystem driver unable to " "allocate memory in create_path().");
* start out with base directory. /* add zone name - parsed properly */ * When neither client or host is passed we are building a * path to see if a zone is supported. We require that a zone * path have the "data dir" directory contained within it so * that we know this zone is really supported. Otherwise, * this zone may not really be supported because we are * supporting a delagated sub zone. * 0. the base dir is "/base-dir/" and the data dir is * "/.datadir" We want to see if we are authoritative for * authoritative for the domain "domain.com". However we are /* if client is passed append xfr dir, otherwise append data dir */ /* if host not null, add it. */ /* return the path we built. */ /* free tmpPath memory */ tmp[0] =
'\0';
/* set 1st byte to '\0' so strcpy works right. */ /* copy base directory name to tmp. */ /* dir->dirname will always have '*' as the last char. */ /* if dir_list != NULL, were are performing a zone xfr */ /* if splitcnt == 0, determine host from path. */ /* handle filesystem's special wildcard "-" */ * not special wildcard -- normal name /* set tmp again for use later */ * if splitcnt != 0 determine host from * ".host" directory entry * handle filesystem's special /* reset dir list for use later */ "Filesystem driver Dir name:" " '%s' Dir entry: '%s'\n",
/* skip any entries starting with "." */ * get rid of '*', set to NULL. Effectively trims * string from previous loop to base directory only * while still leaving memory for concat to be /* add name to base directory name. */ /* make sure we can stat entry */ /* if entry is a directory */ * if dir list is NOT NULL, add dir to * if entry is a file be sure we do * not add entry to DNS results if we * are performing a zone xfr and we * could not find a host entry. }
else /* if we cannot stat entry, skip it. */ "%s could not be parsed properly",
tmp);
/* replace separator char with NULL to split string */ /* start string after NULL of previous string */ "%s could not be parsed properly",
tmp);
/* replace separator char with NULL to split string */ /* start string after NULL of previous string */ /* replace all cd->separator chars with a space. */ for (i=0; i <
len; i++) {
/* convert text to int, make sure it worked right */ "ttl must be a postive number");
/* pass data back to Bind */ /* if error, return error right away */ }
/* end of while loop */ /* allocate memory for list */ /* remove path separator at end of path so stat works properly */ /* initialize and open directory */ /* if directory open failed, return error. */ "Unable to open %s directory to read entries.",
/* process the directory */ /* close the directory */ /* get first dir entry from list. */ /* if directory open failed, return error. */ "directory to read entries.",
basepath);
/* process the directory */ /* close the directory */ /* clean up entries from list. */ "Filesystem driver Findzone() Checking for path: '%s'\n",
path);
* handle filesystem's special wildcard "-" /* remove path separator at end of path so stat works properly */ "Filesystem driver lookup() Checking for path: '%s'\n",
path);
/* initialize and open directory */ /* if directory open failed, return error. */ "Unable to open %s directory to read entries.",
path);
/* process any records in the directory */ /* close the directory */ /* allocate memory for our config data and helper functions */ /* Fill in the helper functions */ /* we require 5 command line args. */ "Filesystem driver requires " "Filesystem driver can only " "accept a single character for separator.");
/* verify base dir ends with '/' or '\' */ "Base dir parameter for filesystem driver " /* determine and save path separator for later */ /* get and store our base directory */ /* get and store our data sub-dir */ /* get and store our zone xfr sub-dir */ /* get and store our directory split count */ "Directory split count must be zero (0) " /* get and store our separator character */ /* pass back config data */ /* handle no memory error */ /* write error message */ "filesystem_dynamic: Filesystem driver unable to " "allocate memory for config data.");
/* if we allocated a config data object clean it up */ * free memory for each section of config data that was /* free config data memory */ * Return the version of the API * Register a helper function from the bind9 dlz_dlopen driver