[Git][NTPsec/ntpsec][master] 2 commits: Do dropped stitch in fix of GitLab issue #65.

Eric S. Raymond gitlab at mg.gitlab.com
Sat Jun 4 09:23:21 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
ffa29c0c by Eric S. Raymond at 2016-06-04T05:23:01-04:00
Do dropped stitch in fix of GitLab issue #65.

- - - - -
44652aae by Eric S. Raymond at 2016-06-04T05:23:01-04:00
Regularize handlings of help options and invalid options.

Also, fully update the documentation on changes from Classic to be complete
in this area.

- - - - -


6 changed files:

- docs/includes/ntpd-body.txt
- docs/includes/ntpdig-body.txt
- docs/index.txt
- ntpd/ntpd.c
- ntpdig/main.c
- ntpq/ntpq.c


Changes:

=====================================
docs/includes/ntpd-body.txt
=====================================
--- a/docs/includes/ntpd-body.txt
+++ b/docs/includes/ntpd-body.txt
@@ -128,7 +128,7 @@ used with the +-q+ and +-x+ options. See the _tinker_ configuration
 file directive for other options.
 
 +-h+, +--help+::
-  Print a usage message summarizing options end exit.
+  Print a usage message summarizing options and exit.
 
 +-G+, +--force-step-once+::
   Step any initial offset correction..


=====================================
docs/includes/ntpdig-body.txt
=====================================
--- a/docs/includes/ntpdig-body.txt
+++ b/docs/includes/ntpdig-body.txt
@@ -58,9 +58,8 @@ reports whether ntpdig adjusted the time.
 
 == OPTIONS ==
 
-//+-?, --help+::
-//  displays usage information. The short form typically requires shell
-//  quoting, such as +-\?+, otherwise +?+ is consumed by the shell.
++-h, --help+::
+  Displays usage information and exits.
 
 +-4+, +--ipv4+::
   Force IPv4 DNS name resolution. This option must not appear in


=====================================
docs/index.txt
=====================================
--- a/docs/index.txt
+++ b/docs/index.txt
@@ -107,18 +107,26 @@ few will be user-visible:
 * The +sntp+ program has been renamed +{ntpdig}+ in order to make
   NTP installables have a uniform name prefix and take up less
   namespace. Also, +ntp-keygen+ is now +{ntpkeygen}+, +ntp-wait+
-  is {ntpwait}, and +update-leap+ is now +ntpleapfetch+.
+  is {ntpwait}, and +update-leap+ is now +{ntpleapfetch}+.
 
 * A new utility, {ntpfrob}, collects several small diagnostic functions
   for reading and tweaking the local clock hardware, including reading
   the clock tick rate, precision, and jitter. Part of it formerly
   traveled as +tickadj+.
 
-* The deprecated ntpdate program has been replaced with a shell
-  wrapper around {ntpdig}.
+* The deprecated and vulnerability-prone ntpdate program has been
+  replaced with a shell wrapper around {ntpdig}.  Its -e and -p
+  options are not implemented. It is no longer documented, but can be
+  found in the util/ directory of the source distribution.
 
 * Log timestamps look a little different; they are now in ISO8601 format.
 
+* The -!m, ->, and -< options of some Classic commands are not
+  supported.  (The argument-parsing framework code that implemented
+  them in Classic was overcomplicated and buggy and had to be removed.)
+
+* The shortname of --help options is now -h, not -?
+
 * As noted above, Autokey is not supported; that code has been removed.
 
 [[platforms]]


=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -242,7 +242,7 @@ static void ntpd_usage(void)
     P("				- may appear multiple times\n");
     P("   -x no  slew           Slew up to 600 seconds\n");
     P("   -V no  version        Output version information and exit\n");
-    P("   -? no  help           Display extended usage information and exit\n");
+    P("   -h no  help           Display extended usage information and exit\n");
 #undef P
 }
 
@@ -304,7 +304,6 @@ parse_cmdline_opts(
 	    case 'h':
 		ntpd_usage();
 		exit(0);
-		break;
 	    case 'i':
 #ifdef ENABLE_DROPROOT
 		droproot = true;
@@ -450,8 +449,10 @@ parse_cmdline_opts(
 	    case 'Z':
 		/* defer */
 		break;
-	    default :
-		break;
+	    default:
+		fputs("Unknown command line switch or missing argument.\n", stderr);
+		ntpd_usage();
+		exit(1);
 	    } /*switch*/
 	}
 


=====================================
ntpdig/main.c
=====================================
--- a/ntpdig/main.c
+++ b/ntpdig/main.c
@@ -119,7 +119,7 @@ int  gettimeofday_cached(struct event_base *b, struct timeval *tv);
 
 #define EXIT_SOFTWARE	70
 
-#define ALL_OPTIONS "46a:b:c:dD:g:jK:k:l:M:o:rSst:VwW"
+#define ALL_OPTIONS "46a:b:c:dD:g:hjK:k:l:M:o:rSst:VwW"
 static const struct option longoptions[] = {
     { "ipv4",		    0, 0, '4' },
     { "ipv6",		    0, 0, '6' },
@@ -129,6 +129,7 @@ static const struct option longoptions[] = {
     { "debug",		    0, 0, 'd' },
     { "set-debug-level",    1, 0, 'D' },
     { "gap",                1, 0, 'g' },
+    { "help",               9, 0, 'h' },
     { "kod",                1, 0, 'K' },
     { "json",               1, 0, 'j' },
     { "keyfile",            1, 0, 'k' },
@@ -161,6 +162,37 @@ static bool opt_step =false, opt_slew = false;
 static float opt_timeout = 5.0;
 static int opt_wait = false;
 
+static void ntpdig_usage(void)
+{
+#define P(x)	fputs(x, stderr)
+    P("USAGE:  sntp [ -<flag> [<val>] | --<name>[{=| }<val>] ]...");
+    P("		[ hostname-or-IP ...]");
+    P("  Flg Arg Option-Name    Description");
+    P("   -4 no  ipv4           Force IPv4 DNS name resolution");
+    P("				- prohibits the option 'ipv6'");
+    P("   -6 no  ipv6           Force IPv6 DNS name resolution");
+    P("				- prohibits the option 'ipv4'");
+    P("   -d no  normalverbose  Normal verbose");
+    P("   -K Str kod            KoD history filename");
+    P("   -p no  syslog         Logging with syslog");
+    P("				- prohibits the option 'logfile'");
+    P("   -l Str logfile        Log to specified logfile");
+    P("				- prohibits the option 'syslog'");
+    P("   -s no  settod         Set (step) the time with settimeofday()");
+    P("				- prohibits the option 'adjtime'");
+    P("   -j no  adjtime        Set (slew) the time with adjtime()");
+    P("				- prohibits the option 'settod'");
+    P("   -b Str broadcast      Use broadcasts to the address specified for synchronisation");
+    P("   -t Num timeout        Specify seconds to wait for broadcasts");
+    P("   -a Num authentication Enable authentication with the numbered key");
+    P("   -k Str keyfile        Specify a keyfile. SNTP will look in this file");
+    P("                         for the key specified with -a");
+    P("   -V no version         Output version information and exit");
+    P("   -h no  help           Display extended usage information and exit");
+#undef P
+}
+
+
 /*
  * The actual main function.
  */
@@ -222,6 +254,9 @@ ntpdig_main (
 			exit(1);
 		}
 		break;
+	    case 'h':
+		ntpdig_usage();
+		exit(0);
 	    case 'j':
 		opt_json = true;
 		syslogit = false;
@@ -264,7 +299,10 @@ ntpdig_main (
 		opt_wait = false;
 		break;
 	    default :
-		break;
+		/* chars not in table get converted to ? */
+		fputs("Unknown command line switch or missing argument.\n", stderr);
+		ntpdig_usage();
+		exit(1);
 	    } /*switch*/
 	}
 


=====================================
ntpq/ntpq.c
=====================================
--- a/ntpq/ntpq.c
+++ b/ntpq/ntpq.c
@@ -404,7 +404,7 @@ void clear_globals(void)
 #endif /* !BUILD_AS_LIB */
 #endif /* NO_MAIN_ALLOWED */
 
-#define ALL_OPTIONS "46c:dD:inOpVw"
+#define ALL_OPTIONS "46c:dhD:inOpVw"
 static const struct option longoptions[] = {
     { "ipv4",		    0, 0, '4' },
     { "ipv6",		    0, 0, '6' },
@@ -577,7 +577,7 @@ ntpqmain(
 			break;
 		    default:
 			/* chars not in table get converted to ? */
-			printf("Unknown command line switch or missing argument.\n");
+			fputs("Unknown command line switch or missing argument.\n", stderr);
 			ntpq_usage();
 			exit(1);
 		    } /*switch*/



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/56263531988b9ce09878ea65aae18eea781e6c09...44652aae159b465509cde297b45aac906e79ee32
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160604/939b10f9/attachment.html>


More information about the vc mailing list