]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Many files:
authorHarlan Stenn <stenn@ntp.org>
Mon, 20 Mar 2000 07:15:36 +0000 (07:15 -0000)
committerHarlan Stenn <stenn@ntp.org>
Mon, 20 Mar 2000 07:15:36 +0000 (07:15 -0000)
  * ntpd/ntp_resolver.c (findhostaddr): hstrerror isn't always available.
  * configure.in: Look for hstrerror.
  * util/ntp_genkeys.c (main): Use snprintf, not sprintf.
  * ntpd/ntp_crypto.c: Use gethostname, not uname
  * util/ntp_genkeys.c: Ditto
  From: Dave Mills

bk: 38d5d018dyJBwMhjK6NtXy7SJ_Tr7w

ChangeLog
config.h.in
configure
configure.in
ntpd/ntp_crypto.c
ntpd/ntp_resolver.c
util/ntp_genkeys.c

index b56d65a5c63eb8e85d25f4e3585717b573fed42b..41e66ac3555accdef7e38c9e7c5df44851f7b2fb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2000-03-20  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_resolver.c (findhostaddr): hstrerror isn't always available.
+
+       * configure.in: Look for hstrerror.
+
+       * util/ntp_genkeys.c (main): Use snprintf, not sprintf.
+       
+       * ntpd/ntp_crypto.c: Use gethostname, not uname
+       * util/ntp_genkeys.c: Ditto
+       From: Dave Mills
+
 2000-03-19  Harlan Stenn  <harlan@pfcs.com>
 
        * ntpd/ntp_proto.c (receive): Rename ntp_res_send() to
index 8dad8e80bbe033a2e85f1d941860f493c14d36af..d42bd69f4fc587d4f691ca99fa2a9faca87a0aa7 100644 (file)
 /* Define if you have the `getuid' function. */
 #undef HAVE_GETUID
 
+/* Define if you have the `hstrerror' function. */
+#undef HAVE_HSTRERROR
+
 /* Define if you have the <ieeefp.h> header file. */
 #undef HAVE_IEEEFP_H
 
index 7efdb1fd01d4a5c1b3b57089efa73187bd9225c7..3002d77070638e382380f8492ea767efd81af2fc 100755 (executable)
--- a/configure
+++ b/configure
@@ -5655,7 +5655,7 @@ done
 
     ;;
 esac
-for ac_func in K_open kvm_open memcpy memmove memset
+for ac_func in hstrerror K_open kvm_open memcpy memmove memset
 do
 ac_ac_var=`echo "ac_cv_func_$ac_func" | $ac_tr_sh`
 echo $ac_n "checking for $ac_func... $ac_c" 1>&6
index 7596d099f75bb98ec6175d1467f8d30811b9d8b8..081408eef531a507b1fc29013b699b243be68682 100644 (file)
@@ -560,7 +560,7 @@ case "$target" in
  *) AC_CHECK_FUNCS(getuid)
     ;;
 esac
-AC_CHECK_FUNCS(K_open kvm_open memcpy memmove memset)
+AC_CHECK_FUNCS(hstrerror K_open kvm_open memcpy memmove memset)
 case "$target" in
  *-*-sco3.2v5.0.*)
     # Just stubs.  Idiots.
index ee3f8a9939bc6eb69b0f4d1e1a8808080c99e6e3..63c3f793e87601b424481101a0b1c4956f9c4d31 100644 (file)
@@ -9,7 +9,6 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <sys/utsname.h>
 
 #include "ntpd.h"
 #include "ntp_stdlib.h"
@@ -894,7 +893,7 @@ void
 crypto_setup(void)
 {
        FILE *str;
-       struct utsname utsnamebuf;
+       u_char hostname[MAXFILENAME];
        u_char filename[MAXFILENAME];
 
        /*
@@ -910,9 +909,9 @@ crypto_setup(void)
         * host is the DNS name of this machine.
         */
        if (public_key_file == NULL) {
-               uname(&utsnamebuf);
+               gethostname(&hostname, MAXFILENAME);
                snprintf(filename, sizeof filename, "ntpkey_%s",
-                        utsnamebuf.nodename);
+                        hostname);
                public_key_file = emalloc(strlen(filename) + 1);
                strcpy(public_key_file, filename);
        }
index 7b201884a3728ea7857566b36c6980a2b7bf9f8f..15466b72bb9f130d7c708ef12f4bfe9457e09925 100644 (file)
@@ -551,12 +551,36 @@ findhostaddr(
 #ifdef DEBUG
                if (debug > 2) {
                        struct in_addr si;
+                       char *hes;
+#ifndef HAVE_HSTRERROR
+                       char hnum[20];
+                       
+                       switch (h_errno) {
+                           case HOST_NOT_FOUND:
+                               hes = "Authoritive Answer Host not found";
+                               break;
+                           case TRY_AGAIN:
+                               hes = "Non-Authoritative Host not found, or SERVERFAIL";
+                               break;
+                           case NO_RECOVERY:
+                               hes = "Non recoverable errors, FORMERR, REFUSED, NOTIMP";
+                               break;
+                           case NO_DATA:
+                               hes = "Valid name, no data record of requested type";
+                               break;
+                           default:
+                               snprintf(hnum, sizeof hnum, "%d", h_errno);
+                               hes = hnum;
+                               break;
+                       }
+#else
+                       hes = hstrerror(h_errno);
+#endif
 
-                       si.s_addr = de->de_peeraddr;
+                       si.s_addr = entry->de_peeraddr;
                        msyslog(LOG_DEBUG,
                                "findhostaddr: Failed resolution on <%s>/%s: %s",
-                               de->de_hostname, inet_ntoa(si),
-                               hstrerror(h_errno));
+                               entry->de_hostname, inet_ntoa(si), hes);
                }
 #endif
        }
index 1b025cb1193c56eca2a90c0ae94714f41e2b08dd..ca20e7d0c11a008005aece79c6b11eec9093f32e 100644 (file)
@@ -5,7 +5,6 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <sys/time.h>
-#include <sys/utsname.h>
 #include "ntpd.h"
 #include "ntp_stdlib.h"
 #include "ntp_string.h"
@@ -94,8 +93,8 @@ main(
        u_char encoded_key[MAXKEYLEN];  /* encoded PEM string buffer */
        u_int modulus;                  /* modulus length */
        struct timeval tv;              /* initialization vector */
-       struct utsname utsnamebuf;      /* uname argument structure */
-       u_char sysname[128];            /* DNS host name */
+       u_char hostname[256];           /* DNS host name */
+       u_char filename[256];           /* public key file name */
        u_char md5key[17];              /* generated MD5 key */ 
        FILE *str;                      /* file handle */
        int rval;                       /* return value */
@@ -106,7 +105,7 @@ main(
         * Generate the file "ntp.keys" containing 16 random MD5 keys in
         * the format expected at daemon run time.
         */
-       uname(&utsnamebuf);
+       gethostname(&hostname, sizeof hostname);
        printf("Generating MD5 keys...\n");
        str = fopen("ntp.keys", "w");
        if (str == NULL) {
@@ -116,7 +115,7 @@ main(
        gettimeofday(&tv, 0);
        srandom((u_int)tv.tv_sec);
        fprintf(str, "# MD5/DES key file generated by %s\n# %s",
-           utsnamebuf.nodename, ctime(&tv.tv_sec));
+           hostname, ctime(&tv.tv_sec));
        for (i = 1; i <= 16; i++) {
                for (j = 0; j < 16; j++) {
                        while (1) {
@@ -164,7 +163,7 @@ main(
        len = sizeof(rsaref_private) - sizeof(rsaref_private.bits);
        modulus = (u_int32)rsaref_private.bits;
        fprintf(str, "# RSA private key file generated by %s\n# %s",
-           utsnamebuf.nodename, ctime(&tv.tv_sec));
+           hostname, ctime(&tv.tv_sec));
        R_EncodePEMBlock(encoded_key, &temp,
            (u_char *)&rsaref_private.modulus, len);
        encoded_key[temp] = '\0';
@@ -175,8 +174,8 @@ main(
         * Generate the file "ntpkey_host" containing the RSA public key
         * in printable ASCII format.
         */
-       sprintf(sysname, "ntpkey_%s", utsnamebuf.nodename); 
-       str = fopen(sysname, "w");
+       snprintf(filename, sizeof filename, "ntpkey_%s", hostname); 
+       str = fopen(filename, "w");
        if (str == NULL) { 
                perror("RSA public key file");
                return (-1);
@@ -184,7 +183,7 @@ main(
        len = sizeof(rsaref_public) - sizeof(rsaref_public.bits);
        modulus = (u_int32)rsaref_public.bits;
        fprintf(str, "# RSA public key file generated by %s\n# %s",
-           utsnamebuf.nodename, ctime(&tv.tv_sec));
+           hostname, ctime(&tv.tv_sec));
        R_EncodePEMBlock(encoded_key, &temp,
            (u_char *)&rsaref_public.modulus, len);
        encoded_key[temp] = '\0';
@@ -224,7 +223,7 @@ main(
        }
        fprintf(str,
            "# Diffie-Hellman parameter file generated by %s\n# %s",
-           utsnamebuf.nodename, ctime(&tv.tv_sec));
+           hostname, ctime(&tv.tv_sec));
        R_EncodePEMBlock(encoded_key, &temp,
            (u_char *)dh_params.prime, dh_params.primeLen);
        encoded_key[temp] = '\0';