2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

further changes for

1848.   [bug]           Improve SMF integration. [RT #13238]
This commit is contained in:
Mark Andrews
2005-04-29 00:36:16 +00:00
parent 69fe9aaafd
commit 2e740e169d
4 changed files with 29 additions and 42 deletions

View File

@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: control.c,v 1.25 2005/04/27 04:55:49 sra Exp $ */ /* $Id: control.c,v 1.26 2005/04/29 00:36:15 marka Exp $ */
/*! \file */ /*! \file */
@@ -64,7 +64,7 @@ ns_control_docommand(isccc_sexpr_t *message, isc_buffer_t *text) {
char *command; char *command;
isc_result_t result; isc_result_t result;
#ifdef HAVE_LIBSCF #ifdef HAVE_LIBSCF
char *instance = NULL; ns_smf_want_disable = 0;
#endif #endif
data = isccc_alist_lookup(message, "_data"); data = isccc_alist_lookup(message, "_data");
@@ -114,17 +114,8 @@ ns_control_docommand(isccc_sexpr_t *message, isc_buffer_t *text) {
* If we are managed by smf(5) but not in chroot, * If we are managed by smf(5) but not in chroot,
* try to disable ourselves the smf way. * try to disable ourselves the smf way.
*/ */
if (ns_smf_got_instance == 1 && ns_smf_chroot == 0) { if (ns_smf_got_instance == 1 && ns_smf_chroot == 0)
result = ns_smf_get_instance(&instance, 1, ns_g_mctx); ns_smf_want_disable = 1;
if (result == ISC_R_SUCCESS && instance != NULL) {
ns_server_flushonshutdown(ns_g_server,
ISC_FALSE);
result = ns_smf_disable(instance);
}
if (instance != NULL)
isc_mem_free(ns_g_mctx, instance);
return (result);
}
/* /*
* If ns_smf_got_instance = 0, ns_smf_chroot * If ns_smf_got_instance = 0, ns_smf_chroot
* is not relevant and we fall through to * is not relevant and we fall through to
@@ -141,17 +132,8 @@ ns_control_docommand(isccc_sexpr_t *message, isc_buffer_t *text) {
result = ns_smf_add_message(text); result = ns_smf_add_message(text);
return (result); return (result);
} }
if (ns_smf_got_instance == 1 && ns_smf_chroot == 0) { if (ns_smf_got_instance == 1 && ns_smf_chroot == 0)
result = ns_smf_get_instance(&instance, 1, ns_g_mctx); ns_smf_want_disable = 1;
if (result == ISC_R_SUCCESS && instance != NULL) {
ns_server_flushonshutdown(ns_g_server,
ISC_TRUE);
result = ns_smf_disable(instance);
}
if (instance != NULL)
isc_mem_free(ns_g_mctx, instance);
return (result);
}
#endif #endif
ns_server_flushonshutdown(ns_g_server, ISC_TRUE); ns_server_flushonshutdown(ns_g_server, ISC_TRUE);
ns_os_shutdownmsg(command, text); ns_os_shutdownmsg(command, text);

View File

@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: ns_smf_globals.h,v 1.3 2005/04/07 03:49:58 marka Exp $ */ /* $Id: ns_smf_globals.h,v 1.4 2005/04/29 00:36:16 marka Exp $ */
#ifndef NS_SMF_GLOBALS_H #ifndef NS_SMF_GLOBALS_H
#define NS_SMF_GLOBALS_H 1 #define NS_SMF_GLOBALS_H 1
@@ -33,10 +33,10 @@
EXTERN unsigned int ns_smf_got_instance INIT(0); EXTERN unsigned int ns_smf_got_instance INIT(0);
EXTERN unsigned int ns_smf_chroot INIT(0); EXTERN unsigned int ns_smf_chroot INIT(0);
EXTERN unsigned int ns_smf_want_disable INIT(0);
isc_result_t ns_smf_add_message(isc_buffer_t *text); isc_result_t ns_smf_add_message(isc_buffer_t *text);
isc_result_t ns_smf_get_instance(char **name, int debug, isc_mem_t *mctx); isc_result_t ns_smf_get_instance(char **name, int debug, isc_mem_t *mctx);
isc_result_t ns_smf_disable(const char *name);
#undef EXTERN #undef EXTERN
#undef INIT #undef INIT

View File

@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: main.c,v 1.145 2005/04/27 04:55:53 sra Exp $ */ /* $Id: main.c,v 1.146 2005/04/29 00:36:15 marka Exp $ */
/*! \file */ /*! \file */
@@ -779,6 +779,9 @@ ns_smf_get_instance(char **ins_name, int debug, isc_mem_t *mctx) {
int int
main(int argc, char *argv[]) { main(int argc, char *argv[]) {
isc_result_t result; isc_result_t result;
#ifdef HAVE_LIBSCF
char *instance = NULL;
#endif
/* /*
* Record version in core image. * Record version in core image.
@@ -849,6 +852,22 @@ main(int argc, char *argv[]) {
} }
} while (result != ISC_R_SUCCESS); } while (result != ISC_R_SUCCESS);
#ifdef HAVE_LIBSCF
if (ns_smf_want_disable == 1) {
result = ns_smf_get_instance(&instance, 1, ns_g_mctx);
if (result == ISC_R_SUCCESS && instance != NULL) {
if (smf_disable_instance(instance, 0) != 0)
UNEXPECTED_ERROR(__FILE__, __LINE__,
"smf_disable_instance() ",
"failed for %s : %s",
instance,
scf_strerror(scf_error()));
}
if (instance != NULL)
isc_mem_free(ns_g_mctx, instance);
}
#endif /* HAVE_LIBSCF */
cleanup(); cleanup();
if (want_stats) { if (want_stats) {

View File

@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: server.c,v 1.441 2005/04/27 04:55:54 sra Exp $ */ /* $Id: server.c,v 1.442 2005/04/29 00:36:15 marka Exp $ */
/*! \file */ /*! \file */
@@ -4239,18 +4239,4 @@ ns_smf_add_message(isc_buffer_t *text) {
isc_buffer_add(text, n); isc_buffer_add(text, n);
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
} }
isc_result_t
ns_smf_disable(const char *ins_name) {
if (ins_name == NULL)
return (ISC_R_UNEXPECTED);
if (smf_disable_instance(ins_name, 0) != 0) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"smf_disable_instance() failed: %s",
scf_strerror(scf_error()));
return (ISC_R_FAILURE);
}
return (ISC_R_SUCCESS);
}
#endif /* HAVE_LIBSCF */ #endif /* HAVE_LIBSCF */