]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 531]: ntpdc limitations on addserver & addpeer (Ray Van Tassle)
authorHarlan Stenn <stenn@ntp.org>
Sun, 11 Dec 2005 23:54:45 +0000 (18:54 -0500)
committerHarlan Stenn <stenn@ntp.org>
Sun, 11 Dec 2005 23:54:45 +0000 (18:54 -0500)
bk: 439cbc45nj_6ufBVyv3KxLxUQ47JQQ

html/ntpdc.html
ntpd/ntp_request.c
ntpdc/ntpdc.c
ntpdc/ntpdc.h
ntpdc/ntpdc_ops.c

index e82d0584d7fe637a11c349065c8f928cfe5a0d80..800127eefe741b26f400b9492035af0b0f6f3682 100644 (file)
                <p>Authenticated requests always include a timestamp in the packet data, which is included in the computation of the authentication code. This timestamp is compared by the server to its receive time stamp. If they differ by more than a small amount the request is rejected. This is done for two reasons. First, it makes simple replay attacks on the server, by someone who might be able to overhear traffic on your LAN, much more difficult. Second, it makes it more difficult to request configuration changes to your server from topologically remote hosts. While the reconfiguration facility will work well with a server on the local host, and may work adequately between time-synchronized hosts on the same LAN, it will work very poorly for more distant hosts. As such, if reasonable passwords are chosen, care is taken in the distribution and protection of keys and appropriate source address restrictions are applied, the run time reconfiguration facility should provide an adequate level of security.</p>
                <p>The following commands all make authenticated requests.</p>
                <dl>
-                       <dt><tt>addpeer <i>peer_address</i> [ <i>keyid</i> ] [ <i>version</i> ] [ <i>prefer</i> ]</tt>
-                       <dd>Add a configured peer association at the given address and operating in symmetric active mode. Note that an existing association with the same peer may be deleted when this command is executed, or may simply be converted to conform to the new configuration, as appropriate. If the optional <tt>keyid</tt> is a nonzero integer, all outgoing packets to the remote server will have an authentication field attached encrypted with this key. If the value is 0 (or not given) no authentication will be done. The <tt>version#</tt> can be 1, 2 or 3 and defaults to 3. The <tt>prefer</tt> keyword indicates a preferred peer (and thus will be used primarily for clock synchronisation if possible). The preferred peer also determines the validity of the PPS signal - if the preferred peer is suitable for synchronisation so is the PPS signal.
-                       <dt><tt>addserver <i>peer_address</i> [ <i>keyid</i> ] [ <i>version</i> ] [ <i>prefer</i> ]</tt>
+                       <dt><tt>addpeer <i>peer_address</i> [
+               <i>keyid</i> ] [ <i>version</i> ] [
+               <i>minpoll|prefer|iburst|burst</i> [...] ]</tt>
+                       <dd>Add a configured peer association at the
+                       given address and operating in symmetric
+                       active mode. Note that an existing association
+                       with the same peer may be deleted when this
+                       command is executed, or may simply be
+                       converted to conform to the new configuration,
+                       as appropriate. If the optional <tt>keyid</tt>
+                       is a nonzero integer, all outgoing packets to
+                       the remote server will have an authentication
+                       field attached encrypted with this key. If the
+                       value is 0 (or not given) no authentication
+                       will be done. The <tt>version#</tt> can be 1,
+                       2 or 3 and defaults to 3.  The remaining
+                       options are either a numeric value for <tt>minpoll</tt> or
+                       a literal string <tt>prefer</tt>, <tt>iburst</tt>, or
+                       <tt>burst</tt>, and have the action as specified in the
+                       <tt>peer</tt> configuration file command of
+                       ntpd.  See the <a href="confopt.html">Server Options</a> page for further information.
+                       Each flag (or its absence) replaces the
+                       previous setting. The <tt>prefer</tt> keyword indicates a preferred peer (and thus will be used primarily for clock synchronisation if possible). The preferred peer also determines the validity of the PPS signal - if the preferred peer is suitable for synchronisation so is the PPS signal.
+                       <dt><tt>addserver <i>peer_address</i> [ <i>keyid</i> ] [ <i>version</i> ] [ [ <i>minpoll|prefer|iburst|burst</i> [...] ]</tt>
                        <dd>Identical to the addpeer command, except that the operating mode is client.
-                       <dt><tt>broadcast <i>peer_address</i> [ <i>keyid</i> ] [ <i>version</i> ] [ <i>prefer</i> ]</tt>
+                       <dt><tt>broadcast <i>peer_address</i> [
+                       <i>keyid</i> ] [ <i>version</i> ] [ <i>prefer</i> ]</tt>
                        <dd>Identical to the addpeer command, except that the operating mode is broadcast. In this case a valid key identifier and key are required. The <tt>peer_address</tt> parameter can be the broadcast address of the local network or a multicast group address assigned to NTP. If a multicast address, a multicast-capable kernel is required.
                        <dt><tt>unconfig <i>peer_address</i> [...]</tt>
                        <dd>This command causes the configured bit to be removed from the specified peer(s). In many cases this will cause the peer association to be deleted. When appropriate, however, the association may persist in an unconfigured mode if the remote peer is willing to continue on in this fashion.
                <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
        </body>
 
-</html>
\ No newline at end of file
+</html>
index b067b9a788676ae399b0d21963332ef86bcf87b7..17dcef5fb12ce7c57883f31ce904f91157ce84a7 100644 (file)
@@ -495,17 +495,21 @@ process_private(
            !(inpkt->implementation == IMPL_XNTPD &&
            inpkt->request == REQ_CONFIG &&
            temp_size == sizeof(struct old_conf_peer))) {
+#ifdef DEBUG
                if (debug > 2)
                        printf("process_private: wrong item size, received %d, should be %d or %d\n",
                            temp_size, proc->sizeofitem, proc->v6_sizeofitem);
+#endif
                req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
                return;
        }
        if ((proc->sizeofitem != 0) &&
            ((temp_size * INFO_NITEMS(inpkt->err_nitems)) >
            (rbufp->recv_length - REQ_LEN_HDR))) {
+#ifdef DEBUG
                if (debug > 2)
                        printf("process_private: not enough data\n");
+#endif
                req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
                return;
        }
@@ -928,7 +932,10 @@ peer_stats (
        struct sockaddr_storage addr;
        extern struct peer *sys_peer;
 
-       printf("peer_stats: called\n");
+#ifdef DEBUG
+       if (debug)
+            printf("peer_stats: called\n");
+#endif
        items = INFO_NITEMS(inpkt->err_nitems);
        ipl = (struct info_peer_list *) inpkt->data;
        ip = (struct info_peer_stats *)prepare_pkt(srcadr, inter, inpkt,
@@ -946,14 +953,20 @@ peer_stats (
 #ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
                addr.ss_len = SOCKLEN(&addr);
 #endif
-               printf("peer_stats: looking for %s, %d, %d\n", stoa(&addr),
+#ifdef DEBUG
+               if (debug)
+                   printf("peer_stats: looking for %s, %d, %d\n", stoa(&addr),
                    ipl->port, ((struct sockaddr_in6 *)&addr)->sin6_port);
+#endif
                ipl = (struct info_peer_list *)((char *)ipl +
                    INFO_ITEMSIZE(inpkt->mbz_itemsize));
 
                if ((pp = findexistingpeer(&addr, (struct peer *)0, -1)) == 0)
                    continue;
-               printf("peer_stats: found %s\n", stoa(&addr));
+#ifdef DEBUG
+               if (debug)
+                    printf("peer_stats: found %s\n", stoa(&addr));
+#endif
                if (pp->srcadr.ss_family == AF_INET) {
                        ip->dstadr = (pp->processed) ?
                                pp->cast_flags == MDF_BCAST ?
@@ -1301,7 +1314,7 @@ do_conf(
                    && temp_cp.hmode != MODE_BROADCAST)
                    fl = 1;
                if (temp_cp.flags & ~(CONF_FLAG_AUTHENABLE | CONF_FLAG_PREFER
-                                 | CONF_FLAG_BURST | CONF_FLAG_SKEY))
+                                 | CONF_FLAG_BURST | CONF_FLAG_IBURST | CONF_FLAG_SKEY))
                    fl = 1;
                cp = (struct conf_peer *)
                    ((char *)cp + INFO_ITEMSIZE(inpkt->mbz_itemsize));
@@ -1330,6 +1343,8 @@ do_conf(
                    fl |= FLAG_PREFER;
                if (temp_cp.flags & CONF_FLAG_BURST)
                    fl |= FLAG_BURST;
+               if (temp_cp.flags & CONF_FLAG_IBURST)
+                   fl |= FLAG_IBURST;
                if (temp_cp.flags & CONF_FLAG_SKEY)
                        fl |= FLAG_SKEY;
                if (client_v6_capable && temp_cp.v6_flag != 0) {
@@ -1513,7 +1528,10 @@ do_unconf(
 #endif
                found = 0;
                peer = (struct peer *)0;
-               printf("searching for %s\n", stoa(&peeraddr));
+#ifdef DEBUG
+               if (debug)
+                    printf("searching for %s\n", stoa(&peeraddr));
+#endif
                while (!found) {
                        peer = findexistingpeer(&peeraddr, peer, -1);
                        if (peer == (struct peer *)0)
index b037a85818522fe76514b33e7ddc9012aead20d1..4c73b001b31e2031d72ebaa2025aa62c26e4a4f0 100644 (file)
@@ -1163,6 +1163,21 @@ docmd(
                i++;
        }
 
+       /* Any extra args are assumed to be "OPT|NTP_STR". */
+       for ( ; i < MAXARGS + MOREARGS;) {
+            if ((i+ti) >= ntok)
+                 break;
+               rval = getarg(tokens[i+ti], (int)(OPT|NTP_STR), &pcmd.argval[i]);
+               if (rval == -1) {
+                       ti++;
+                       continue;
+               }
+               if (rval == 0)
+                       return;
+               pcmd.nargs++;
+               i++;
+       }
+
        i += ti;
        if (i < ntok && *tokens[i] == '>') {
                char *fname;
index d56d2b617bffb7f0c22aa16a37849d25f4314a49..ff935ae24289862a84baeb23ab7cc62c6eb7ca6b 100644 (file)
@@ -11,7 +11,7 @@
  * Maximum number of arguments
  */
 #define        MAXARGS 4
-
+#define        MOREARGS 4
 /*
  * Flags for forming descriptors.
  */
@@ -39,7 +39,7 @@ typedef union {
  */
 struct parse {
        char *keyword;
-       arg_v argval[MAXARGS];
+       arg_v argval[MAXARGS + MOREARGS];
        int nargs;
 };
 
index 4ae7f1c22621d330590fe92ec7997af0fe01cb31..8663588d5c1063f7d437b95aaf71c8ef24ddc2d1 100644 (file)
@@ -117,10 +117,10 @@ struct xcmd opcmds[] = {
          { "", "", "", "" },
          "display event timer subsystem statistics" },
        { "addpeer",    addpeer,        { NTP_ADD, OPT|NTP_UINT, OPT|NTP_UINT, OPT|NTP_STR },
-         { "addr", "keyid", "version", "minpoll|prefer" },
+         { "addr", "keyid", "version", "minpoll|prefer|burst ..." },
          "configure a new peer association" },
        { "addserver",  addserver,      { NTP_ADD, OPT|NTP_UINT, OPT|NTP_UINT, OPT|NTP_STR },
-         { "addr", "keyid", "version", "minpoll|prefer" },
+         { "addr", "keyid", "version", "minpoll|prefer|burst|iburst ..." },
          "configure a new server" },
        { "addrefclock",addrefclock,    { NTP_ADD, OPT|NTP_UINT, OPT|NTP_STR, OPT|NTP_STR },
          { "addr", "mode", "minpoll|prefer", "minpoll|prefer" },
@@ -1330,6 +1330,8 @@ again:
                    flags |= CONF_FLAG_PREFER;
                else if (STREQ(pcmd->argval[items].string, "burst"))
                    flags |= CONF_FLAG_BURST;
+               else if (STREQ(pcmd->argval[items].string, "iburst"))
+                   flags |= CONF_FLAG_IBURST;
                else {
                        long val;
                        if (!atoint(pcmd->argval[items].string, &val)) {