]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
3275. [bug] Corrected rndc -h output; the 'rndc sync -clean'
authorEvan Hunt <each@isc.org>
Fri, 3 Feb 2012 22:27:17 +0000 (22:27 +0000)
committerEvan Hunt <each@isc.org>
Fri, 3 Feb 2012 22:27:17 +0000 (22:27 +0000)
option had been missplled as '-clear'.  (To avoid
future confusion, both options now work.) [RT #27173]

CHANGES
bin/named/server.c
bin/rndc/rndc.c

diff --git a/CHANGES b/CHANGES
index 8f300f9fc0e4059165c8db77bdd1a8e7c173e08a..c81e4378fc97232bd572afd2472dc1ab82478e02 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+3275.  [bug]           Corrected rndc -h output; the 'rndc sync -clean'
+                       option had been missplled as '-clear'.  (To avoid
+                       future confusion, both options now work.) [RT #27173]
+
 3274.   [placeholder]
 
 3273.   [bug]           AAAA responses could be returned in the additional
index 7e6be95f4529d47d43abff03802caa8052206ff7..056f67af134474c325e0114bc60e8f7bc8e58c8c 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: server.c,v 1.643 2012/02/01 23:46:51 tbox Exp $ */
+/* $Id: server.c,v 1.644 2012/02/03 22:27:16 each Exp $ */
 
 /*! \file */
 
@@ -5890,13 +5890,17 @@ next_token(char **stringp, const char *delim) {
  * Find the zone specified in the control channel command 'args',
  * if any.  If a zone is specified, point '*zonep' at it, otherwise
  * set '*zonep' to NULL.
+ *
+ * If 'zonetxt' is set, the caller has already pulled a token
+ * off the command line that is to be used as the zone name.  (This
+ * is done when it's necessary to check for an optional argument
+ * before the zone name, as in "rndc sync [-clean] zone".)
  */
 static isc_result_t
-zone_from_args(ns_server_t *server, char *args, dns_zone_t **zonep,
-              const char **zonename, isc_boolean_t skip)
+zone_from_args(ns_server_t *server, char *args, const char *zonetxt,
+              dns_zone_t **zonep, const char **zonename, isc_boolean_t skip)
 {
        char *input, *ptr;
-       const char *zonetxt;
        char *classtxt;
        const char *viewtxt = NULL;
        dns_fixedname_t name;
@@ -5917,7 +5921,8 @@ zone_from_args(ns_server_t *server, char *args, dns_zone_t **zonep,
        }
 
        /* Look for the zone name. */
-       zonetxt = next_token(&input, " \t");
+       if (zonetxt == NULL)
+               zonetxt = next_token(&input, " \t");
        if (zonetxt == NULL)
                return (ISC_R_SUCCESS);
        if (zonename)
@@ -5982,7 +5987,7 @@ ns_server_retransfercommand(ns_server_t *server, char *args) {
        dns_zone_t *zone = NULL;
        dns_zonetype_t type;
 
-       result = zone_from_args(server, args, &zone, NULL, ISC_TRUE);
+       result = zone_from_args(server, args, NULL, &zone, NULL, ISC_TRUE);
        if (result != ISC_R_SUCCESS)
                return (result);
        if (zone == NULL)
@@ -6006,7 +6011,7 @@ ns_server_reloadcommand(ns_server_t *server, char *args, isc_buffer_t *text) {
        dns_zonetype_t type;
        const char *msg = NULL;
 
-       result = zone_from_args(server, args, &zone, NULL, ISC_TRUE);
+       result = zone_from_args(server, args, NULL, &zone, NULL, ISC_TRUE);
        if (result != ISC_R_SUCCESS)
                return (result);
        if (zone == NULL) {
@@ -6066,7 +6071,7 @@ ns_server_notifycommand(ns_server_t *server, char *args, isc_buffer_t *text) {
        dns_zone_t *zone = NULL;
        const unsigned char msg[] = "zone notify queued";
 
-       result = zone_from_args(server, args, &zone, NULL, ISC_TRUE);
+       result = zone_from_args(server, args, NULL, &zone, NULL, ISC_TRUE);
        if (result != ISC_R_SUCCESS)
                return (result);
        if (zone == NULL)
@@ -6091,7 +6096,7 @@ ns_server_refreshcommand(ns_server_t *server, char *args, isc_buffer_t *text) {
        const unsigned char msg2[] = "not a slave or stub zone";
        dns_zonetype_t type;
 
-       result = zone_from_args(server, args, &zone, NULL, ISC_TRUE);
+       result = zone_from_args(server, args, NULL, &zone, NULL, ISC_TRUE);
        if (result != ISC_R_SUCCESS)
                return (result);
        if (zone == NULL)
@@ -7222,7 +7227,7 @@ ns_server_rekey(ns_server_t *server, char *args) {
        if (strncasecmp(args, NS_COMMAND_SIGN, strlen(NS_COMMAND_SIGN)) == 0)
            fullsign = ISC_TRUE;
 
-       result = zone_from_args(server, args, &zone, NULL, ISC_TRUE);
+       result = zone_from_args(server, args, NULL, &zone, NULL, ISC_TRUE);
        if (result != ISC_R_SUCCESS)
                return (result);
        if (zone == NULL)
@@ -7283,21 +7288,19 @@ ns_server_sync(ns_server_t *server, char *args, isc_buffer_t *text) {
        dns_zone_t *zone = NULL;
        char classstr[DNS_RDATACLASS_FORMATSIZE];
        char zonename[DNS_NAME_FORMATSIZE];
-       const char *vname, *sep, *msg = NULL;
+       const char *vname, *sep, *msg = NULL, *arg;
        isc_boolean_t cleanup = ISC_FALSE;
-       char arg[8];
-       int n;
 
-       /* Did the user specify -clean? */
-       n = sscanf(args, "%*s %7s", arg);
-       if (n > 0 && strcmp(arg, "-clean") == 0) {
-               cleanup = ISC_TRUE;
+       (void) next_token(&args, " \t");
 
-               /* shift so that zone_from_args() won't be confused */
-               (void) next_token(&args, " \t");
+       arg = next_token(&args, " \t");
+       if (arg != NULL &&
+           (strcmp(arg, "-clean") == 0 || strcmp(arg, "-clear") == 0)) {
+               cleanup = ISC_TRUE;
+               arg = next_token(&args, " \t");
        }
 
-       result = zone_from_args(server, args, &zone, NULL, ISC_TRUE);
+       result = zone_from_args(server, args, arg, &zone, NULL, ISC_FALSE);
        if (result != ISC_R_SUCCESS)
                return (result);
 
@@ -7373,7 +7376,7 @@ ns_server_freeze(ns_server_t *server, isc_boolean_t freeze, char *args,
        isc_boolean_t frozen;
        const char *msg = NULL;
 
-       result = zone_from_args(server, args, &zone, NULL, ISC_TRUE);
+       result = zone_from_args(server, args, NULL, &zone, NULL, ISC_TRUE);
        if (result != ISC_R_SUCCESS)
                return (result);
        if (zone == NULL) {
@@ -7707,7 +7710,7 @@ ns_server_del_zone(ns_server_t *server, char *args) {
        FILE                  *ifp = NULL, *ofp = NULL;
 
        /* Parse parameters */
-       CHECK(zone_from_args(server, args, &zone, &zonename, ISC_TRUE));
+       CHECK(zone_from_args(server, args, NULL, &zone, &zonename, ISC_TRUE));
        if (result != ISC_R_SUCCESS)
                return (result);
        if (zone == NULL) {
@@ -7909,7 +7912,8 @@ ns_server_signing(ns_server_t *server, char *args, isc_buffer_t *text) {
 
        if (strcasecmp(ptr, "-list") == 0)
                list = ISC_TRUE;
-       else if (strcasecmp(ptr, "-clear") == 0) {
+       else if ((strcasecmp(ptr, "-clear") == 0)  ||
+                (strcasecmp(ptr, "-clean") == 0)) {
                clear = ISC_TRUE;
                ptr = next_token(&args, " \t");
                if (ptr == NULL)
@@ -7952,7 +7956,7 @@ ns_server_signing(ns_server_t *server, char *args, isc_buffer_t *text) {
        } else
                CHECK(DNS_R_SYNTAX);
 
-       CHECK(zone_from_args(server, args, &zone, NULL, ISC_FALSE));
+       CHECK(zone_from_args(server, args, NULL, &zone, NULL, ISC_FALSE));
        if (zone == NULL)
                CHECK(ISC_R_UNEXPECTEDEND);
 
@@ -8051,7 +8055,7 @@ ns_server_zonestatus(ns_server_t *server, char *args, isc_buffer_t *text) {
        isc_time_settoepoch(&refreshkeytime);
        isc_time_settoepoch(&resigntime);
 
-       CHECK(zone_from_args(server, args, &zone, &zonename, ISC_TRUE));
+       CHECK(zone_from_args(server, args, NULL, &zone, &zonename, ISC_TRUE));
        if (result != ISC_R_SUCCESS)
                return (result);
        if (zone == NULL) {
index 3ccf27b6e2651e3a4e71d558e30b19def420c3ff..b2dbe8d5035ed61c7c57ae6be878f577df836124 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: rndc.c,v 1.141 2012/01/31 23:47:31 tbox Exp $ */
+/* $Id: rndc.c,v 1.142 2012/02/03 22:27:17 each Exp $ */
 
 /*! \file */
 
@@ -114,9 +114,9 @@ command is one of the following:\n\
   thaw         Enable updates to all dynamic zones and reload them.\n\
   thaw zone [class [view]]\n\
                Enable updates to a frozen dynamic zone and reload it.\n\
-  sync [-clear]        Dump changes to all dynamic zones to disk, and optionally\n\
+  sync [-clean]        Dump changes to all dynamic zones to disk, and optionally\n\
                remove their journal files.\n\
-  sync [-clear] zone [class [view]]\n\
+  sync [-clean] zone [class [view]]\n\
                Dump a single zone's changes to disk, and optionally\n\
                remove its journal file.\n\
   notify zone [class [view]]\n\