[Git][NTPsec/ntpsec][20L-Dec24-unholy] 10 commits: Remove shebang from pythonize-header

James Browning gitlab at mg.gitlab.com
Thu Dec 31 19:38:28 UTC 2020



James Browning pushed to branch 20L-Dec24-unholy at NTPsec / ntpsec


Commits:
946f212b by Richard Laager at 2020-12-27T15:30:53-06:00
Remove shebang from pythonize-header

This is run using an explicit interpreter by pylib/wscript:

    ctx(
        before=['pyc', 'pyo'],
        cwd=srcnode,
        rule='${PYTHON} ${SRC} >${TGT}',
        source=["../wafhelpers/pythonize-header", "../include/ntp.h"],
        target=target2,
    )

I also removed the execute bit.

- - - - -
152ca26e by Richard Laager at 2020-12-27T15:32:29-06:00
Remove shebang from tlscheck

This is run using an explicit interpreter from tests/option-tester.sh.

- - - - -
b7dcb972 by James Browning at 2020-12-31T12:49:22-06:00
ntpviz doc: Document comma as --datadir separator

Signed-off-by: Richard Laager <rlaager at wiktel.com>
[I changed the example syntax slightly.]

- - - - -
d8bd811a by James Browning at 2020-12-31T12:50:08-06:00
ntpviz doc: Remove stray backtick

Signed-off-by: Richard Laager <rlaager at wiktel.com>
[I split this from the previous commit.]

- - - - -
5b13095e by James Browning at 2020-12-31T11:37:21-08:00
Update some docs to reflect post 1.2.0 changes.




- - - - -
a02dd44f by James Browning at 2020-12-31T11:37:21-08:00
ntp.ntpc: Fix libntpc version checking.


- - - - -
2c771b33 by James Browning at 2020-12-31T11:37:21-08:00
ntpq: Do not crash on sysinfo. Use a bitvector as it should be.


- - - - -
f76af8b7 by James Browning at 2020-12-31T11:37:21-08:00
Remove --build-epoch and replace it with arbitrary --build-desc text.

Passing '--build-desc=$(date -u +%Y-%m-%dT%H:%M:%Sz)' restores the previous
default extended version.

The build epoch has been replaced with a hardcoded timestamp which will be
manually updated every nine years or so (approx 512w).  This makes the
binaries reproducible by default.
- - - - -
ec8fc06d by James Browning at 2020-12-31T11:37:21-08:00
test: pass output through polystr when writing build/main/test.log


- - - - -
c09978eb by James Browning at 2020-12-31T11:37:21-08:00
ntpviz: Do not explode but behave badly on --local-offset-multiplot.


- - - - -


14 changed files:

- NEWS.adoc
- devel/hacking.adoc
- docs/includes/ntpviz-body.adoc
- libntp/ntp_calendar.c
- ntpclients/ntpq.py
- ntpclients/ntpviz.py
- packaging/packaging.adoc
- pylib/ntpc.py
- pylib/util.py
- wafhelpers/options.py
- wafhelpers/pythonize-header
- wafhelpers/test.py
- wafhelpers/tlscheck.py
- wscript


Changes:

=====================================
NEWS.adoc
=====================================
@@ -12,6 +12,23 @@ on user-visible changes.
 
 == Repository Head ==
 
+Remove --build-epoch and replace it with arbitrary --build-desc text.
+Passing '--build-desc=$(date -u +%Y-%m-%dT%H:%M:%Sz)' restores the previous
+default extended version.
+
+The build epoch has been replaced with a hardcoded timestamp which will be
+manually updated every nine years or so (approx 512w).  This makes the
+binaries reproducible by default.
+
+Compare versions of ntp.ntpc and libntpc printing a warning is
+mismatched. Fix libntpc install path if using it.
+
+Reduce maxclocks to 5 to reduce the NTP pool load.
+
+Print LIBDIR during ./waf configure.
+
+Documentation, new GPG key, and miscellaneous cleanups.
+
 == 2020-10-06: 1.2.0 ==
 
 The minor version bump is to indicate official official support of
@@ -22,7 +39,7 @@ On this day in 1783, Benjamin Hanks received a patent for a
 self-winding clock he planned to install in the Old Dutch Church in
 Kingston, New York, supposedly making it the first public clock in
 what became the New York City metropolitan area.
- 
+
 NTS-KE client now defaults to port 4460.
 
 NTS-KE server now listens on port 4460.


=====================================
devel/hacking.adoc
=====================================
@@ -497,17 +497,13 @@ C was the minor.  They also use release-candidate suffixes.
 
 == Version string
 
-We use the BUILD_EPOCH as described in packaging/packaging.adoc for
-the timestamp (converted to RFC 3339 format) part of the version
-string reported in ntpd and other binaries.
-
 Release builds have version strings of the form:
 
-<base version number> <BUILD_EPOCH in RFC 3339 format>
+<base version number><trim()d --build-desc with a prepended space>
 
 Development builds have version strings of the form:
 
-<base version number>+ <BUILD_EPOCH in RFC 3339 format> (git rev <git shorthash>)
+<base version number>+<commits since last tag>-g<git short hash><conditional '-dirty'> <trim()d --build-desc with a prepended space>
 
 == Contribution workflow and conventions
 
@@ -812,6 +808,6 @@ cat > ~/.gitconfig
 ^D
 -------------------------------------------------------------
 
-. 
+.
 
 //end


=====================================
docs/includes/ntpviz-body.adoc
=====================================
@@ -7,14 +7,14 @@
 ntpviz [OPTIONS]
          [-c | --clip]
          [-D DLVL | --debug DLVL]
-         [-d LOGDIR]
+         [-d LOGDIR[,LOGDIR]...]
          [-e endtime]
          [-g | --general]
          [-h | --help]
          [-n NAME | --name NAME]
          [-N | --nice]
          [-o OUTDIR | --outdir OUTDIR]
-         [-p DAYS | --period DAYS`]
+         [-p DAYS | --period DAYS]
          [-s STARTTIME | --starttime STARTTIME]
          [-T TERMINAL | --terminal TERMINAL]
          [-V | --version]
@@ -51,7 +51,7 @@ subset of comparative plots for multiple directories.
     the plots to the data between 1% and 99%; this is useful for
     ignoring a few spikes in the data.
 
--d LOGDIR or --datadir LOGDIR::
+-d LOGDIR[,LOGDIR]... or --datadir LOGDIR[,LOGDIR]...::
     Specifies one or more logfile directories to examine; the default is
     the single directory /var/log/ntpstats.
 


=====================================
libntp/ntp_calendar.c
=====================================
@@ -38,7 +38,7 @@ ntpcal_get_build_date(
 	struct calendar * jd
 	)
 {
-        time_t epoch = (time_t)BUILD_EPOCH;
+        time_t epoch = (time_t)1577836800; // 2020 Jan 01 -> 1863820800 - 2029 Jan 23
         struct tm epoch_tm;
 
 	ZERO(*jd);


=====================================
ntpclients/ntpq.py
=====================================
@@ -70,7 +70,7 @@ class Ntpq(cmd.Cmd):
         #  so I am leaving them, and possibly duplicating them.
         self.rawmode = False            # Flag which indicates raw mode output.
         self.directmode = False         # Flag for direct MRU output.
-        self.showhostnames = 1          # If & 1 false, display numeric IPs
+        self.showhostnames = 1          # If & 1, display names
         self.showunits = False          # If False, show old style float
         self.auth_delay = 20            # delay time (default 20msec)
         self.wideremote = False         # show wide remote names?
@@ -441,7 +441,7 @@ usage: timeout [ msec ]
                 value = queried[name][0]
                 rawvalue = queried[name][1]
                 if fmt in (NTP_ADD, NTP_ADP):
-                    if self.showhostnames[0]:
+                    if self.showhostnames & 1:  # if & 1, display names 
                         if self.debug:
                             self.say("DNS lookup begins...")
                         value = ntp.util.canonicalize_dns(


=====================================
ntpclients/ntpviz.py
=====================================
@@ -1295,7 +1295,7 @@ def local_offset_multiplot(statlist):
     plot = NTPViz.Common + '''\
 set terminal %(terminal)s size %(size)s
 set title "Multiplot Local Clock Offsets"
-set ytics format "%1.2f μs" nomirror textcolor rgb "#0060ad"
+set ytics format "%%1.2f μs" nomirror textcolor rgb "#0060ad"
 set key bottom right box
 plot \\
 ''' % out
@@ -1311,7 +1311,7 @@ plot \\
     for stats in statlist:
         # speed up by only sending gnuplot the data it will actually use
         # fields: time, offset
-        pt = NTPViz.plot_slice(stats.loopstats, 2)
+        pt = stats.plot_slice(stats.loopstats, 2)
         plot_data += pt[0]
 
     ret = {'html': '', 'stats': []}


=====================================
packaging/packaging.adoc
=====================================
@@ -18,9 +18,9 @@ pool group of its own. This may change in the future.
 
 Many tools (actually, almost everything except the core daemon itself)
 have been moved from C to Python. This is an important step for
-improving maintainability and reducing attack surface.  However, we
-know that some platforms cannot support Python or choose not to
-include it in their core configuration.
+improving maintainability and reducing the attack surface.  However,
+we know that some platforms cannot support Python or choose not
+to include it in their core configuration.
 
 For these platforms, we recommend using cx_Freeze to render the NTPsec
 Python programs, and all their imported modules, into standalone files.
@@ -35,7 +35,7 @@ can install it with pip like this:
 
 ```
 pip install cx_Freeze
-````
+```
 
 You may find that you also need to install the package 'patchelf'.
 
@@ -58,54 +58,43 @@ binaries created by cx_freeze.
 
 == Hacking Python shebangs
 
-The shebang lines in our Python scripts point to "python".  Part of
-our standard tests check that you can change that to "python3" without
-breaking anything.
-
-We are aware that the Python 3 transition is well advanced.  We are
-also aware that PEP394 strongly urges all distributors to point
-'python' at Python 2.
+The shebang lines in our Python scripts point to the value of
+--pyshebang (default "python"). Part of our standard development tests
+check that you can change that to "python3" without breaking anything.
 
-This leaves us with a choice to either (a) change the shebangs to
-python3 ourselves, causing breakage to users stuck with Python 2
-and installing from source, or (b) not change them, leaving it up
-to distro maintainers to hack them in whatever way is appropriate for
-their distro's Python policy.
-
-We think the choice that minimizes overall pain, and directs it to
-the party best able to cope, is clear.  We choose (b).
+We are aware that the Python 3 transition is well advanced.  We are also
+aware that PEP394 strongly urges all distributors to point 'python' at
+Python 2.
 
 == Cross-era interoperability in modular calendar arithmetic
 
-The protocol necessarily uses time/date stamps of finite length in
-order to fit into fixed-size fields; they happen to have a 136-year
-cycle, but the problems this produces aren't dependent on the specific
-cycle length.  Thus, each instance of ntpd speaks time based on a
-specific epoch (cycle start date).  The epoch of era 0 was at the
-beginning of 1900; the epoch of era 1 will be in 2036.
+The protocol necessarily uses time/date stamps of finite length
+to fit into fixed-size fields; they happen to have a 136-year cycle, but
+the problems this produces aren't dependent on the specific cycle
+length.  Thus, each instance of ntpd speaks time based on a specific
+epoch (cycle start date).  The epoch of era 0 was at the beginning of
+1900; the epoch of era 1 will be in 2036.
 
 Two instances talking to each other have no way to know that they're
-based in the same era. To mitigate this problem, each instance
-has a pivot date and resolves incoming timestamps to the era that
-minimizes distance between now and the timestamp.  This procedure
-is part of the core protocol specification.
-
-An instance's pivot time is constructed from BUILD_EPOCH defined at
-configure time in config.h.  If BUILD_EPOCH is set to a known time
-then the binaries are reproducible.  By default the BUILD_EPOCH is the
-time when the last './waf configure' was run.  You can override the
-BUILD_EPOCH with './waf configure --build-epoch' or using the SOURCE_DATE_EPOCH
-environment variable.
+based in the same era. To mitigate this problem, each instance has a
+pivot date and resolves incoming timestamps to the era that minimizes
+the distance between now and the timestamp.  This procedure is part of the
+core protocol specification.
+
+An instance's pivot time is constructed from a hardcoded timestamp
+in the source code. This is also used to disambiguate the current
+GPS era. This number should be updated every nine years or so (approx
+512w). This should make the binaries reproducible.
 
 More information on reproducible builds is at:
 https://reproducible-builds.org/[https://reproducible-builds.org/]
 
 == Disambiguation of NMEA dates
 
-Due to bad design of NMEA0183, the reporting protocol used by many GPS
-sensors, the NMEA driver in NTPsec sometimes has to make an assumption
-about what century it is.  Choice of a base-century hits the same
-issues; so here the year derived from the BUILD_EPOCH is also used.  The
+Due to the bad design of NMEA0183, the reporting protocol used by many GPS
+sensors, the NMEA driver in NTPsec sometimes has to assume
+what century it is.  Choice of a base-century hits the same
+issues, so here the year derived from a hardcoded timestamp. The
 alternative - trusting the system clock to report the right century -
 could produce very bad behavior near century boundaries, and also on
 cold-start of systems without an RTC.


=====================================
pylib/ntpc.py
=====================================
@@ -44,9 +44,9 @@ def _dlo(paths):
         try:
             lib = ctypes.CDLL(ntpc_path, use_errno=True)
             wrap_version = "@NTPSEC_VERSION_EXTENDED@"
-            clib_version = ctypes.c_char_p.in_dll(lib, 'version').value
+            clib_version = ntp.poly.polystr(ctypes.c_char_p.in_dll(lib, 'version').value)
             if clib_version != wrap_version:
-                sys.stderr.write("ntp.ntpc wrong version %s !== %s" % (clib_version, wrap_version))
+                sys.stderr.write("ntp.ntpc wrong version '%s' != '%s'\n" % (clib_version, wrap_version))
             return lib
         except OSError:
             pass


=====================================
pylib/util.py
=====================================
@@ -1233,7 +1233,7 @@ class MRUSummary:
         self.debug = debug
         self.logfp = logfp
         self.now = None
-        self.showhostnames = showhostnames  # If not [0], display numeric IPs
+        self.showhostnames = showhostnames  # if & 1, display names 
         self.wideremote = wideremote
 
     header = " lstint avgint rstr r m v  count    score   drop rport remote address"
@@ -1269,7 +1269,7 @@ class MRUSummary:
             rscode = '.'
         (ip, port) = portsplit(entry.addr)
         try:
-            if not self.showhostnames & 1:
+            if not self.showhostnames & 1:  # if not & 1 display numeric IPs
                 dns = ip
             else:
                 dns = canonicalize_dns(ip)


=====================================
wafhelpers/options.py
=====================================
@@ -67,8 +67,8 @@ ext, ffi, or none. defaults to ffi.""", nargs=1)
     grp.add_option('--cflags', type='string', action="callback",
                    callback=callback_flags,
                    help="Users should use CFLAGS in their environment.")
-    grp.add_option('--build-epoch', type='int', default=None,
-                   help="Force epoch, or use SOURCE_DATE_EPOCH in environment")
+    grp.add_option('--build-desc', type='string', default="",
+                   help="Arbitrary text string to append to extended version.")
     grp.add_option('--ldflags', type='string', action="callback",
                    callback=callback_flags,
                    help="Users should use LDFLAGS in their environment.")


=====================================
wafhelpers/pythonize-header
=====================================
@@ -1,4 +1,3 @@
-#! /usr/bin/env python
 # -*- coding: utf-8 -*-
 """
 Generate a Python module from a C file of macro definitions.


=====================================
wafhelpers/test.py
=====================================
@@ -1,6 +1,7 @@
 from __future__ import print_function
 
 from waflib.Logs import pprint
+from pylib.poly import polystr
 
 
 def test_write_log(ctx):
@@ -16,9 +17,9 @@ def test_write_log(ctx):
             fp.write("BINARY      : %s\n" % binary)
             fp.write("RETURN VALUE: %s\n" % retval)
             fp.write("\n*** stdout ***\n")
-            fp.write(str(lines))
+            fp.write(polystr(lines))
             fp.write("\n*** stderr ***\n")
-            fp.write(str(error))
+            fp.write(polystr(error))
             fp.write("\n\n\n")
 
     pprint("BLUE", "Wrote test log to: ", file_out)


=====================================
wafhelpers/tlscheck.py
=====================================
@@ -1,5 +1,3 @@
-#! /usr/bin/env python
-
 """tlscheck - Helper for checking SSL library bits."""
 import ctypes
 import ctypes.util


=====================================
wscript
=====================================
@@ -173,40 +173,23 @@ def configure(ctx):
     if os.path.exists(".git"):
         ctx.find_program("git", var="BIN_GIT", mandatory=False)
 
-    source_date_epoch = os.getenv('SOURCE_DATE_EPOCH', None)
-    if ctx.options.build_epoch is not None:
-        build_epoch = ctx.options.build_epoch
-        ctx.define("BUILD_EPOCH", build_epoch, comment="Using --build-epoch")
-    elif source_date_epoch:
-        if not source_date_epoch.isdigit():
-            ctx.fatal("ERROR: malformed SOURCE_DATE_EPOCH")
-        build_epoch = int(source_date_epoch)
-        ctx.define("BUILD_EPOCH", build_epoch,
-                   comment="Using SOURCE_DATE_EPOCH")
-    elif ctx.env.BIN_GIT:
-        cmd = ctx.env.BIN_GIT + shlex.split("log -1 --pretty=%ct")
-        build_epoch = int(ctx.cmd_and_log(cmd).strip())
-        ctx.define("BUILD_EPOCH", build_epoch, comment="last git commit")
-    else:
-        build_epoch = int(time.time())
-        ctx.define("BUILD_EPOCH", build_epoch, comment="Using default")
-
-    build_epoch_formatted = datetime.utcfromtimestamp(build_epoch).strftime(
-        "%Y-%m-%dT%H:%M:%SZ")
+    build_desc = ctx.options.build_desc.strip()
+    if build_desc:
+        build_desc = ' ' + build_desc
     if ctx.env.BIN_GIT:
         cmd = ctx.env.BIN_GIT + shlex.split("describe --dirty")
         git_short_hash = ctx.cmd_and_log(cmd).strip()
         git_short_hash = '-'.join(git_short_hash.split('-')[1:])
 
         ctx.env.NTPSEC_VERSION = "%s+" % ntpsec_release
-        ctx.env.NTPSEC_VERSION_EXTENDED = ("%s+%s %s" %
+        ctx.env.NTPSEC_VERSION_EXTENDED = ("%s+%s%s" %
                                            (ntpsec_release,
                                             git_short_hash,
-                                            build_epoch_formatted))
+                                            build_desc))
     else:
         ctx.env.NTPSEC_VERSION = "%s" % ntpsec_release
-        ctx.env.NTPSEC_VERSION_EXTENDED = ("%s %s" % (ntpsec_release,
-                                                      build_epoch_formatted))
+        ctx.env.NTPSEC_VERSION_EXTENDED = ("%s%s" % (ntpsec_release,
+                                                      build_desc))
     ctx.define("NTPSEC_VERSION", ctx.env.NTPSEC_VERSION)
     ctx.define("NTPSEC_VERSION_EXTENDED", ctx.env.NTPSEC_VERSION_EXTENDED)
 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/77c7b3f6cf07cb385de7fcd3e621dd9e1c36a257...c09978ebd79327ba2a30a6bce4cb7029e72a7c83

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/77c7b3f6cf07cb385de7fcd3e621dd9e1c36a257...c09978ebd79327ba2a30a6bce4cb7029e72a7c83
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20201231/0e2f299b/attachment-0001.htm>


More information about the vc mailing list