+ 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().
* 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>
#include <isc/app.h>
#include <isc/commandline.h>
+#include <isc/dir.h>
#include <isc/entropy.h>
#include <isc/file.h>
#include <isc/os.h>
/* #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
usage();
ns_main_earlyfatal("extra command line arguments");
}
+
+
}
static isc_result_t
(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",