From: Harlan Stenn Date: Mon, 6 Dec 2004 02:06:26 +0000 (-0500) Subject: [Bug 357] Fixed and additional improvements from Dave Mills X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fb9fa62b0bc81951bfb95501fae3e9fdd3d25fe8;p=thirdparty%2Fntp.git [Bug 357] Fixed and additional improvements from Dave Mills bk: 41b3bea2Ir5c_uhXmTn3v2UmPqiLsA --- diff --git a/include/ntpd.h b/include/ntpd.h index 3c66f9161c..f2444f883d 100644 --- a/include/ntpd.h +++ b/include/ntpd.h @@ -220,7 +220,7 @@ extern int sock_hash P((struct sockaddr_storage *)); /* ntp_config.c */ extern char const * progname; -extern char sys_phone[][MAXDIAL]; /* ACTS phone numbers */ +extern char *sys_phone[]; /* ACTS phone numbers */ #if defined(HAVE_SCHED_SETSCHEDULER) extern int config_priority_override; extern int config_priority; diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index 8f657868cc..169881eb37 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -309,7 +309,7 @@ static struct masks logcfg_item[] = { */ #define MAXTOKENS 20 /* 20 tokens on line */ #define MAXLINE 1024 /* maximum length of line */ -#define MAXPHONE 5 /* maximum number of phone strings */ +#define MAXPHONE 10 /* maximum number of phone strings */ #define MAXPPS 20 /* maximum length of PPS device string */ #define MAXINCLUDELEVEL 5 /* maximum include file levels */ @@ -340,7 +340,7 @@ static char res_file[MAX_PATH]; * Definitions of things either imported from or exported to outside */ char const *progname; -char sys_phone[MAXPHONE][MAXDIAL]; /* ACTS phone numbers */ +char *sys_phone[MAXPHONE] = {NULL}; /* ACTS phone numbers */ char *keysdir = NTP_KEYSDIR; /* crypto keys directory */ #if defined(HAVE_SCHED_SETSCHEDULER) int config_priority_override = 0; @@ -528,7 +528,6 @@ getconfig( #endif /* SYS_WINNT */ progname = argv[0]; res_fp = NULL; - memset((char *)sys_phone, 0, sizeof(sys_phone)); ntp_syslogmask = NLOG_SYNCMASK; /* set more via logconfig */ /* @@ -1761,11 +1760,12 @@ getconfig( break; case CONFIG_PHONE: - for (i = 1; i < ntokens && i < MAXPHONE; i++) { - (void)strncpy(sys_phone[i - 1], - tokens[i], MAXDIAL); + for (i = 1; i < ntokens && i < MAXPHONE - 1; i++) { + sys_phone[i - 1] = + emalloc(strlen(tokens[i]) + 1); + strcpy(sys_phone[i - 1], tokens[i]); } - sys_phone[i - 1][0] = '\0'; + sys_phone[i] = NULL; break; case CONFIG_ADJ: { diff --git a/ntpd/refclock_acts.c b/ntpd/refclock_acts.c index addf87bfd0..a0b0039458 100644 --- a/ntpd/refclock_acts.c +++ b/ntpd/refclock_acts.c @@ -37,13 +37,14 @@ * * The calling program is initiated by setting fudge flag1, either * manually or automatically. When flag1 is set, the calling program - * dials each number listed in the phones command of the configuration - * file in turn. The number is specified by the Hayes ATDT prefix - * followed by the number itself, including the prefix and long-distance - * digits and delay code, if necessary. The flag1 is reset and the - * calling program terminated if (a) a valid clock update has been - * determined, (b) no more numbers remain in the list, (c) a device - * fault or timeout occurs or (d) fudge flag1 is reset manually. + * dials the first number in the phone command of the configuration + * file. If that call fails, the calling program dials the second number + * and so on. The number is specified by the Hayes ATDT prefix followed + * by the number itself, including the prefix and long-distance digits + * and delay code, if necessary. The flag1 is reset and the calling + * program terminated if (a) a valid clock update has been determined, + * (b) no more numbers remain in the list, (c) a device fault or timeout + * occurs or (d) fudge flag1 is reset manually. * * The driver is transparent to each of the modem time services and * Spectracom radios. It selects the parsing algorithm depending on the @@ -385,7 +386,7 @@ acts_message( /* * We are waiting for the OK response to the modem setup - * command. When this happens dial the number. + * command. When this happens dial the number followed by a \r. */ case S_OK: if (strcmp(pp->a_lastcode, "OK") != 0) { @@ -406,6 +407,7 @@ acts_message( acts_disc(peer); return; } + write(pp->io.fd, "\r", 1); up->state = S_CONNECT; up->timer = ANSWER; return; @@ -437,7 +439,7 @@ acts_message( /* * For USNO format on-time character '*', which is on a line by - * itself. By sure a timecode has been received. + * itself. Be sure a timecode has been received. */ case 1: if (*pp->a_lastcode == '*' && up->state == S_MSG)