]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Autokey multiple identity group improvements from Dave Mills
authorHarlan Stenn <stenn@ntp.org>
Fri, 31 Dec 2010 22:34:44 +0000 (17:34 -0500)
committerHarlan Stenn <stenn@ntp.org>
Fri, 31 Dec 2010 22:34:44 +0000 (17:34 -0500)
bk: 4d1e5a84MxbaY-NQMRLNyw3f0F3qaQ

ChangeLog
html/authopt.html
html/confopt.html
ntpd/ntp_control.c
ntpd/ntp_crypto.c
util/ntp-keygen.c

index 3eb3375bfa5e285ef3ff8dd556bc613a4a60f5d5..e252605bcd14380e2b9d91c975e0ff280667cc83 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+* Autokey multiple identity group improvements from Dave Mills.
 * [Bug 1768] TIOCFLUSH undefined in linux for refclock_acts.
 (4.2.7p107) 2010/12/31 Released by Harlan Stenn <stenn@ntp.org>
 * [Bug 1764] Palisade driver doesn't build on Linux.
index 252e363dfd0a9665d5932c80ef2f35cef82dff0b..c4e4d4992973b1cef15b3591885b5560d797b6a7 100644 (file)
@@ -10,7 +10,9 @@
 color: #FF0000;
  font-weight: bold;
 }
-.style1 {color: #FF0000}
+.style1 {
+       color: #FF0000
+}
 </style>
 </head>
 <body>
@@ -18,7 +20,7 @@ color: #FF0000;
 <img src="pic/alice44.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/%7emills/pictures.html">from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
 <p>Our resident cryptographer; now you see him, now you don't.</p>
 <p>Last update:
-  <!-- #BeginDate format:En2m -->22-Dec-2010  21:55<!-- #EndDate -->
+  <!-- #BeginDate format:En2m -->31-Dec-2010  6:20<!-- #EndDate -->
   UTC</p>
 <br clear="left">
 <h4>Related Links</h4>
@@ -54,18 +56,19 @@ color: #FF0000;
         key message digest algorithm. Note: If compliance with FIPS 140-2 is required,
         the algorithm must be ether <tt>SHA</tt> or <tt>SHA1</tt>.</dd>
       <dt><tt>host <i>name</i></tt></dt>
-      <dd>Specifies the string used when constructing the names for the host, sign
-        and certificate files generated by the <tt>ntp-keygen</tt> program  with the <tt>-s <i>host</i></tt> option.</dd>
-        <dd><span class="style1">Note: In the latest Autokey version,  this option is deprecated. See the <a href="autokey.html">Autokey Public-Key Authentication</a> page for further information.</span></a>
-      <dt>&nbsp;</dt>
+      <dd>Specifies the Autokey host name of this host.  If this option is not specified, the default name is the string returned by the Unix <tt>gethostname()</tt> routine.</dd>
+      <dd><span class="style1">Note: In the latest Autokey version,  this option has no affect other than to change the Autokey host name.</span></dd>
       <dt><tt>ident <i>group</i></tt></dt>
-      <dd>Specifies the optional string used in retrieving the identity files generated by the <tt>ntp-keygen</tt> program with the <tt>-i <i>group</i></tt> option.</dd>
+      <dd>Specifies the Autokey group name of this host.  If this option is not specified, the default is the empty string.</dd>
+      <dd><span class="style1">Note: In the latest Autokey version,  this option has no affect other than to change the Autokey group name.</span></dd>
       <dt><tt>pw <i>password</i></tt></dt>
-      <dd>Specifies the password to decrypt files previously encrypted by the <tt>ntp-keygen</tt> program with the <tt>-p</tt> option.</dd>
+      <dd>Specifies the password to decrypt files previously encrypted by the <tt>ntp-keygen</tt> program with the <tt>-p</tt> option. If this option is not specified, the default password is the string returned by the Unix <tt>gethostname()</tt> routine. </dd>
       <dt><tt>randfile <i>file</i></tt></dt>
       <dd>Specifies the location of the random seed file used by the OpenSSL library. The defaults are described on the <tt>ntp-keygen</tt> page.</dd>
     </dl>
   </dd>
+  <dt id="keys"><tt>ident <i>group</i></tt></dt>
+  <dd>Specifies the group name for ephemeral associations mobilized by broadcast and symmetric passive modes. See the <a href="autokey.html">Autokey Public-Key Authentication</a> page for further information.</dd>
   <dt id="keys"><tt>keys <i>path</i></tt></dt>
   <dd>Specifies the complete directory path for the  key file containing the key IDs, key types and keys  used by <tt>ntpd</tt>, <tt>ntpq</tt> and <tt>ntpdc</tt> when operating with symmetric key cryptography. This is the same operation as the <tt>-k </tt>command line option. Note that the directory path for Autokey cryptographic media is specified by the <tt>keysdir</tt> command.</dd>
   <dt id="keysdir"><tt>keysdir <i>path</i></tt></dt>
index 1be42382e54a2e9730d4a19763d4132f93bae374..69f8c85959eb711dca43a62a42d525df7ad536ba 100644 (file)
@@ -12,7 +12,7 @@
 Walt Kelly</a>
 <p>The chicken is getting configuration advice.</p>
 <p>Last update:
-       <!-- #BeginDate format:En2m -->16-Dec-2010  0:52<!-- #EndDate -->
+       <!-- #BeginDate format:En2m -->31-Dec-2010  6:22<!-- #EndDate -->
 </p>
 <br clear="left">
 <h4>Related Links</h4>
@@ -64,7 +64,7 @@ Walt Kelly</a>
   <dt><tt>iburst</tt></dt>
        <dd>When the server is unreachable, send a burst of  packets instead of the usual one.  This option is valid only with the <tt>server</tt> command and type s addresses. It is a recommended option with this command. Additional information about this option is on the <a href="poll.html">Poll Program</a> page.</dd>
     <dt><tt>ident</tt> <em><tt>group</tt></em></dt>
-    <dd>Specify <i><tt>group</tt></i> as the group name for the association. This is used by the identigy scheme described on the <a href="autokey.html">Autokey Public-Key Authenticationn</a> page.</dd>
+    <dd>Specify the group name for the association.  See the <a href="autokey.html">Autokey Public-Key Authentication</a> page for further information.</dd>
   <dt><tt>key</tt> <i><tt>key</tt></i></dt>
   <dd>Send and receive packets authenticated by the symmetric key scheme described in the <a href="authentic.html">Authentication Support</a> page. The <i><tt>key</tt></i> specifies the key identifier with values from 1 to 65534, inclusive. This option is mutually exclusive with the <tt>autokey</tt> option.</dd>      <dt><tt>minpoll <i>minpoll<br>
        </i></tt><tt>maxpoll <i>maxpoll</i></tt></dt>
index 2b3e1ae8601dbbd46433f50e38488b62046464b1..aca3566755f9974438a5ec844a6dec1b15b5d419 100644 (file)
@@ -2292,8 +2292,8 @@ ctl_putsys(
 
        case CS_HOST:
                if (sys_hostname != NULL)
-                       ctl_putstr(sys_var[CS_HOST].text, sys_hostname,
-                           strlen(sys_hostname));
+                       ctl_putstr(sys_var[CS_HOST].text, hostval.ptr,
+                           strlen(hostval.ptr));
                break;
 
        case CS_IDENT:
index 2d616a96874db9abc839ecc452156ad1104c95e7..21bb6f37dc3c46620235e67e3181e137e4ee2b8b 100644 (file)
@@ -3647,7 +3647,8 @@ crypto_setup(void)
 {
        struct pkey_info *pinfo; /* private/public key */
        char    filename[MAXFILENAME]; /* file name buffer */
-       char *  randfile;
+       char    hostname[MAXFILENAME]; /* host name buffer */
+       char    *randfile;
        char    statstr[NTP_MAXSTRLEN]; /* statistics for filegen */
        l_fp    seed;           /* crypto PRNG seed as NTP timestamp */
        u_int   len;
@@ -3703,13 +3704,12 @@ crypto_setup(void)
        /*
         * Initialize structures.
         */
-       if (sys_hostname == NULL) {
-               gethostname(filename, MAXFILENAME);
-               sys_hostname = emalloc(strlen(filename) + 1);
-               strcpy(sys_hostname, filename);
-       }
+       gethostname(hostname, MAXFILENAME);
+       if (sys_hostname == NULL)
+               sys_hostname = strdup(hostname);
        if (passwd == NULL)
                passwd = sys_hostname;
+
        memset(&hostval, 0, sizeof(hostval));
        memset(&pubkey, 0, sizeof(pubkey));
        memset(&tai_leap, 0, sizeof(tai_leap));
@@ -3720,7 +3720,7 @@ crypto_setup(void)
         * as we know it ends. The host key also becomes the default
         * sign key. 
         */
-       snprintf(filename, MAXFILENAME, "ntpkey_host_%s", sys_hostname);
+       snprintf(filename, MAXFILENAME, "ntpkey_host_%s", hostname);
        pinfo = crypto_key(filename, passwd, NULL);
        if (pinfo == NULL) {
                msyslog(LOG_ERR,
@@ -3751,14 +3751,14 @@ crypto_setup(void)
         * Load optional sign key from file "ntpkey_sign_<hostname>". If
         * available, it becomes the sign key.
         */
-       snprintf(filename, MAXFILENAME, "ntpkey_sign_%s", sys_hostname);
+       snprintf(filename, MAXFILENAME, "ntpkey_sign_%s", hostname);
        pinfo = crypto_key(filename, passwd, NULL); if (pinfo != NULL)
                sign_pkey = pinfo->pkey;
 
        /*
         * Load required certificate from file "ntpkey_cert_<hostname>".
         */
-       snprintf(filename, MAXFILENAME, "ntpkey_cert_%s", sys_hostname);
+       snprintf(filename, MAXFILENAME, "ntpkey_cert_%s", hostname);
        cinfo = crypto_cert(filename);
        if (cinfo == NULL) {
                msyslog(LOG_ERR,
@@ -3781,37 +3781,42 @@ crypto_setup(void)
                    filename);
                exit (-1);
        }
-       hostval.vallen = htonl(strlen(cinfo->subject));
-       hostval.ptr = cinfo->subject;
+printf("xxx %s %s\n", sys_hostname, sys_groupname);
+
        if (sys_groupname == NULL)
-               sys_groupname = sys_hostname;
+               snprintf(filename, MAXFILENAME, "%s", sys_hostname);
+       else
+               snprintf(filename, MAXFILENAME, "%s@%s", sys_hostname,
+                   sys_groupname);
+       hostval.vallen = htonl(strlen(filename));
+       hostval.ptr = strdup(filename);
 
        /*
         * Load optional IFF parameters from file
-        * "ntpkey_iffkey_<groupname>".
+        * "ntpkey_iffkey_<hostname>".
         */
        snprintf(filename, MAXFILENAME, "ntpkey_iffkey_%s",
-           sys_groupname);
+           hostname);
        iffkey_info = crypto_key(filename, passwd, NULL);
        if (iffkey_info != NULL)
                crypto_flags |= CRYPTO_FLAG_IFF;
 
        /*
         * Load optional GQ parameters from file
-        * "ntpkey_gqkey_<groupname>".
+        * "ntpkey_gqkey_<hostname>".
         */
        snprintf(filename, MAXFILENAME, "ntpkey_gqkey_%s",
-           sys_groupname);
+           hostname);
        gqkey_info = crypto_key(filename, passwd, NULL);
        if (gqkey_info != NULL)
                crypto_flags |= CRYPTO_FLAG_GQ;
 
        /*
         * Load optional MV parameters from file
-        * "ntpkey_mvkey_<groupname>".
+        * "ntpkey_mvkey_<hostname>".
         */
        snprintf(filename, MAXFILENAME, "ntpkey_mvkey_%s",
-           sys_groupname);
+           hostname);
        mvkey_info = crypto_key(filename, passwd, NULL);
        if (mvkey_info != NULL)
                crypto_flags |= CRYPTO_FLAG_MV;
@@ -3821,7 +3826,7 @@ crypto_setup(void)
         */
        crypto_flags |= CRYPTO_FLAG_ENAB | (cinfo->nid << 16);
        snprintf(statstr, NTP_MAXSTRLEN,
-           "setup 0x%x host %s %s", crypto_flags, sys_hostname,
+           "setup 0x%x host %s %s", crypto_flags, hostname,
            OBJ_nid2ln(cinfo->nid));
        record_crypto_stats(NULL, statstr);
 #ifdef DEBUG
index a08872ab62a7e3c4bfc4d8ea09c59337f9200618..6375ce01c0397f0664380765a752c7da0486f8ab 100644 (file)
@@ -416,21 +416,16 @@ main(
                                        else if (strcmp(pathbuf,
                                            "Private") == 0)
                                                exten = EXT_KEY_PRIVATE;
-                                       if (groupname == NULL)
-                                               groupname = ptr + 3;
+                                       if (certname == NULL)
+                                               certname = ptr + 3;
                                }
                        }
                }
        }
        if (scheme == NULL)
                scheme = "RSA-MD5";
-       if (groupname == NULL)
-               groupname = hostname;
        fprintf(stderr, "Using host %s group %s\n", hostname,
            groupname);
-       if ((iffkey || gqkey || mvkey) && exten == NULL)
-               fprintf(stderr,
-                   "Warning: identity files may not be useful with a nontrusted certificate.\n");
 #endif /* AUTOKEY */
 
        /*
@@ -2054,7 +2049,7 @@ fheader   (
                perror("Write");
                exit (-1);
        }
-       sprintf(linkname, "ntpkey_%s_%s", ulink, owner);
+       sprintf(linkname, "ntpkey_%s_%s", ulink, hostname);
        remove(linkname);
        temp = symlink(filename, linkname);
        if (temp < 0)