]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
896. [bug] If a configuration file is set on named's command line
authorDavid Lawrence <source@isc.org>
Fri, 8 Jun 2001 23:52:21 +0000 (23:52 +0000)
committerDavid Lawrence <source@isc.org>
Fri, 8 Jun 2001 23:52:21 +0000 (23:52 +0000)
and it has a relative pathname, the current directory
(after any possible jailing resulting from named -t)
will be prepended to it so that reloading works
properly even when a directory option is present.

CHANGES
bin/named/main.c

diff --git a/CHANGES b/CHANGES
index 47f5b8aed54dfa1b339425fabcf8eeabe26baed3..a3c1677880c65a9478b7078e1f2aa0ebd2cb3566 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,10 @@
 
+ 896.  [bug]           If a configuration file is set on named's command line
+                       and it has a relative pathname, the current directory
+                       (after any possible jailing resulting from named -t)
+                       will be prepended to it so that reloading works
+                       properly even when a directory option is present.
+
  895.  [func]          New function, isc_dir_current(), akin to POSIX's
                        getcwd().
 
index be4c6171e88efc5cc762e288411ddb6c2904af43..ea07006c8cbe275549a4dfb4b58a0500f380c26f 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: main.c,v 1.112 2001/05/31 10:37:08 tale Exp $ */
+/* $Id: main.c,v 1.113 2001/06/08 23:52:21 tale Exp $ */
 
 #include <config.h>
 
@@ -25,6 +25,7 @@
 
 #include <isc/app.h>
 #include <isc/commandline.h>
+#include <isc/dir.h>
 #include <isc/entropy.h>
 #include <isc/file.h>
 #include <isc/os.h>
@@ -63,7 +64,8 @@
 /* #include "xxdb.h" */
 
 static isc_boolean_t   want_stats = ISC_FALSE;
-static char            program_name[256] = "named";
+static char            program_name[ISC_DIR_NAMEMAX] = "named";
+static char            absolute_conffile[ISC_DIR_PATHMAX];
 static char                    saved_command_line[512];
 
 void
@@ -356,6 +358,8 @@ parse_command_line(int argc, char *argv[]) {
                usage();
                ns_main_earlyfatal("extra command line arguments");
        }
+
+       
 }
 
 static isc_result_t
@@ -473,6 +477,28 @@ setup(void) {
        (void)isc_resource_getlimit(isc_resource_openfiles,
                                    &ns_g_initopenfiles);
 
+       /*
+        * If the named configuration filename is relative, prepend the current
+        * directory's name before possibly changing to another directory.
+        */
+       if (! isc_file_isabsolute(ns_g_conffile)) {
+               result = isc_dir_current(absolute_conffile,
+                                        sizeof(absolute_conffile), ISC_TRUE);
+               if (result != ISC_R_SUCCESS)
+                       ns_main_earlyfatal("getting current directory failed: "
+                                          "%s", isc_result_totext(result));
+
+               if (strlen(absolute_conffile) + strlen(ns_g_conffile) + 1 >
+                   sizeof(absolute_conffile))
+                       ns_main_earlyfatal("configuration filename too long: "
+                                          "%s%s", absolute_conffile,
+                                          ns_g_conffile);
+
+               strcat(absolute_conffile, ns_g_conffile);
+
+               ns_g_conffile = absolute_conffile;
+       }
+
        result = create_managers();
        if (result != ISC_R_SUCCESS)
                ns_main_earlyfatal("create_managers() failed: %s",