#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
}
#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"
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 */
* 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) {
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) {
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';
* 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);
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';
}
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';