2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-22 10:10:06 +00:00

os API cleanups; -u support; call ns_os_chroot()

This commit is contained in:
Bob Halley 2000-01-28 20:10:26 +00:00
parent bcc1d6507b
commit 7be4ced9e2

View File

@ -1,5 +1,3 @@
#include <dns/rootns.h>
/* /*
* Copyright (C) 1999 Internet Software Consortium. * Copyright (C) 1999 Internet Software Consortium.
* *
@ -25,10 +23,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h> #include <stddef.h>
/* XXX this include will need to go. It's here for _SC_OPEN_MAX */
#include <unistd.h>
#include <isc/app.h> #include <isc/app.h>
#include <isc/assertions.h> #include <isc/assertions.h>
#include <isc/error.h> #include <isc/error.h>
@ -145,7 +139,8 @@ parse_command_line(int argc, char *argv[]) {
int ch; int ch;
isc_commandline_errprint = ISC_FALSE; isc_commandline_errprint = ISC_FALSE;
while ((ch = isc_commandline_parse(argc, argv, "b:c:d:fN:p:st:x:")) != while ((ch = isc_commandline_parse(argc, argv,
"b:c:d:fN:p:st:u:x:")) !=
-1) { -1) {
switch (ch) { switch (ch) {
case 'b': case 'b':
@ -171,9 +166,12 @@ parse_command_line(int argc, char *argv[]) {
want_stats = ISC_TRUE; want_stats = ISC_TRUE;
break; break;
case 't': case 't':
/* XXXJAB should be make a copy? */ /* XXXJAB should we make a copy? */
ns_g_chrootdir = isc_commandline_argument; ns_g_chrootdir = isc_commandline_argument;
break; break;
case 'u':
ns_g_username = isc_commandline_argument;
break;
case 'x': case 'x':
/* XXXRTH temporary syntax */ /* XXXRTH temporary syntax */
ns_g_cachefile = isc_commandline_argument; ns_g_cachefile = isc_commandline_argument;
@ -240,6 +238,8 @@ static void
setup() { setup() {
isc_result_t result; isc_result_t result;
ns_os_chroot(ns_g_chrootdir);
result = ns_log_init(); result = ns_log_init();
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
ns_main_earlyfatal("ns_log_init() failed: %s", ns_main_earlyfatal("ns_log_init() failed: %s",
@ -252,12 +252,8 @@ setup() {
* because calling create_managers() will create threads, which * because calling create_managers() will create threads, which
* would be lost after fork(). * would be lost after fork().
*/ */
if (!ns_g_foreground) { if (!ns_g_foreground)
result = ns_os_daemonize(); ns_os_daemonize();
if (result != ISC_R_SUCCESS)
ns_main_earlyfatal("ns_os_daemonize() failed: %s",
isc_result_totext(result));
}
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
ISC_LOG_NOTICE, "starting BIND %s", ns_g_version); ISC_LOG_NOTICE, "starting BIND %s", ns_g_version);
@ -287,10 +283,7 @@ main(int argc, char *argv[]) {
isc_assertion_setcallback(assertion_failed); isc_assertion_setcallback(assertion_failed);
isc_error_setfatal(library_fatal_error); isc_error_setfatal(library_fatal_error);
result = ns_os_init(); ns_os_init();
if (result != ISC_R_SUCCESS)
ns_main_earlyfatal("ns_os_init() failed: %s",
isc_result_totext(result));
result = isc_app_start(); result = isc_app_start();
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)