cvs updates from Wed Dec 15 17:45:22 EST 2010
[tridge/bind9.git] / bin / nsupdate / nsupdate.c
index 94603826d4bfda437061f39de2412263a64fd250..25d1a212e8759b32148f036e5a8676c0a8bb8180 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: nsupdate.c,v 1.173.66.8 2010/08/10 23:47:45 tbox Exp $ */
+/* $Id: nsupdate.c,v 1.186 2010/12/09 04:31:57 tbox Exp $ */
 
 /*! \file */
 
@@ -641,6 +641,9 @@ setup_keyfile(isc_mem_t *mctx, isc_log_t *lctx) {
 
        debug("Creating key...");
 
+       if (sig0key != NULL)
+               dst_key_free(&sig0key);
+
        /* Try reading the key from a K* pair */
        result = dst_key_fromnamedfile(keyfile, NULL,
                                       DST_TYPE_PRIVATE | DST_TYPE_KEY, mctx,
@@ -685,14 +688,14 @@ setup_keyfile(isc_mem_t *mctx, isc_log_t *lctx) {
                                                   hmacname, dstkey, ISC_FALSE,
                                                   NULL, 0, 0, mctx, NULL,
                                                   &tsigkey);
+               dst_key_free(&dstkey);
                if (result != ISC_R_SUCCESS) {
                        fprintf(stderr, "could not create key from %s: %s\n",
                                keyfile, isc_result_totext(result));
-                       dst_key_free(&dstkey);
                        return;
                }
        } else
-               sig0key = dstkey;
+               dst_key_attach(dstkey, &sig0key);
 }
 
 static void
@@ -901,9 +904,12 @@ setup_system(void) {
 
        if (keystr != NULL)
                setup_keystr();
-       else if (local_only)
-               read_sessionkey(mctx, lctx);
-       else if (keyfile != NULL)
+       else if (local_only) {
+               result = read_sessionkey(mctx, lctx);
+               if (result != ISC_R_SUCCESS)
+                       fatal("can't read key from %s: %s\n",
+                             keyfile, isc_result_totext(result));
+       } else if (keyfile != NULL)
                setup_keyfile(mctx, lctx);
 }
 
@@ -2121,7 +2127,7 @@ send_update(dns_name_t *zonename, isc_sockaddr_t *master,
 {
        isc_result_t result;
        dns_request_t *request = NULL;
-       unsigned int options = 0;
+       unsigned int options = DNS_REQUESTOPT_CASE;
 
        ddebug("send_update()");