diff options
Diffstat (limited to 'contrib/ntp/ntpdc/ntpdc.c')
-rw-r--r-- | contrib/ntp/ntpdc/ntpdc.c | 400 |
1 files changed, 278 insertions, 122 deletions
diff --git a/contrib/ntp/ntpdc/ntpdc.c b/contrib/ntp/ntpdc/ntpdc.c index 6086dae..aa4f188 100644 --- a/contrib/ntp/ntpdc/ntpdc.c +++ b/contrib/ntp/ntpdc/ntpdc.c @@ -8,6 +8,10 @@ #include "ntp_select.h" #include "ntp_io.h" #include "ntp_stdlib.h" +/* Don't include ISC's version of IPv6 variables and structures */ +#define ISC_IPV6_H 1 +#include "isc/net.h" +#include "isc/result.h" #include <ctype.h> #include <signal.h> @@ -20,10 +24,10 @@ # define closesocket close #endif /* SYS_WINNT */ -#ifdef HAVE_LIBREADLINE +#if defined(HAVE_LIBREADLINE) || defined (HAVE_LIBEDIT) # include <readline/readline.h> # include <readline/history.h> -#endif /* HAVE_LIBREADLINE */ +#endif /* HAVE_LIBREADLINE || HAVE_LIBEDIT */ #ifdef SYS_VXWORKS /* vxWorks needs mode flag -casey*/ @@ -45,12 +49,11 @@ static const char * prompt = "ntpdc> "; /* prompt to ask him about */ static u_long info_auth_keyid; /* - * Type of key md5 or des + * Type of key md5 */ -#define KEY_TYPE_DES 3 #define KEY_TYPE_MD5 4 -static int info_auth_keytype = KEY_TYPE_MD5; /* MD5*/ +static int info_auth_keytype = KEY_TYPE_MD5; /* MD5 */ u_long current_time; /* needed by authkeys; not used */ int ntpdcmain P((int, char **)); @@ -60,7 +63,7 @@ int ntpdcmain P((int, char **)); static int openhost P((const char *)); static int sendpkt P((char *, int)); static void growpktdata P((void)); -static int getresponse P((int, int, int *, int *, char **)); +static int getresponse P((int, int, int *, int *, char **, int)); static int sendrequest P((int, int, int, int, int, char *)); static void getcmds P((void)); static RETSIGTYPE abortcmd P((int)); @@ -68,7 +71,7 @@ static void docmd P((const char *)); static void tokenize P((const char *, char **, int *)); static int findcmd P((char *, struct xcmd *, struct xcmd *, struct xcmd **)); static int getarg P((char *, int, arg_v *)); -static int getnetnum P((const char *, u_int32 *, char *)); +static int getnetnum P((const char *, struct sockaddr_storage *, char *, int)); static void help P((struct parse *, FILE *)); #ifdef QSORT_USES_VOID_P static int helpsort P((const void *, const void *)); @@ -108,8 +111,8 @@ static struct xcmd builtins[] = { { "delay", my_delay, { OPT|INT, NO, NO, NO }, { "msec", "", "", "" }, "set the delay added to encryption time stamps" }, - { "host", host, { OPT|NTP_STR, NO, NO, NO }, - { "hostname", "", "", "" }, + { "host", host, { OPT|NTP_STR, OPT|NTP_STR, NO, NO }, + { "-4|-6", "hostname", "", "" }, "specify the host whose NTP server we talk to" }, { "passwd", passwd, { OPT|NTP_STR, NO, NO, NO }, { "", "", "", "" }, @@ -151,7 +154,9 @@ static struct xcmd builtins[] = { #define MAXCMDS 100 /* maximum commands on cmd line */ #define MAXHOSTS 200 /* maximum hosts on cmd line */ #define MAXLINE 512 /* maximum line length */ -#define MAXTOKENS (1+MAXARGS+2) /* maximum number of usable tokens */ +#define MAXTOKENS (1+1+MAXARGS+2) /* maximum number of usable tokens */ + /* command + -4|-6 + MAXARGS + */ + /* redirection */ /* * Some variables used and manipulated locally @@ -160,20 +165,19 @@ static struct timeval tvout = { DEFTIMEOUT, 0 }; /* time out for reads */ static struct timeval tvsout = { DEFSTIMEOUT, 0 }; /* secondary time out */ static l_fp delay_time; /* delay time */ static char currenthost[LENHOSTNAME]; /* current host name */ -static struct sockaddr_in hostaddr = { 0 }; /* host address */ -static int showhostnames = 1; /* show host names by default */ +int showhostnames = 1; /* show host names by default */ -static int sockfd; /* fd socket is openned on */ +static int ai_fam_templ; /* address family */ +static int ai_fam_default; /* default address family */ +static SOCKET sockfd; /* fd socket is opened on */ static int havehost = 0; /* set to 1 when host open */ -struct servent *server_entry = NULL; /* server entry for ntp */ +int s_port = 0; #if defined (SYS_WINNT) || defined (SYS_VXWORKS) char password[9]; #endif /* SYS_WINNT || SYS_VXWORKS */ #ifdef SYS_WINNT -WORD wVersionRequested; -WSADATA wsaData; DWORD NumberOfBytesWritten; HANDLE TimerThreadHandle = NULL; /* 1998/06/03 - Used in ntplib/machines.c */ @@ -194,6 +198,7 @@ static int pktdatasize; /* * These are used to help the magic with old and new versions of ntpd. */ +int impl_ver = IMPL_XNTPD; static int req_pkt_size = REQ_LEN_NOMAC; /* @@ -268,7 +273,6 @@ void clear_globals(void) showhostnames = 0; /* show host names by default */ ntp_optind = 0; ntp_optarg = 0; - server_entry = NULL; /* server entry for ntp */ havehost = 0; /* set to 1 when host open */ numcmds = 0; numhosts = 0; @@ -297,9 +301,29 @@ ntpdcmain( taskPrioritySet(taskIdSelf(), 100 ); #endif +#ifdef SYS_WINNT + if (!Win32InitSockets()) + { + fprintf(stderr, "No useable winsock.dll:"); + exit(1); + } +#endif /* SYS_WINNT */ + + /* Check to see if we have IPv6. Otherwise force the -4 flag */ + if (isc_net_probeipv6() != ISC_R_SUCCESS) { + ai_fam_default = AF_INET; + } + progname = argv[0]; - while ((c = ntp_getopt(argc, argv, "c:dilnps")) != EOF) + ai_fam_templ = ai_fam_default; + while ((c = ntp_getopt(argc, argv, "46c:dilnps")) != EOF) switch (c) { + case '4': + ai_fam_templ = AF_INET; + break; + case '6': + ai_fam_templ = AF_INET6; + break; case 'c': ADDCMD(ntp_optarg); break; @@ -327,7 +351,7 @@ ntpdcmain( } if (errflg) { (void) fprintf(stderr, - "usage: %s [-dilnps] [-c cmd] host ...\n", + "usage: %s [-46dilnps] [-c cmd] host ...\n", progname); exit(2); } @@ -358,14 +382,6 @@ ntpdcmain( } pktdatasize = INITDATASIZE; -#ifdef SYS_WINNT - wVersionRequested = MAKEWORD(1,1); - if (WSAStartup(wVersionRequested, &wsaData)) { - fprintf(stderr, "No useable winsock.dll"); - exit(1); - } -#endif /* SYS_WINNT */ - if (numcmds == 0) { (void) openhost(chosts[0]); getcmds(); @@ -397,29 +413,68 @@ openhost( const char *hname ) { - u_int32 netnum; char temphost[LENHOSTNAME]; + int a_info, i; + struct addrinfo hints, *ai = NULL; + register const char *cp; + char name[LENHOSTNAME]; + char service[5]; - if (server_entry == NULL) { - server_entry = getservbyname("ntp", "udp"); - if (server_entry == NULL) { -#ifdef VMS /* UCX getservbyname() doesn't work [yet], but we do know better */ - server_entry = (struct servent *) - malloc(sizeof(struct servent)); - server_entry->s_port = htons(NTP_PORT); -#else - (void) fprintf(stderr, "%s: ntp/udp: unknown service\n", - progname); - exit(1); -#endif /* VMS & UCX */ - } - if (debug > 2) - printf("Got ntp/udp service entry\n"); + /* + * We need to get by the [] if they were entered + */ + + cp = hname; + + if (*cp == '[') { + cp++; + for(i = 0; *cp != ']'; cp++, i++) + name[i] = *cp; + name[i] = '\0'; + hname = name; + } + + /* + * First try to resolve it as an ip address and if that fails, + * do a fullblown (dns) lookup. That way we only use the dns + * when it is needed and work around some implementations that + * will return an "IPv4-mapped IPv6 address" address if you + * give it an IPv4 address to lookup. + */ + strcpy(service, "ntp"); + memset((char *)&hints, 0, sizeof(struct addrinfo)); + hints.ai_family = ai_fam_templ; + hints.ai_protocol = IPPROTO_UDP; + hints.ai_socktype = SOCK_DGRAM; + hints.ai_flags = AI_NUMERICHOST; + + a_info = getaddrinfo(hname, service, &hints, &ai); + if (a_info == EAI_NONAME || a_info == EAI_NODATA) { + hints.ai_flags = AI_CANONNAME; +#ifdef AI_ADDRCONFIG + hints.ai_flags |= AI_ADDRCONFIG; +#endif + a_info = getaddrinfo(hname, service, &hints, &ai); + } + /* Some older implementations don't like AI_ADDRCONFIG. */ + if (a_info == EAI_BADFLAGS) { + hints.ai_flags = AI_CANONNAME; + a_info = getaddrinfo(hname, service, &hints, &ai); + } + if (a_info != 0) { + (void) fprintf(stderr, "%s\n", gai_strerror(a_info)); + return 0; + } + + if (ai->ai_canonname == NULL) { + strncpy(temphost, stoa((struct sockaddr_storage *)ai->ai_addr), + LENHOSTNAME); + temphost[LENHOSTNAME-1] = '\0'; + } else { + strncpy(temphost, ai->ai_canonname, LENHOSTNAME); + temphost[LENHOSTNAME-1] = '\0'; } - if (!getnetnum(hname, &netnum, temphost)) - return 0; - if (debug > 2) printf("Opening host %s\n", temphost); @@ -430,14 +485,18 @@ openhost( havehost = 0; } (void) strcpy(currenthost, temphost); - - hostaddr.sin_family = AF_INET; -#ifndef SYS_VXWORKS - hostaddr.sin_port = server_entry->s_port; -#else - hostaddr.sin_port = htons(SERVER_PORT_NUM); -#endif - hostaddr.sin_addr.s_addr = netnum; + + /* port maps to the same in both families */ + s_port = ((struct sockaddr_in6 *)ai->ai_addr)->sin6_port; +#ifdef SYS_VXWORKS + ((struct sockaddr_in6 *)&hostaddr)->sin6_port = htons(SERVER_PORT_NUM); + if (ai->ai_family == AF_INET) + *(struct sockaddr_in *)&hostaddr= + *((struct sockaddr_in *)ai->ai_addr); + else + *(struct sockaddr_in6 *)&hostaddr= + *((struct sockaddr_in6 *)ai->ai_addr); +#endif /* SYS_VXWORKS */ #ifdef SYS_WINNT { @@ -449,14 +508,14 @@ openhost( exit(1); } } - - sockfd = socket(AF_INET, SOCK_DGRAM, 0); + + sockfd = socket(ai->ai_family, SOCK_DGRAM, 0); if (sockfd == INVALID_SOCKET) { error("socket", "", ""); exit(-1); } #else - sockfd = socket(AF_INET, SOCK_DGRAM, 0); + sockfd = socket(ai->ai_family, SOCK_DGRAM, 0); if (sockfd == -1) error("socket", "", ""); #endif /* SYS_WINNT */ @@ -474,12 +533,19 @@ openhost( # endif #endif - if (connect(sockfd, (struct sockaddr *)&hostaddr, +#ifdef SYS_VXWORKS + if (connect(sockfd, (struct sockaddr *)&hostaddr, sizeof(hostaddr)) == -1) +#else + if (connect(sockfd, (struct sockaddr *)ai->ai_addr, + ai->ai_addrlen) == -1) +#endif /* SYS_VXWORKS */ error("connect", "", ""); - + if (a_info) + freeaddrinfo(ai); havehost = 1; req_pkt_size = REQ_LEN_NOMAC; + impl_ver = IMPL_XNTPD; return 1; } @@ -527,15 +593,18 @@ getresponse( int reqcode, int *ritems, int *rsize, - char **rdata + char **rdata, + int esize ) { struct resp_pkt rpkt; struct timeval tvo; int items; + int i; int size; int datasize; char *datap; + char *tmp_data; char haveseq[MAXSEQ+1]; int firstpkt; int lastseq; @@ -543,6 +612,7 @@ getresponse( int seq; fd_set fds; int n; + int pad; /* * This is pretty tricky. We may get between 1 and many packets @@ -666,13 +736,15 @@ getresponse( return (int)INFO_ERR(rpkt.err_nitems); } - /* * Collect items and size. Make sure they make sense. */ items = INFO_NITEMS(rpkt.err_nitems); size = INFO_ITEMSIZE(rpkt.mbz_itemsize); - + if (esize > size) + pad = esize - size; + else + pad = 0; if ((datasize = items*size) > (n-RESP_HEADER_SIZE)) { if (debug) printf( @@ -685,15 +757,14 @@ getresponse( * If this isn't our first packet, make sure the size matches * the other ones. */ - if (!firstpkt && size != *rsize) { + if (!firstpkt && esize != *rsize) { if (debug) printf("Received itemsize %d, previous %d\n", size, *rsize); goto again; } - /* - * If we've received this before, toss it + * If we've received this before, +toss it */ seq = INFO_SEQ(rpkt.auth_seq); if (haveseq[seq]) { @@ -717,17 +788,28 @@ getresponse( /* * So far, so good. Copy this data into the output array. */ - if ((datap + datasize) > (pktdata + pktdatasize)) { + if ((datap + datasize + (pad * items)) > (pktdata + pktdatasize)) { int offset = datap - pktdata; growpktdata(); *rdata = pktdata; /* might have been realloced ! */ datap = pktdata + offset; } - memmove(datap, (char *)rpkt.data, (unsigned)datasize); - datap += datasize; + /* + * We now move the pointer along according to size and number of + * items. This is so we can play nice with older implementations + */ + + tmp_data = (char *)rpkt.data; + for(i = 0; i <items; i++){ + memmove(datap, tmp_data, (unsigned)size); + tmp_data += size; + memset(datap + size, 0, pad); + datap += size + pad; + } + if (firstpkt) { firstpkt = 0; - *rsize = size; + *rsize = size + pad; } *ritems += items; @@ -796,8 +878,7 @@ sendrequest( info_auth_keyid = maclen; } if (!authistrusted(info_auth_keyid)) { - pass = getpass((info_auth_keytype == KEY_TYPE_DES) - ? "DES Password: " : "MD5 Password: "); + pass = getpass("MD5 Password: "); if (*pass == '\0') { (void) fprintf(stderr, "Invalid password\n"); @@ -837,7 +918,8 @@ doquery( int *ritems, int *rsize, char **rdata, - int quiet_mask + int quiet_mask, + int esize ) { int res; @@ -882,7 +964,7 @@ again: /* * Get the response. If we got a standard error, print a message */ - res = getresponse(implcode, reqcode, ritems, rsize, rdata); + res = getresponse(implcode, reqcode, ritems, rsize, rdata, esize); /* * Try to be compatible with older implementations of ntpd. @@ -894,9 +976,17 @@ again: switch(req_pkt_size) { case REQ_LEN_NOMAC: + req_pkt_size = 160; + break; + case 160: req_pkt_size = 48; break; } + if (impl_ver == IMPL_XNTPD) { + fprintf(stderr, + "***Warning changing to older implementation\n"); + return INFO_ERR_IMPL; + } fprintf(stderr, "***Warning changing the request packet size from %d to %d\n", @@ -908,6 +998,9 @@ again: if ((res > 0) && (((1 << res) & quiet_mask) == 0)) { switch(res) { case INFO_ERR_IMPL: + /* Give us a chance to try the older implementation. */ + if (implcode == IMPL_XNTPD) + break; (void) fprintf(stderr, "***Server implementation incompatable with our own\n"); break; @@ -949,7 +1042,7 @@ again: static void getcmds(void) { -#ifdef HAVE_LIBREADLINE +#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT) char *line; for (;;) { @@ -958,7 +1051,7 @@ getcmds(void) docmd(line); free(line); } -#else /* not HAVE_LIBREADLINE */ +#else /* not (HAVE_LIBREADLINE || HAVE_LIBEDIT) */ char line[MAXLINE]; for (;;) { @@ -975,10 +1068,11 @@ getcmds(void) docmd(line); } -#endif /* not HAVE_LIBREADLINE */ +#endif /* not HAVE_LIBREADLINE || HAVE_LIBEDIT */ } +#ifndef SYS_WINNT /* Under NT cannot handle SIGINT, WIN32 spawns a handler */ /* * abortcmd - catch interrupts and abort the current command */ @@ -994,7 +1088,7 @@ abortcmd( (void) fflush(stderr); if (jump) longjmp(interrupt_buf, 1); } - +#endif /* SYS_WINNT */ /* * docmd - decode the command line and execute a command @@ -1007,9 +1101,11 @@ docmd( char *tokens[1+MAXARGS+2]; struct parse pcmd; int ntok; - static int i; + int i, ti; + int rval; struct xcmd *xcmd; + ai_fam_templ = ai_fam_default; /* * Tokenize the command line. If nothing on it, return. */ @@ -1037,22 +1133,29 @@ docmd( */ pcmd.keyword = tokens[0]; pcmd.nargs = 0; - for (i = 0; i < MAXARGS && xcmd->arg[i] != NO; i++) { - if ((i+1) >= ntok) { + ti = 1; + for (i = 0; i < MAXARGS && xcmd->arg[i] != NO;) { + if ((i+ti) >= ntok) { if (!(xcmd->arg[i] & OPT)) { printusage(xcmd, stderr); return; } break; } - if ((xcmd->arg[i] & OPT) && (*tokens[i+1] == '>')) - break; - if (!getarg(tokens[i+1], (int)xcmd->arg[i], &pcmd.argval[i])) - return; + if ((xcmd->arg[i] & OPT) && (*tokens[i+ti] == '>')) + break; + rval = getarg(tokens[i+ti], (int)xcmd->arg[i], &pcmd.argval[i]); + if (rval == -1) { + ti++; + continue; + } + if (rval == 0) + return; pcmd.nargs++; + i++; } - i++; + i += ti; if (i < ntok && *tokens[i] == '>') { char *fname; @@ -1071,10 +1174,8 @@ docmd( perror(""); return; } - i = 1; /* flag we need a close */ } else { current_output = stdout; - i = 0; /* flag no close */ } if (interactive && setjmp(interrupt_buf)) { @@ -1083,7 +1184,9 @@ docmd( jump = 1; (xcmd->handler)(&pcmd, current_output); jump = 0; - if (i) (void) fclose(current_output); + if (current_output != stdout) + (void) fclose(current_output); + current_output = NULL; } } @@ -1187,8 +1290,12 @@ findcmd( } - /* +/* * getarg - interpret an argument token + * + * return: 0 - failure + * 1 - success + * -1 - skip to next token */ static int getarg( @@ -1206,7 +1313,14 @@ getarg( argp->string = str; break; case ADD: - if (!getnetnum(str, &(argp->netnum), (char *)0)) { + if (!strcmp("-6", str)) { + ai_fam_templ = AF_INET6; + return -1; + } else if (!strcmp("-4", str)) { + ai_fam_templ = AF_INET; + return -1; + } + if (!getnetnum(str, &(argp->netnum), (char *)0, 0)) { return 0; } break; @@ -1240,6 +1354,17 @@ getarg( argp->ival = -argp->ival; } break; + case IP_VERSION: + if (!strcmp("-6", str)) + argp->ival = 6 ; + else if (!strcmp("-4", str)) + argp->ival = 4 ; + else { + (void) fprintf(stderr, + "***Version must be either 4 or 6\n"); + return 0; + } + break; } return 1; @@ -1253,24 +1378,36 @@ getarg( static int getnetnum( const char *hname, - u_int32 *num, - char *fullhost + struct sockaddr_storage *num, + char *fullhost, + int af ) { - struct hostent *hp; - + int err; + int sockaddr_len; + struct addrinfo hints, *ai = NULL; + + sockaddr_len = (af == AF_INET) + ? sizeof(struct sockaddr_in) + : sizeof(struct sockaddr_in6); + memset((char *)&hints, 0, sizeof(struct addrinfo)); + hints.ai_flags = AI_CANONNAME; +#ifdef AI_ADDRCONFIG + hints.ai_flags |= AI_ADDRCONFIG; +#endif + + /* decodenetnum only works with addresses */ if (decodenetnum(hname, num)) { if (fullhost != 0) { - (void) sprintf(fullhost, - "%u.%u.%u.%u", (u_int)((htonl(*num)>>24)&0xff), - (u_int)((htonl(*num)>>16)&0xff), (u_int)((htonl(*num)>>8)&0xff), - (u_int)(htonl(*num)&0xff)); + getnameinfo((struct sockaddr *)num, sockaddr_len, + fullhost, sizeof(fullhost), NULL, 0, + NI_NUMERICHOST); } return 1; - } else if ((hp = gethostbyname(hname)) != 0) { - memmove((char *)num, hp->h_addr, sizeof(u_int32)); + } else if ((err = getaddrinfo(hname, "ntp", &hints, &ai)) == 0) { + memmove((char *)num, ai->ai_addr, ai->ai_addrlen); if (fullhost != 0) - (void) strcpy(fullhost, hp->h_name); + (void) strcpy(fullhost, ai->ai_canonname); return 1; } else { (void) fprintf(stderr, "***Can't find host %s\n", hname); @@ -1285,14 +1422,15 @@ getnetnum( */ char * nntohost( - u_int32 netnum + struct sockaddr_storage *netnum ) { if (!showhostnames) - return numtoa(netnum); - if ((ntohl(netnum) & REFCLOCK_MASK) == REFCLOCK_ADDR) - return refnumtoa(netnum); - return numtohost(netnum); + return stoa(netnum); + + if ((netnum->ss_family == AF_INET) && ISREFCLOCKADR(netnum)) + return refnumtoa(netnum); + return socktohost(netnum); } @@ -1380,8 +1518,8 @@ helpsort( const void *t2 ) { - const char **name1 = (const char **)t1; - const char **name2 = (const char **)t2; + char const * const * name1 = (char const * const *)t1; + char const * const * name2 = (char const * const *)t2; return strcmp(*name1, *name2); } @@ -1406,10 +1544,15 @@ printusage( FILE *fp ) { - register int i; + int i, opt46; + opt46 = 0; (void) fprintf(fp, "usage: %s", xcp->keyword); for (i = 0; i < MAXARGS && xcp->arg[i] != NO; i++) { + if (opt46 == 0 && (xcp->arg[i] & ~OPT) == ADD) { + (void) fprintf(fp, " [ -4|-6 ]"); + opt46 = 1; + } if (xcp->arg[i] & OPT) (void) fprintf(fp, " [ %s ]", xcp->desc[i]); else @@ -1484,12 +1627,33 @@ host( FILE *fp ) { + int i; + if (pcmd->nargs == 0) { if (havehost) (void) fprintf(fp, "current host is %s\n", currenthost); else (void) fprintf(fp, "no current host\n"); - } else if (openhost(pcmd->argval[0].string)) { + return; + } + + i = 0; + if (pcmd->nargs == 2) { + if (!strcmp("-4", pcmd->argval[i].string)) + ai_fam_templ = AF_INET; + else if (!strcmp("-6", pcmd->argval[i].string)) + ai_fam_templ = AF_INET6; + else { + if (havehost) + (void) fprintf(fp, + "current host remains %s\n", currenthost); + else + (void) fprintf(fp, "still no current host\n"); + return; + } + i = 1; + } + if (openhost(pcmd->argval[i].string)) { (void) fprintf(fp, "current host set to %s\n", currenthost); } else { if (havehost) @@ -1532,7 +1696,7 @@ keytype( { if (pcmd->nargs == 0) fprintf(fp, "keytype is %s\n", - (info_auth_keytype == KEY_TYPE_MD5) ? "MD5" : "DES"); + (info_auth_keytype == KEY_TYPE_MD5) ? "MD5" : "???"); else switch (*(pcmd->argval[0].string)) { case 'm': @@ -1540,13 +1704,8 @@ keytype( info_auth_keytype = KEY_TYPE_MD5; break; - case 'd': - case 'D': - info_auth_keytype = KEY_TYPE_DES; - break; - default: - fprintf(fp, "keytype must be 'md5' or 'des'\n"); + fprintf(fp, "keytype must be 'md5'\n"); } } @@ -1576,10 +1735,7 @@ passwd( (u_char *)pcmd->argval[0].string); authtrust(info_auth_keyid, 1); } else { - pass = getpass((info_auth_keytype == KEY_TYPE_DES) - ? "DES Password: " - : "MD5 Password: " - ); + pass = getpass("MD5 Password: "); if (*pass == '\0') (void) fprintf(fp, "Password unchanged\n"); else { @@ -1729,7 +1885,7 @@ getkeyid( fprintf(stderr, "%s", keyprompt); fflush(stderr); for (p=pbuf; (c = getc(fi))!='\n' && c!=EOF;) { if (p < &pbuf[18]) - *p++ = c; + *p++ = (char) c; } *p = '\0'; if (fi != stdin) |