]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
further changes for
authorMark Andrews <marka@isc.org>
Fri, 29 Apr 2005 00:36:16 +0000 (00:36 +0000)
committerMark Andrews <marka@isc.org>
Fri, 29 Apr 2005 00:36:16 +0000 (00:36 +0000)
1848.   [bug]           Improve SMF integration. [RT #13238]

bin/named/control.c
bin/named/include/named/ns_smf_globals.h
bin/named/main.c
bin/named/server.c

index e0577f6963255c84af6b2e7a2dad63e8eb12753d..e8b055daa78401bf188b1bdb894b6c938fd115d8 100644 (file)
@@ -15,7 +15,7 @@
  * 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 */
 
@@ -64,7 +64,7 @@ ns_control_docommand(isccc_sexpr_t *message, isc_buffer_t *text) {
        char *command;
        isc_result_t result;
 #ifdef HAVE_LIBSCF
-       char *instance = NULL;
+       ns_smf_want_disable = 0;
 #endif
 
        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,
                 * 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
@@ -141,17 +132,8 @@ ns_control_docommand(isccc_sexpr_t *message, isc_buffer_t *text) {
                        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);
index 663375864cae958c054bc75c8530d6d7c58da376..23fdb99b4b705a8225d51f5e3b91bab974b90861 100644 (file)
@@ -14,7 +14,7 @@
  * 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
index be961e13c20b25d59adaf679307e71f241d02683..f9a05128c9778b337af7b9f13582a85aa4395012 100644 (file)
@@ -15,7 +15,7 @@
  * 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 */
 
@@ -779,6 +779,9 @@ ns_smf_get_instance(char **ins_name, int debug, isc_mem_t *mctx) {
 int
 main(int argc, char *argv[]) {
        isc_result_t result;
+#ifdef HAVE_LIBSCF
+       char *instance = NULL;
+#endif
 
        /*
         * Record version in core image.
@@ -849,6 +852,22 @@ main(int argc, char *argv[]) {
                }
        } 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) {
index 230f714eb6486835d2b9e2e43eb0db90a4e22141..947457b3a73a9ad3b2bf283d4326be41009047ec 100644 (file)
@@ -15,7 +15,7 @@
  * 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 */
 
@@ -4239,18 +4239,4 @@ ns_smf_add_message(isc_buffer_t *text) {
        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 */