]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
pullup: numerous changes to support OMAPI authentication
authorAndreas Gustafsson <source@isc.org>
Tue, 11 Jul 2000 17:23:24 +0000 (17:23 +0000)
committerAndreas Gustafsson <source@isc.org>
Tue, 11 Jul 2000 17:23:24 +0000 (17:23 +0000)
16 files changed:
CHANGES
bin/named/Makefile.in
bin/named/include/named/omapi.h
bin/named/main.c
bin/named/omapi.c
bin/named/server.c
bin/rndc/Makefile.in
bin/rndc/rndc.c
bin/tests/named.conf
lib/dns/config/confctl.c
lib/dns/config/confparser.y
lib/dns/include/dns/confctl.h
lib/omapi/include/omapi/omapi.h
lib/omapi/include/omapi/private.h
lib/omapi/listener.c
lib/omapi/protocol.c

diff --git a/CHANGES b/CHANGES
index d59145f97b96c047207648807cf864df19b251cb..f820c7bff50c81c305fef5540c298a8579087ed6 100644 (file)
--- a/CHANGES
+++ b/CHANGES
                        the type and class of the CNAME dns_rdata_t,
                        causing random failures.
 
+ 320.  [func]          Multiple rndc changes: parses an rndc.conf file,
+                       uses authentication to talk to named, command
+                       line syntax changed.  This will all be described
+                       in the ARM.
+
+ 319.  [func]          The named.conf "controls" statement is now used
+                       to configure the OMAPI command channel.
+
+ 317.  [func]          Use callbacks from libomapi to determine if a
+                       new connection is valid, and if a key requested
+                       to be used with that connection is valid.
+
  316.  [bug]           Generate a warning if we detect an unexpected <eof>
                        but treat as <eol><eof>.
 
  315.  [bug]           Handle non-empty blanks lines. (RT #163)
 
+ 314.  [func]          The named.conf controls statement can now have 
+                       more than one key specified for the inet clause.
+
  313.  [bug]           When parsing resolv.conf, don't terminate on an
                        error.  Instead, parse as much as possible, but
                        still return an error if one was found.
  311.  [bug]           lwres_conf_parse failed when the first line of
                        resolv.conf was empty or a comment.
 
+ 310.  [func]          Changes to named.conf "controls" statement (inet
+                       subtype only)
+
+                         - support "keys" clause
+
+                               controls {
+                                  inet * port 1024
+                                       allow { any; } keys { "foo"; }
+                               }
+
+                         - allow "port xxx" to be left out of statement,
+                           in which case it defaults to omapi's default port
+                           of 953.
  309.  [bug]           When sending a referral, the server did not look
                        for name server addresses as glue in the zone
                        holding the NS RRset in the case where this zone
index 55ba26bb14950dfbdf04414a542515e592ea24ff..edacf70e15b3600e944a82b189f6ad94b5b2fc54 100644 (file)
@@ -13,7 +13,7 @@
 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 # SOFTWARE.
 
-# $Id: Makefile.in,v 1.49.2.1 2000/06/28 02:56:24 tale Exp $
+# $Id: Makefile.in,v 1.49.2.2 2000/07/11 17:23:01 gson Exp $
 
 srcdir =       @srcdir@
 VPATH =                @srcdir@
@@ -50,7 +50,7 @@ TARGETS =     named lwresd
 
 OBJS =         client.@O@ interfacemgr.@O@ listenlist.@O@ \
                log.@O@ logconf.@O@ main.@O@ notify.@O@ omapi.@O@ \
-               query.@O@ server.@O@ update.@O@ xfrout.@O@ \
+               omapiconf.@O@ query.@O@ server.@O@ update.@O@ xfrout.@O@ \
                lwresd.@O@ lwdclient.@O@ lwderror.@O@ lwdgabn.@O@ \
                lwdgnba.@O@ lwdnoop.@O@
 
@@ -58,7 +58,7 @@ UOBJS =               unix/os.@O@
 
 SRCS =         client.c interfacemgr.c listenlist.c \
                log.c logconf.c main.c notify.c omapi.c \
-               query.c server.c update.c xfrout.c \
+               omapiconf.c query.c server.c update.c xfrout.c \
                lwresd.c lwdclient.c lwderror.c lwdgabn.c \
                lwdgnba.c lwdnoop.c
 
index b05cfe05799119895b832e811d076e5e831dd32e..2a9ab3baa7e5aed07d87348da0020e54ee5c687e 100644 (file)
  * SOFTWARE.
  */
 
-/* $Id: omapi.h,v 1.7 2000/06/22 21:49:49 tale Exp $ */
+/* $Id: omapi.h,v 1.7.2.1 2000/07/11 17:23:07 gson Exp $ */
 
 #ifndef NAMED_OMAPI_H
 #define NAMED_OMAPI_H 1
 
+#include <dns/aclconf.h>
+#include <dns/confctx.h>
+
 #include <omapi/omapi.h>
 
 #define NS_OMAPI_PORT                  953
@@ -37,6 +40,10 @@ isc_result_t
 ns_omapi_init(void);
 
 isc_result_t
-ns_omapi_listen(omapi_object_t **managerp);
+ns_omapi_configure(isc_mem_t *mctx, dns_c_ctx_t *cctx,
+                  dns_aclconfctx_t *aclconfctx);
+
+void
+ns_omapi_shutdown(isc_boolean_t exiting);
 
 #endif /* NAMED_OMAPI_H */
index d8d2015f8dc5a0a3762bf19ba22bc217fde8ad38..b2a6472401aeb97ba540996c9ed09afc1c31e255 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: main.c,v 1.71.2.1 2000/07/10 21:35:35 gson Exp $ */
+/* $Id: main.c,v 1.71.2.2 2000/07/11 17:23:02 gson Exp $ */
 
 #include <config.h>
 
@@ -385,12 +385,12 @@ create_managers(void) {
 
 static void
 destroy_managers(void) {
-       if (!lwresd_only) {
-               if (ns_g_omapimgr != NULL)
-                       omapi_listener_shutdown(ns_g_omapimgr);
-               else
-                       omapi_lib_destroy();
-       }
+       if (!lwresd_only)
+               /*
+                * The omapi listeners need to be stopped here so that
+                * isc_taskmgr_destroy() won't block on the omapi task.
+                */
+               ns_omapi_shutdown(ISC_TRUE);
 
        isc_entropy_detach(&ns_g_entropy);
        /*
@@ -455,29 +455,20 @@ setup(void) {
        if (!lwresd_only) {
                result = ns_omapi_init();
                if (result != ISC_R_SUCCESS)
-                       ns_main_earlyfatal("omapi_lib_init() failed: %s",
+                       ns_main_earlyfatal("ns_omapi_init() failed: %s",
                                           isc_result_totext(result));
-       
-               result = ns_omapi_listen(&ns_g_omapimgr);
-               if (result == ISC_R_SUCCESS)
-                       isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
-                                     NS_LOGMODULE_MAIN, ISC_LOG_DEBUG(3),
-                                     "OMAPI started");
-               else
-                       isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
-                                     NS_LOGMODULE_MAIN, ISC_LOG_WARNING,
-                                     "OMAPI failed to start: %s",
-                                     isc_result_totext(result));
        }
 }
 
 static void
 cleanup(void) {
        destroy_managers();
+
        if (lwresd_only)
                ns_lwresd_destroy(&ns_g_lwresd);
        else
                ns_server_destroy(&ns_g_server);
+
        isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
                      ISC_LOG_NOTICE, "exiting");
        ns_log_shutdown();
@@ -543,5 +534,3 @@ main(int argc, char *argv[]) {
 
        return (0);
 }
-
-
index 09238b8a059da8aba59336163467675bf45e71a8..fbcf06bbc9fddaae7f6f66d19828080e4ef28da6 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: omapi.c,v 1.13 2000/05/08 14:32:57 tale Exp $ */
+/* $Id: omapi.c,v 1.13.2.1 2000/07/11 17:23:04 gson Exp $ */
 
 /*
  * Principal Author: DCL
@@ -42,9 +42,6 @@ typedef struct control_object {
 static control_object_t control;
 static omapi_objecttype_t *control_type;
 
-static void
-listen_done(isc_task_t *task, isc_event_t *event);
-
 #undef REGION_FMT
 /*
  * Ok, kind of gross.  Sorry.  A little.
@@ -172,74 +169,3 @@ ns_omapi_init(void) {
 
        return (result);
 }
-
-isc_result_t
-ns_omapi_listen(omapi_object_t **managerp) {
-       omapi_object_t *manager = NULL;
-       isc_result_t result;
-       isc_sockaddr_t sockaddr;
-       isc_netaddr_t netaddr;
-       dns_acl_t *acl;         /* XXXDCL make a parameter */
-       dns_aclelement_t elt;
-       struct in_addr inaddr4;
-
-       REQUIRE(managerp != NULL && *managerp == NULL);
-
-       /*
-        * Listen on localhost (127.0.0.1).
-        * XXXDCL should be configurable.
-        */
-       inaddr4.s_addr = htonl(0x7F000001);
-       isc_sockaddr_fromin(&sockaddr, &inaddr4, NS_OMAPI_PORT);
-
-       /*
-        * XXXDCL this is not right either
-        */
-       isc_netaddr_fromsockaddr(&netaddr, &sockaddr);
-       elt.type = dns_aclelementtype_ipprefix;
-       elt.negative = ISC_FALSE;
-       elt.u.ip_prefix.address = netaddr;
-       elt.u.ip_prefix.prefixlen = 32;
-
-       result = dns_acl_create(ns_g_mctx, 1, &acl);
-
-       if (result == ISC_R_SUCCESS)
-               result = dns_acl_appendelement(acl, &elt);
-
-       if (result == ISC_R_SUCCESS)
-               /*
-                * Create a generic object to be the manager for handling
-                * incoming server connections.
-                */
-               result = omapi_object_create(&manager, NULL, 0);
-
-       if (result == ISC_R_SUCCESS) {
-               /*
-                * Start listening for connections.
-                */
-               result = omapi_protocol_listen(manager, &sockaddr, acl, 1,
-                                              listen_done, ns_g_omapimgr);
-               dns_acl_detach(&acl);
-       }
-
-       if (result == ISC_R_SUCCESS)
-               *managerp = manager;
-
-       else
-               if (manager != NULL)
-                       omapi_object_dereference(&manager);
-
-       return (result);
-}
-
-static void
-listen_done(isc_task_t *task, isc_event_t *event) {
-       isc_event_free(&event);
-
-       UNUSED(task);
-
-       if (ns_g_omapimgr != NULL)
-               omapi_object_dereference(&ns_g_omapimgr);
-
-       omapi_lib_destroy();
-}
index 93e48caa333b8c822088693d1c12c28f29dfb41d..08edfe823672895424591247e1cd8eac1cf9eebf 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: server.c,v 1.200.2.1 2000/07/10 21:35:37 gson Exp $ */
+/* $Id: server.c,v 1.200.2.2 2000/07/11 17:23:06 gson Exp $ */
 
 #include <config.h>
 
@@ -54,6 +54,7 @@
 #include <named/interfacemgr.h>
 #include <named/log.h>
 #include <named/logconf.h>
+#include <named/omapi.h>
 #include <named/os.h>
 #include <named/server.h>
 
@@ -127,11 +128,13 @@ configure_view_acl(dns_c_view_t *cview,
        if (*aclp != NULL)
                dns_acl_detach(aclp);
        if (getvcacl != NULL && cview != NULL)
-               (void) (*getvcacl)(cview, &cacl);
+               (void)(*getvcacl)(cview, &cacl);
        if (cacl == NULL && getscacl != NULL)
-               (void) (*getscacl)(cctx, &cacl);
+               (void)(*getscacl)(cctx, &cacl);
        if (cacl == NULL) {
-               /* No value available.  *aclp == NULL. */               
+               /*
+                * No value available.  *aclp == NULL.
+                */
                return (ISC_R_SUCCESS);
        }
 
@@ -142,15 +145,12 @@ configure_view_acl(dns_c_view_t *cview,
        return (result);
 }
 
-
 /*
- * Convert a null-terminated string of base64 text into
- * binary, storing it in a buffer.
- * 'mctx' is only used internally.
+ * Convert a null-terminated string of base64 text into binary,
+ * storing it in a buffer.  'mctx' is only used internally.
  */
 static isc_result_t
-base64_cstring_tobuffer(isc_mem_t *mctx, char *cstr, isc_buffer_t *target)
-{
+base64_cstring_tobuffer(isc_mem_t *mctx, char *cstr, isc_buffer_t *target) {
        isc_result_t result;
        isc_buffer_t source;
        isc_lex_t *lex = NULL;
@@ -165,7 +165,7 @@ base64_cstring_tobuffer(isc_mem_t *mctx, char *cstr, isc_buffer_t *target)
        
  cleanup:
        if (isopen)
-               (void) isc_lex_close(lex);
+               (void)isc_lex_close(lex);
        if (lex != NULL)
                isc_lex_destroy(&lex);
        return (result);
@@ -268,7 +268,8 @@ configure_view_dnsseckeys(dns_c_view_t *cview,
                                        strlen(ckey->domain));
                        isc_buffer_add(&namebuf, strlen(ckey->domain));
                        CHECK(dns_name_fromtext(keyname, &namebuf,
-                                               dns_rootname, ISC_FALSE, NULL));
+                                               dns_rootname, ISC_FALSE,
+                                               NULL));
                        CHECK(dst_key_fromdns(keyname, &rrdatabuf, mctx,
                                              &dstkey));
                        
@@ -530,8 +531,8 @@ configure_view(dns_view_t *view, dns_c_ctx_t *cctx, dns_c_view_t *cview,
                 *         eliminated.
                 */
                if ((cview != NULL &&
-                    dns_c_view_getforward(cview, &forward) == ISC_R_SUCCESS) ||
-                   (dns_c_ctx_getforward(cctx, &forward) == ISC_R_SUCCESS)) {
+                    dns_c_view_getforward(cview, &forward) == ISC_R_SUCCESS)
+                   || dns_c_ctx_getforward(cctx, &forward) == ISC_R_SUCCESS) {
                        INSIST(forward == dns_c_forw_first ||
                               forward == dns_c_forw_only);
                        if (forward == dns_c_forw_only)
@@ -596,14 +597,14 @@ configure_view(dns_view_t *view, dns_c_ctx_t *cctx, dns_c_view_t *cview,
         * Configure other configurable data.
         */
        view->recursion = ISC_TRUE;
-       (void) dns_c_ctx_getrecursion(cctx, &view->recursion);
+       (void)dns_c_ctx_getrecursion(cctx, &view->recursion);
        if (cview != NULL)
-               (void) dns_c_view_getrecursion(cview, &view->recursion);
+               (void)dns_c_view_getrecursion(cview, &view->recursion);
 
        view->auth_nxdomain = ISC_FALSE; /* Was true in BIND 8 */
-       (void) dns_c_ctx_getauthnxdomain(cctx, &view->auth_nxdomain);
+       (void)dns_c_ctx_getauthnxdomain(cctx, &view->auth_nxdomain);
        if (cview != NULL)
-               (void) dns_c_view_getauthnxdomain(cview, &view->auth_nxdomain);
+               (void)dns_c_view_getauthnxdomain(cview, &view->auth_nxdomain);
 
        result = ISC_R_NOTFOUND;
        if (cview != NULL)      
@@ -1155,12 +1156,12 @@ load_configuration(const char *filename, ns_server_t *server,
         */
        {
                isc_uint32_t transfersin = 10;
-               (void) dns_c_ctx_gettransfersin(cctx, &transfersin);
+               (void)dns_c_ctx_gettransfersin(cctx, &transfersin);
                dns_zonemgr_settransfersin(server->zonemgr, transfersin);
        }
        {
                isc_uint32_t transfersperns = 2;
-               (void) dns_c_ctx_gettransfersperns(cctx, &transfersperns);
+               (void)dns_c_ctx_gettransfersperns(cctx, &transfersperns);
                dns_zonemgr_settransfersperns(server->zonemgr, transfersperns);
        }
 
@@ -1182,7 +1183,7 @@ load_configuration(const char *filename, ns_server_t *server,
                dns_c_lstnlist_t *clistenon = NULL;
                ns_listenlist_t *listenon = NULL;
 
-               (void) dns_c_ctx_getlistenlist(cctx, &clistenon);
+               (void)dns_c_ctx_getlistenlist(cctx, &clistenon);
                if (clistenon != NULL) {
                        result = ns_listenlist_fromconfig(clistenon,
                                                          cctx,
@@ -1190,7 +1191,9 @@ load_configuration(const char *filename, ns_server_t *server,
                                                          ns_g_mctx,
                                                          &listenon);
                } else {
-                       /* Not specified, use default. */
+                       /*
+                        * Not specified, use default.
+                        */
                        CHECK(ns_listenlist_default(ns_g_mctx, listen_port,
                                                    ISC_TRUE, &listenon));
                }
@@ -1204,7 +1207,7 @@ load_configuration(const char *filename, ns_server_t *server,
                dns_c_lstnlist_t *clistenon = NULL;
                ns_listenlist_t *listenon = NULL;
 
-               (void) dns_c_ctx_getv6listenlist(cctx, &clistenon);
+               (void)dns_c_ctx_getv6listenlist(cctx, &clistenon);
                if (clistenon != NULL) {
                        result = ns_listenlist_fromconfig(clistenon,
                                                          cctx,
@@ -1212,7 +1215,9 @@ load_configuration(const char *filename, ns_server_t *server,
                                                          ns_g_mctx,
                                                          &listenon);
                } else {
-                       /* Not specified, use default. */
+                       /*
+                        * Not specified, use default.
+                        */
                        CHECK(ns_listenlist_default(ns_g_mctx, listen_port,
                                                    ISC_FALSE, &listenon));
                }
@@ -1233,7 +1238,7 @@ load_configuration(const char *filename, ns_server_t *server,
         * as specified by the "interface-interval" option.
         */
        interface_interval = 3600; /* Default is 1 hour. */
-       (void) dns_c_ctx_getinterfaceinterval(cctx, &interface_interval);
+       (void)dns_c_ctx_getinterfaceinterval(cctx, &interface_interval);
        if (interface_interval == 0) {
                isc_timer_reset(server->interface_timer,
                                isc_timertype_inactive,
@@ -1330,6 +1335,12 @@ load_configuration(const char *filename, ns_server_t *server,
                server->tkeyctx = t;
        }
 
+       /*
+        * Bind the OMAPI port(s).
+        */
+       CHECKM(ns_omapi_configure(ns_g_mctx, cctx, &aclconfctx),
+              "binding control channel(s)");
+
        /*
         * Relinquish root privileges.
         */
@@ -1355,7 +1366,7 @@ load_configuration(const char *filename, ns_server_t *server,
                CHECKM(isc_logconfig_create(ns_g_lctx, &logc),
                       "creating new logging configuration");
 
-               (void) dns_c_ctx_getlogging(cctx, &clog);
+               (void)dns_c_ctx_getlogging(cctx, &clog);
                if (clog != NULL) {
                        CHECKM(ns_log_configure(logc, clog),
                               "configuring logging");
index 4baab893bf400e8bf5e47ec815c2f74dd3adfb83..6d9bd497dbc567a467e9a747145f53fd30efc60e 100644 (file)
@@ -13,7 +13,7 @@
 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 # SOFTWARE.
 
-# $Id: Makefile.in,v 1.7.2.1 2000/06/28 16:28:03 tale Exp $
+# $Id: Makefile.in,v 1.7.2.2 2000/07/11 17:23:09 gson Exp $
 
 srcdir =       @srcdir@
 VPATH =                @srcdir@
@@ -49,6 +49,10 @@ SRCS =               rndc.c
 
 @BIND9_MAKE_RULES@
 
+rndc.@O@ rndc.c:
+       ${LIBTOOL} ${CC} ${ALL_CFLAGS} -DVERSION=\"${VERSION}\" \
+               -DRNDC_SYSCONFDIR=\"${sysconfdir}\" -c ${srcdir}/rndc.c
+
 rndc: ${OBJS} ${DEPLIBS}
        ${LIBTOOL} ${CC} ${CFLAGS} -o $@ ${OBJS} ${LIBS}
 
index d7b2a002b1038eaf0ca357a55dd0afdee3cbccc1..b2c0a862d704d75e0f7d9e350040b61bbcf221c4 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: rndc.c,v 1.12.2.2 2000/06/28 16:13:46 tale Exp $ */
+/* $Id: rndc.c,v 1.12.2.3 2000/07/11 17:23:10 gson Exp $ */
 
 /* 
  * Principal Author: DCL
@@ -40,7 +40,8 @@
 #include <named/omapi.h>
 
 static const char *progname;
-static const char *conffile = "/etc/rndc.conf";
+static const char *conffile = RNDC_SYSCONFDIR "/rndc.conf";
+static const char *version = VERSION;
 
 static isc_boolean_t verbose;
 static isc_mem_t *mctx;
@@ -224,14 +225,10 @@ ndc_signalhandler(omapi_object_t *handle, const char *name, va_list ap) {
        return (result);
 }
 
-/*
- * XXXDCL
- * Usage: %s [-c config] [-s server] [-p port] [-m] command [command ...]\n\
- */
 static void
 usage(void) {
        fprintf(stderr, "\
-Usage: %s [-p port] [-m] server command [command ...]\n\
+Usage: %s [-c config] [-s server] [-p port] [-y key] command [command ...]\n\
 \n\
 command is one of the following for named:\n\
 \n\
@@ -245,8 +242,9 @@ command is one of the following for named:\n\
   *stop                Stop the server.\n\
   *restart     Restart the server.\n\
 \n\
-* == not yet implemented\n",
-               progname);
+* == not yet implemented\n\
+Version: %s\n",
+               progname, version);
 }
 
 #undef DO
@@ -264,14 +262,11 @@ command is one of the following for named:\n\
 int
 main(int argc, char **argv) {
        isc_boolean_t show_final_mem = ISC_FALSE;
-#ifdef notyet /* XXXDCL no authentication in 9.0.0 */
        isc_entropy_t *entropy = NULL;
-#endif
        isc_result_t result = ISC_R_SUCCESS;
        isc_socketmgr_t *socketmgr = NULL;
        isc_taskmgr_t *taskmgr = NULL;
        omapi_object_t *omapimgr = NULL;
-#ifdef notyet /* XXXDCL match documentation for 9.0; no authentication */
        dns_c_ndcctx_t *config = NULL;
        dns_c_ndcopts_t *configopts = NULL;
        dns_c_ndcserver_t *server = NULL;
@@ -279,14 +274,11 @@ main(int argc, char **argv) {
        dns_c_kdef_t *key = NULL;
        const char *keyname = NULL;
        const char *secret = NULL;
-#endif /* notyet */
        char *command;
        const char *servername = NULL;
        const char *host = NULL;
        unsigned int port = NS_OMAPI_PORT;
-#ifdef notyet /* XXXDCL */
        unsigned int algorithm;
-#endif
        int ch;
 
        progname = strrchr(*argv, '/');
@@ -295,16 +287,16 @@ main(int argc, char **argv) {
        else
                progname = *argv;
 
-       /*
-        * XXXDCL "c:mp:s:v"
-        */
-
-       while ((ch = isc_commandline_parse(argc, argv, "mp:v")) != -1) {
+       while ((ch = isc_commandline_parse(argc, argv, "c:Mmp:s:vy:")) != -1) {
                switch (ch) {
                case 'c':
                        conffile = isc_commandline_argument;
                        break;
 
+               case 'M':
+                       isc_mem_debugging = ISC_TRUE;
+                       break;
+
                case 'm':
                        show_final_mem = ISC_TRUE;
                        break;
@@ -329,6 +321,10 @@ main(int argc, char **argv) {
                        verbose = ISC_TRUE;
                        break;
 
+               case 'y':
+                       keyname = isc_commandline_argument;
+                       break;
+
                case '?':
                        usage();
                        exit(1);
@@ -344,26 +340,19 @@ main(int argc, char **argv) {
        argc -= isc_commandline_index;
        argv += isc_commandline_index;
 
-       /*
-        * XXXDCL change to 1 after 9.0.0.
-        */
-       if (argc < 2) {
+       if (argc < 1) {
                usage();
                exit(1);
        }
 
-       servername = *argv;
-       argc--;
-
        DO("create memory context", isc_mem_create(0, 0, &mctx));
        DO("create socket manager", isc_socketmgr_create(mctx, &socketmgr));
        DO("create task manager", isc_taskmgr_create(mctx, 1, 0, &taskmgr));
 
-#ifdef notyet /* XXXDCL match documentation for 9.0; no authentication */
        DO("create entropy pool", isc_entropy_create(mctx, &entropy));
        /* XXXDCL probably should use ISC_ENTROPY_GOOD.  talk with graff. */
        DO("initialize digital signatures",
-          dst_lib_init(mctx, entropy, ISC_ENTROPY_BLOCKING));
+          dst_lib_init(mctx, entropy, NULL));
 
        DO(conffile, dns_c_ndcparseconf(conffile, mctx, &config));
 
@@ -380,7 +369,12 @@ main(int argc, char **argv) {
                exit (1);
        }
 
-       if (server != NULL)
+       /*
+        * Look for the name of the key to use.
+        */
+       if (keyname != NULL)
+               ;               /* Was set on command line, do nothing. */
+       else if (server != NULL)
                DO("get key for server", dns_c_ndcserver_getkey(server,
                                                                &keyname));
        else if (configopts != NULL)
@@ -392,6 +386,9 @@ main(int argc, char **argv) {
                exit(1);
        }
 
+       /*
+        * Get the key's definition.
+        */
        DO("get config key list", dns_c_ndcctx_getkeys(config, &keys));
        DO("get key definition", dns_c_kdeflist_find(keys, keyname, &key));
 
@@ -410,7 +407,6 @@ main(int argc, char **argv) {
 
        if (server != NULL)
                (void)dns_c_ndcserver_gethost(server, &host);
-#endif /* notyet */
 
        if (host == NULL)
                host = servername;
@@ -435,27 +431,23 @@ main(int argc, char **argv) {
        ndc_g_ndc.refcnt = 1;
        ndc_g_ndc.type = ndc_type;
 
-#ifdef notyet /* XXXDCL match documentation for 9.0; no authentication */
        DO("register local authenticator",
           omapi_auth_register(keyname, secret, algorithm));
-#endif /* notyet */
 
        DO("create protocol manager", omapi_object_create(&omapimgr, NULL, 0));
 
        DO("connect", omapi_protocol_connect(omapimgr, host, (in_port_t)port,
                                             NULL));
 
-#ifdef notyet /* XXXDCL match documentation for 9.0; no authentication */
        DO("send remote authenticator",
           omapi_auth_use(omapimgr, keyname, algorithm));
-#endif /* notyet */
 
        /*
         * Preload the waitresult as successful.
         */
        ndc_g_ndc.waitresult = ISC_R_SUCCESS;
 
-       while ((command = *++argv) != NULL &&
+       while ((command = *argv++) != NULL &&
               result == ISC_R_SUCCESS &&
               ndc_g_ndc.waitresult == ISC_R_SUCCESS) {
 
@@ -504,8 +496,8 @@ main(int argc, char **argv) {
                                isc_result_totext(ndc_g_ndc.waitresult));
 
                else
-                       fprintf(stdout, "%s: %s command successful\n",
-                               progname, command);
+                       printf("%s: %s command successful\n",
+                              progname, command);
        }
 
        notify("command loop done");
@@ -524,13 +516,12 @@ main(int argc, char **argv) {
                omapi_object_dereference(&omapimgr);
        }
 
-       omapi_lib_destroy();
+       dns_c_ndcctx_destroy(&config);
 
+       omapi_lib_destroy();
 
-#ifdef notyet /* XXXDCL no authentication in 9.0.0. */
        dst_lib_destroy();
        isc_entropy_detach(&entropy);
-#endif /* notyet */
 
        isc_socketmgr_destroy(&socketmgr);
        isc_taskmgr_destroy(&taskmgr);
index 8b0424b9cb73ba7f0483f9e17e9c642b5b6c1517..6e885e62322cf9f15e6ec88686222f79c02406ff 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: named.conf,v 1.38 2000/06/22 21:50:34 tale Exp $ */
+/* $Id: named.conf,v 1.38.2.1 2000/07/11 17:23:12 gson Exp $ */
 
 /*
  * This is a worthless, nonrunnable example of a named.conf file that has
@@ -199,6 +199,8 @@ options {
  */
 controls {
        inet * port 52 allow { any; };                  // a bad idea
+       inet 10.0.0.1 allow { any; };                   // a bad idea
+       inet 10.0.0.2 allow { none; } keys "foo";       // a bad idea
        unix "/var/run/ndc" perm 0600 owner 0 group 0;  // the default
 };
 
index 8d66cd0f53047782e3a2a30fae7eb6f77ac1b781..8ac08edc372d771722eeadddc0ca693c5f658144 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: confctl.c,v 1.20 2000/05/13 19:44:53 tale Exp $ */
+/* $Id: confctl.c,v 1.20.2.1 2000/07/11 17:23:14 gson Exp $ */
 
 #include <config.h>
 
@@ -58,7 +58,8 @@ dns_c_ctrllist_print(FILE *fp, int indent, dns_c_ctrllist_t *cl) {
        REQUIRE(DNS_C_CONFCTLLIST_VALID(cl));
        
        fprintf(fp, "controls {\n");
-       ctl = ISC_LIST_HEAD(cl->elements);
+
+       ctl = dns_c_ctrllist_head(cl);
        if (ctl == NULL) {
                dns_c_printtabs(fp, indent + 1);
                fprintf(fp,"/* empty list */\n");
@@ -66,9 +67,10 @@ dns_c_ctrllist_print(FILE *fp, int indent, dns_c_ctrllist_t *cl) {
                while (ctl != NULL) {
                        dns_c_printtabs(fp, indent + 1);
                        dns_c_ctrl_print(fp, indent + 1, ctl);
-                       ctl = ISC_LIST_NEXT(ctl, next);
+                       ctl = dns_c_ctrl_next(ctl);
                }
        }
+               
        fprintf(fp, "};\n");
 }
 
@@ -103,7 +105,8 @@ dns_c_ctrllist_delete(dns_c_ctrllist_t **list) {
 isc_result_t
 dns_c_ctrlinet_new(isc_mem_t *mem, dns_c_ctrl_t **control,
                   isc_sockaddr_t addr, in_port_t port,
-                  dns_c_ipmatchlist_t *iml, isc_boolean_t copy)
+                  dns_c_ipmatchlist_t *iml, dns_c_kidlist_t *keylist,
+                  isc_boolean_t copy)
 {
        dns_c_ctrl_t  *ctrl;
        isc_result_t    res;
@@ -112,15 +115,15 @@ dns_c_ctrlinet_new(isc_mem_t *mem, dns_c_ctrl_t **control,
        REQUIRE(control != NULL);
 
        ctrl = isc_mem_get(mem, sizeof *ctrl);
-       if (ctrl == NULL) {
+       if (ctrl == NULL)
                return (ISC_R_NOMEMORY);
-       }
 
        ctrl->magic = DNS_C_CONFCTL_MAGIC;
        ctrl->mem = mem;
        ctrl->control_type = dns_c_inet_control;
+       isc_sockaddr_setport(&addr, port);
        ctrl->u.inet_v.addr = addr;
-       ctrl->u.inet_v.port = port;
+       ctrl->keyidlist = keylist;
 
        if (copy) {
                res = dns_c_ipmatchlist_copy(mem,
@@ -165,6 +168,8 @@ dns_c_ctrlunix_new(isc_mem_t *mem, dns_c_ctrl_t **control,
        ctrl->u.unix_v.perm = perm;
        ctrl->u.unix_v.owner = uid;
        ctrl->u.unix_v.group = gid;
+
+       ctrl->keyidlist = NULL;
        
        *control = ctrl;
 
@@ -193,6 +198,7 @@ dns_c_ctrl_delete(dns_c_ctrl_t **control) {
                                                       u.inet_v.matchlist);
                else
                        res = ISC_R_SUCCESS;
+
                break;
 
        case dns_c_unix_control:
@@ -201,6 +207,10 @@ dns_c_ctrl_delete(dns_c_ctrl_t **control) {
                break;
        }
 
+       if (ctrl->keyidlist != NULL) {
+               dns_c_kidlist_delete(&ctrl->keyidlist);
+       }
+
        ctrl->magic = 0;
        
        isc_mem_put(mem, ctrl, sizeof *ctrl);
@@ -220,7 +230,7 @@ dns_c_ctrl_print(FILE *fp, int indent, dns_c_ctrl_t *ctl) {
        (void) indent;
        
        if (ctl->control_type == dns_c_inet_control) {
-               port = ctl->u.inet_v.port;
+               port = isc_sockaddr_getport(&ctl->u.inet_v.addr);
                iml = ctl->u.inet_v.matchlist;
                
                fprintf(fp, "inet ");
@@ -235,6 +245,12 @@ dns_c_ctrl_print(FILE *fp, int indent, dns_c_ctrl_t *ctl) {
                dns_c_printtabs(fp, indent + 1);
                fprintf(fp, "allow ");
                dns_c_ipmatchlist_print(fp, indent + 2, iml);
+
+               if (ctl->keyidlist != NULL) {
+                       fprintf(fp, "\n");
+                       dns_c_kidlist_print(fp, indent + 1, ctl->keyidlist);
+               }
+
                fprintf(fp, ";\n");
        } else {
                /* The "#" means force a leading zero */
@@ -247,3 +263,22 @@ dns_c_ctrl_print(FILE *fp, int indent, dns_c_ctrl_t *ctl) {
 }
 
 
+
+dns_c_ctrl_t *
+dns_c_ctrllist_head (dns_c_ctrllist_t *list)
+{
+       REQUIRE(DNS_C_CONFCTLLIST_VALID(list));
+
+       return(ISC_LIST_HEAD(list->elements));
+}
+
+       
+dns_c_ctrl_t *
+dns_c_ctrl_next(dns_c_ctrl_t *ctl)
+{
+       REQUIRE(DNS_C_CONFCTL_VALID(ctl));
+
+       return (ISC_LIST_NEXT(ctl, next));
+}
+               
+       
index e4ff106ad1963fe1abfb0464447350c401c51182..16e6fc0ca2f3dab1a39a7015d1cddaf799bdfaf3 100644 (file)
@@ -16,7 +16,7 @@
  * SOFTWARE.
  */
 
-/* $Id: confparser.y,v 1.99 2000/06/21 22:44:19 tale Exp $ */
+/* $Id: confparser.y,v 1.99.2.1 2000/07/11 17:23:15 gson Exp $ */
 
 #include <config.h>
 
@@ -92,6 +92,14 @@ static isc_symtab_t         *keywords;
 static dns_c_cbks_t           *callbacks;
 static isc_lexspecials_t       specials;
 
+
+/*
+ * XXXJAB The #define for the default OMAPI port is not available
+ * to us, so we make our own.
+ */
+#define OMAPI_DEFAULT_PORT 953
 #define CONF_MAX_IDENT 1024
 
 /* This should be sufficient to permit multiple parsers and lexers if needed */
@@ -420,6 +428,7 @@ static isc_boolean_t        int_too_big(isc_uint32_t base, isc_uint32_t mult);
 %type <port_int>       maybe_port
 %type <port_int>       maybe_wild_port
 %type <port_int>       maybe_zero_port
+%type <port_int>       control_port
 %type <rdatatype>      rdatatype
 %type <rdatatypelist>  rdatatype_list
 %type <rrclass>                class_name
@@ -434,6 +443,7 @@ static isc_boolean_t        int_too_big(isc_uint32_t base, isc_uint32_t mult);
 %type <text>           channel_name
 %type <text>           domain_name
 %type <text>           key_value
+%type <text>           control_key
 %type <text>           ordering_name
 %type <text>           secret
 %type <tformat>                transfer_format
@@ -1480,13 +1490,18 @@ controls: control L_EOS
        ;
 
 control: /* Empty */
-       | L_INET maybe_wild_addr L_PORT in_port
-         L_ALLOW L_LBRACE address_match_list L_RBRACE
+       | L_INET maybe_wild_addr control_port
+         L_ALLOW L_LBRACE address_match_list L_RBRACE control_key
        {
                dns_c_ctrl_t *control;
 
                tmpres = dns_c_ctrlinet_new(currcfg->mem, &control,
-                                           $2, $4, $7, ISC_FALSE);
+                                           $2, $3, $6, $8, ISC_FALSE);
+
+               if ($8 != NULL) {
+                       isc_mem_free(memctx, $8);
+               }
+               
                if (tmpres != ISC_R_SUCCESS) {
                        parser_error(ISC_FALSE,
                                     "failed to build inet control structure");
@@ -1513,6 +1528,28 @@ control: /* Empty */
        }
        ;
 
+
+control_key: /* nothing */
+       {
+               $$ = NULL;
+       }
+       | L_KEYS key_value
+       {
+               $$ = $2;
+       };
+
+               
+                       
+control_port: /* nothing */
+       {
+               $$ = OMAPI_DEFAULT_PORT;
+       }
+       | L_PORT in_port
+       {
+               $$ = $2;
+       };
+
+
 rrset_ordering_list: rrset_ordering_element L_EOS
        | rrset_ordering_list rrset_ordering_element L_EOS
        ;
index 9474225abb434ba7b9ed23a7fe514eceefa202d7..77890ca357f468b62d2fdea0a5e08e0b919e8d0a 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: confctl.h,v 1.15 2000/06/22 21:55:19 tale Exp $ */
+/* $Id: confctl.h,v 1.15.2.1 2000/07/11 17:23:18 gson Exp $ */
 
 #ifndef DNS_CONFCTL_H
 #define DNS_CONFCTL_H 1
@@ -61,6 +61,7 @@
 #include <isc/magic.h>
 
 #include <dns/confip.h>
+#include <dns/confkeys.h>
 
 #define DNS_C_CONFCTL_MAGIC    0x4363746cU
 #define DNS_C_CONFCTLLIST_MAGIC        0x4354424cU
@@ -85,7 +86,6 @@ struct dns_c_ctrl {
        union {
                struct {
                        isc_sockaddr_t addr;
-                       in_port_t port;
                        dns_c_ipmatchlist_t *matchlist;
                } inet_v; /* when control_type == dns_c_inet_control  */
                struct {
@@ -95,6 +95,7 @@ struct dns_c_ctrl {
                        gid_t group;
                } unix_v; /* when control_type == dns_c_unix_control  */
        } u;
+       dns_c_kidlist_t *keyidlist;
        
        ISC_LINK(dns_c_ctrl_t) next;
 };
@@ -116,7 +117,8 @@ ISC_LANG_BEGINDECLS
 isc_result_t
 dns_c_ctrlinet_new(isc_mem_t *mem, dns_c_ctrl_t **control,
                   isc_sockaddr_t addr, in_port_t port,
-                  dns_c_ipmatchlist_t *iml, isc_boolean_t copy);
+                  dns_c_ipmatchlist_t *iml, dns_c_kidlist_t *keylist,
+                  isc_boolean_t copy);
 /*
  * Creates a new INET control object. If COPY is true then a deep copy is
  * made of IML, otherwise the value of IML is stored directly in the new
@@ -210,6 +212,11 @@ dns_c_ctrllist_print(FILE *fp, int indent, dns_c_ctrllist_t *cl);
  *
  */
 
+
+dns_c_ctrl_t *dns_c_ctrllist_head (dns_c_ctrllist_t *list);
+dns_c_ctrl_t *dns_c_ctrl_next(dns_c_ctrl_t *ctrl);
+
+
 ISC_LANG_ENDDECLS
 
 #endif /* DNS_CONFCTL_H */
index 5451bd670f89b8ea5dadfbd9933b5ae2b0ac1197..2f23fc6e6586ce10e5ca36b3391fbd5ea783709b 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: omapi.h,v 1.13 2000/06/23 21:05:21 tale Exp $ */
+/* $Id: omapi.h,v 1.13.2.1 2000/07/11 17:23:23 gson Exp $ */
 
 /*
  * Definitions for the object management API and protocol.
@@ -114,10 +114,20 @@ omapi_protocol_connect(omapi_object_t *object, const char *server,
 void
 omapi_protocol_disconnect(omapi_object_t *handle, isc_boolean_t force);
 
+/*
+ * XXXDCL The use of one void *arg for all three callbacks/taskactions is
+ * questionable.
+ */
 isc_result_t
 omapi_protocol_listen(omapi_object_t *mgr, isc_sockaddr_t *addr,
-                     dns_acl_t *acl, int backlog,
-                     isc_taskaction_t destroy_action, void *destroy_arg);
+                     isc_boolean_t ((*verify_connection)
+                                    (isc_sockaddr_t *incoming,
+                                     void *connect_arg)),
+                     isc_boolean_t ((*verify_key)
+                                    (const char *name,
+                                     unsigned int algorithm,
+                                     void *key_arg)),
+                     isc_taskaction_t destroy_action, void *arg);
 
 /*
  * Public functions defined in connection.c.
@@ -152,8 +162,14 @@ omapi_connection_puthandle(omapi_object_t *connection, omapi_object_t *object);
  */
 isc_result_t
 omapi_listener_listen(omapi_object_t *mgr, isc_sockaddr_t *addr,
-                     dns_acl_t *acl, unsigned int backlog,
-                     isc_taskaction_t destroy_action, void *destroy_arg);
+                     isc_boolean_t ((*verify_connection)
+                                    (isc_sockaddr_t *incoming,
+                                     void *connect_arg)),
+                     isc_boolean_t ((*verify_key)
+                                    (const char *name,
+                                     unsigned int algorithm,
+                                     void *key_arg)),
+                     isc_taskaction_t destroy_action, void *arg);
 
 void
 omapi_listener_shutdown(omapi_object_t *mgr);
index 5c1964328896b97bb00634370abc539a7359f7cd..e33e4f8021c36a48d994f33369ef925bb911e37b 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: private.h,v 1.21 2000/06/23 21:28:31 tale Exp $ */
+/* $Id: private.h,v 1.21.2.1 2000/07/11 17:23:24 gson Exp $ */
 
 /*****
  ***** Private master include file for the OMAPI library.
@@ -242,6 +242,15 @@ struct omapi_protocol {
        isc_region_t                    signature_in;
        isc_buffer_t                    *signature_out;
        isc_result_t                    verify_result;
+       /*
+        * A callback to find out whether a requested key is valid on
+        * the connection, and the arg the caller wants to help it decide.
+        * Only gets set on the server side.
+        */
+       isc_boolean_t    ((*verify_key)(const char *name,
+                                       unsigned int algorithm,
+                                       void *key_arg));
+       void *                          verify_key_arg;
 };
 
 /*****
index ff2f377293c90403b2879e73a718d1ee57c2633b..185f7c27739627cc1fff3c1aee3447428cf878f6 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: listener.c,v 1.26 2000/06/23 22:28:22 tale Exp $ */
+/* $Id: listener.c,v 1.26.2.1 2000/07/11 17:23:20 gson Exp $ */
 
 /*
  * Subroutines that support the generic listener object.
@@ -39,7 +39,11 @@ typedef struct omapi_listener_object {
        isc_mutex_t mutex;
        isc_task_t *task;
        isc_socket_t *socket;   /* Listening socket. */
-       dns_acl_t *acl;
+       isc_boolean_t (*verify_connection)(isc_sockaddr_t *sockaddr,
+                                          void *connect_arg);
+       isc_boolean_t (*verify_key)(const char *name, unsigned int algorithm,
+                                   void *key_arg);
+       void *callback_arg;
        /*
         * Locked by mutex.
         */
@@ -73,20 +77,18 @@ listener_accept(isc_task_t *task, isc_event_t *event) {
        isc_buffer_t *ibuffer = NULL;
        isc_buffer_t *obuffer = NULL;
        isc_task_t *connection_task = NULL;
-       isc_socket_t *socket;
+       isc_socket_t *sock;
        isc_sockaddr_t sockaddr;
-       isc_netaddr_t netaddr;
        omapi_connection_t *connection = NULL;
-       omapi_object_t *protocol = NULL;
+       omapi_protocol_t *protocol = NULL;
        omapi_listener_t *listener;
-       int match;
 
        /*
         * XXXDCL audit error handling
         */
 
        result = ((isc_socket_newconnev_t *)event)->result;
-       socket = ((isc_socket_newconnev_t *)event)->newsocket;
+       sock = ((isc_socket_newconnev_t *)event)->newsocket;
        listener = (omapi_listener_t *)event->ev_arg;
 
        /*
@@ -151,21 +153,14 @@ listener_accept(isc_task_t *task, isc_event_t *event) {
        /*
         * Is the connection from a valid host?
         */
-       result = isc_socket_getpeername(socket, &sockaddr);
-
-       if (result == ISC_R_SUCCESS) {
-               isc_netaddr_fromsockaddr(&netaddr, &sockaddr);
-
-               result = dns_acl_match(&netaddr, NULL, listener->acl,
-                                      NULL, &match, NULL);
-       }
-
-       if (result != ISC_R_SUCCESS || match <= 0) {
+       result = isc_socket_getpeername(sock, &sockaddr);
+       if (result != ISC_R_SUCCESS ||
+           !listener->verify_connection(&sockaddr, listener->callback_arg)) {
                /*
                 * Permission denied.  Close the connection.
                 * XXXDCL isc_log_write an error.
                 */
-               isc_socket_detach(&socket);
+               isc_socket_detach(&sock);
 
                return;
        }
@@ -198,7 +193,7 @@ listener_accept(isc_task_t *task, isc_event_t *event) {
 
        connection->task = connection_task;
        connection->state = omapi_connection_connected;
-       connection->socket = socket;
+       connection->socket = sock;
        connection->is_client = ISC_FALSE;
 
        ISC_LIST_INIT(connection->input_buffers);
@@ -211,11 +206,19 @@ listener_accept(isc_task_t *task, isc_event_t *event) {
         * connection.
         */
        protocol = NULL;
-       result = omapi_object_create(&protocol, omapi_type_protocol,
+       result = omapi_object_create((omapi_object_t **)&protocol,
+                                    omapi_type_protocol,
                                     sizeof(omapi_protocol_t));
        if (result != ISC_R_SUCCESS)
                goto free_connection_object;
 
+
+       /*
+        * Hand off the key verification information to the protocol object.
+        */
+       protocol->verify_key = listener->verify_key;
+       protocol->verify_key_arg = listener->callback_arg;
+
        /*
         * Tie the protocol object bidirectionally to the connection
         * object, with the connection as the outer object.
@@ -274,15 +277,21 @@ free_task:
 }
 
 isc_result_t
-omapi_listener_listen(omapi_object_t *caller, isc_sockaddr_t *addr,
-                     dns_acl_t *acl, unsigned int backlog,
-                     isc_taskaction_t destroy_action, void *destroy_arg)
+omapi_listener_listen(omapi_object_t *manager, isc_sockaddr_t *addr,
+                     isc_boolean_t ((*verify_connection)
+                                    (isc_sockaddr_t *incoming,
+                                     void *connect_arg)),
+                     isc_boolean_t ((*verify_key)
+                                    (const char *name,
+                                     unsigned int algorithm,
+                                     void *key_arg)),
+                     isc_taskaction_t destroy_action, void *arg)
 {
        isc_result_t result;
        isc_task_t *task;
        omapi_listener_t *listener;
 
-       REQUIRE(caller != NULL);
+       REQUIRE(manager != NULL);
        REQUIRE(addr != NULL && isc_sockaddr_getport(addr) != 0);
 
        task = NULL;
@@ -321,14 +330,13 @@ omapi_listener_listen(omapi_object_t *caller, isc_sockaddr_t *addr,
                /*
                 * Now tell the kernel to listen for connections.
                 */
-               result = isc_socket_listen(listener->socket, backlog);
+               result = isc_socket_listen(listener->socket, 0);
 
        if (result == ISC_R_SUCCESS) {
                /*
                 * Queue up the first accept event.  The listener object
                 * will be passed to listener_accept() when it is called.
                 */
-               dns_acl_attach(acl, &listener->acl);
                listener->listening = ISC_TRUE;
                result = isc_socket_accept(listener->socket, task,
                                           listener_accept, listener);
@@ -338,16 +346,18 @@ omapi_listener_listen(omapi_object_t *caller, isc_sockaddr_t *addr,
                /*
                 * Tie the listener object to the calling object.
                 */
-               OBJECT_REF(&caller->outer, listener);
-               OBJECT_REF(&listener->inner, caller);
+               OBJECT_REF(&manager->outer, listener);
+               OBJECT_REF(&listener->inner, manager);
 
                /*
-                * The callback is not set until here because it should
+                * The destroy action is not set until here because it should
                 * only be called if the listener was successfully set up.
                 */
                listener->destroy_action = destroy_action;
-               listener->destroy_arg = destroy_arg;
-
+               listener->destroy_arg = arg;
+               listener->verify_connection = verify_connection;
+               listener->verify_key = verify_key;
+               listener->callback_arg = arg;
 
        } else {
                /*
@@ -430,9 +440,6 @@ listener_destroy(omapi_object_t *listener) {
 
        if (l->socket != NULL)
                isc_socket_detach(&l->socket);
-
-       if (l->acl != NULL)
-               dns_acl_detach(&l->acl);
 }
 
 static isc_result_t
index 7ab436d0a57b510dd89f10267de6ae009fe90c8a..d2e7251989d8a664a571f08113e18738c2e24772 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: protocol.c,v 1.28 2000/06/23 21:36:57 tale Exp $ */
+/* $Id: protocol.c,v 1.28.2.1 2000/07/11 17:23:21 gson Exp $ */
 
 /*
  * Functions supporting the object management protocol.
@@ -197,11 +197,17 @@ send_intro(omapi_object_t *h, unsigned int ver) {
  */
 isc_result_t
 omapi_protocol_listen(omapi_object_t *manager, isc_sockaddr_t *addr,
-                     dns_acl_t *acl, int max,
-                     isc_taskaction_t destroy_action, void *destroy_arg)
+                     isc_boolean_t ((*verify_connection)
+                                    (isc_sockaddr_t *incoming,
+                                     void *connect_arg)),
+                     isc_boolean_t ((*verify_key)
+                                    (const char *name,
+                                     unsigned int algorithm,
+                                     void *key_arg)),
+                     isc_taskaction_t destroy_action, void *arg)
 {
-       return (omapi_listener_listen((omapi_object_t *)manager, addr,
-                                     acl, max, destroy_action, destroy_arg));
+       return (omapi_listener_listen(manager, addr, verify_connection,
+                                     verify_key, destroy_action, arg));
 }
 
 isc_result_t
@@ -713,6 +719,20 @@ protocol_setvalue(omapi_object_t *h, omapi_string_t *name, omapi_data_t *value)
        if (p->authname != NULL && p->algorithm != 0) {
                unsigned int sigsize;
 
+               /*
+                * Verifying the key through a callback is (currently) only
+                * done by the server.
+                * XXXDCL the client should have some way of checking whether
+                * what is being set is what it asked for.
+                */
+               if (p->verify_key != NULL &&
+                   !p->verify_key(p->authname, p->algorithm,
+                                  p->verify_key_arg))
+                       return (ISC_R_NOPERM);
+
+               if (p->key != NULL)
+                       dst_key_free(&p->key);
+
                result = auth_makekey(p->authname, p->algorithm, &p->key);
 
                if (result == ISC_R_SUCCESS)