* 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 */
char *command;
isc_result_t result;
#ifdef HAVE_LIBSCF
- char *instance = NULL;
+ ns_smf_want_disable = 0;
#endif
data = isccc_alist_lookup(message, "_data");
* If we are managed by smf(5) but not in chroot,
* try to disable ourselves the smf way.
*/
- if (ns_smf_got_instance == 1 && ns_smf_chroot == 0) {
- result = ns_smf_get_instance(&instance, 1, ns_g_mctx);
- 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 == 1 && ns_smf_chroot == 0)
+ ns_smf_want_disable = 1;
/*
* If ns_smf_got_instance = 0, ns_smf_chroot
* is not relevant and we fall through to
result = ns_smf_add_message(text);
return (result);
}
- if (ns_smf_got_instance == 1 && ns_smf_chroot == 0) {
- result = ns_smf_get_instance(&instance, 1, ns_g_mctx);
- 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);
- }
+ if (ns_smf_got_instance == 1 && ns_smf_chroot == 0)
+ ns_smf_want_disable = 1;
#endif
ns_server_flushonshutdown(ns_g_server, ISC_TRUE);
ns_os_shutdownmsg(command, text);
* 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
#define NS_SMF_GLOBALS_H 1
EXTERN unsigned int ns_smf_got_instance 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_get_instance(char **name, int debug, isc_mem_t *mctx);
-isc_result_t ns_smf_disable(const char *name);
#undef EXTERN
#undef INIT
* 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 */
int
main(int argc, char *argv[]) {
isc_result_t result;
+#ifdef HAVE_LIBSCF
+ char *instance = NULL;
+#endif
/*
* Record version in core image.
}
} 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();
if (want_stats) {
* 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 */
isc_buffer_add(text, n);
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 */