rpki-client: POSIX compliant TZ variable

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

rpki-client: POSIX compliant TZ variable

Mathias
Hello.

Below is a patch for changing "UTC" into "UTC0" for TZ assignments.
The former is not POSIX compliant. From /usr/src/lib/libc/time/Theory:

        The POSIX TZ string takes the following form:

                stdoffset[dst[offset],date[/time],date[/time]]

        where:

        std and dst
                are 3 or more characters specifying the standard
                and daylight saving time (DST) zone names.
                Starting with POSIX.1-2001, std and dst may also be
                in a quoted form like "<UTC+10>"; this allows
                "+" and "-" in the names.
        offset
                is of the form `[-]hh:[mm[:ss]]' and specifies the
                                     ^
                    [This is wrong, the colon is optional in POSIX docs]

                offset west of UTC.  The default DST offset is one hour
                ahead of standard time.

While it makes no difference on OpenBSD, rpki-client-portable pulls from
the OpenBSD tree. There are no other portable OpenBSD subprojects that
need this change from what I could find.

Also, it might be a good idea to check for time() and setenv() errors in
these files.

Index: output-json.c
===================================================================
RCS file: /cvs/src/usr.sbin/rpki-client/output-json.c,v
retrieving revision 1.13
diff -u -p -r1.13 output-json.c
--- output-json.c 12 Sep 2020 15:46:48 -0000 1.13
+++ output-json.c 16 Sep 2020 07:00:00 -0000
@@ -30,7 +30,7 @@ outputheader_json(FILE *out, struct stat
  time_t t;
 
  time(&t);
- setenv("TZ", "UTC", 1);
+ setenv("TZ", "UTC0", 1);
  tp = localtime(&t);
  strftime(tbuf, sizeof tbuf, "%FT%TZ", tp);
 
Index: output.c
===================================================================
RCS file: /cvs/src/usr.sbin/rpki-client/output.c,v
retrieving revision 1.17
diff -u -p -r1.17 output.c
--- output.c 12 Sep 2020 15:46:48 -0000 1.17
+++ output.c 16 Sep 2020 07:00:00 -0000
@@ -177,7 +177,7 @@ outputheader(FILE *out, struct stats *st
  time_t t;
 
  time(&t);
- setenv("TZ", "UTC", 1);
+ setenv("TZ", "UTC0", 1);
  tp = localtime(&t);
  strftime(tbuf, sizeof tbuf, "%a %b %e %H:%M:%S %Z %Y", tp);