On 9/17/26 06:50, Dag-Erling Smørgrav wrote:
Paul Eggert via tz <[email protected]> writes:
* localtime.c (localtime): Add comment re difference from FreeBSD 15.1.
[...]
+               /* Omit "tzloadflags &= ~TZLOAD_FROMENV;" here, as that
+                  would hurt performance by rereading and reanalyzing the
+                  TZDEFAULT file even when it is unchanged.  */

This is not accurate.

What wording would you suggest to address inaccuracy in the comment?

TZLOAD_FROMENV was originally used to indicate that the value of `name`
came from the environment and should therefore be subject to additional
scrutiny.

When TZLOAD_FROMENV was originally introduced to tzcode in commit 6d77c92872c0dc5ee0d6189d77337882596768a3 (2024-12-09), it was set whenever the code used a timezone setting derived either from the TZ environment variable, or from the default fallback when TZ is unset. This can be seen by inspecting the source code of that commit, in the tzset_unlocked function. In contrast, TZLOAD_FROMENV was unset when the timezone setting came from the argument of the tzalloc function.

Today, TZLOAD_FROMENV has the same meaning that it did back then. This can be seen by inspecting today's tzset_unlocked function.

At some point between 2025a and 2025c, it was robbed of its original
meaning and turned into a flag that controls change detection.

In tzcode, TZLOAD_FROMENV was always intended to mean the timezone setting came from the environment or default fallback. What subsequent code did with that information was up to the subsequent code. Subsequent parts of 2024 tzcode used TZLOAD_FROMENV only in setuid programs, where it checked that a file with name derived from the environment (or default fallback) was a regular file and that the file was readable by the real user.

However, in later commits tzcode security was tightened, to check that the file was a regular file regardless of whether the program was setuid and regardless of whether its name came from the environment (or default fallback), and to check that the file was under /usr/share/zoneinfo/ in setuid programs regardless of whether its name came from the environment (or default fallback). This meant TZLOAD_FROMENV was no longer useful and indeed it was removed in commit 87abb1135ef7bd5d2e57041868ad9a135b9fa67d (2025-09-25).

However, even though TZLOAD_FROMENV's original meaning was no longer useful for security, it turned out that the original meaning was useful for change detection. So TZLOAD_FROMENV was brought back in commit 59ebd6afa671cc218d4198e58269202eff0a838e (2025-10-04), still with its original meaning, but now localtime.c used it to improve the performance of change detection for settings derived from the environment (or default fallback).

No explanation has ever been provided for the change in meaning of the
flag, or the loss of its original function,

I hope the above helps to explain why the flag still has its originally intended meaning.

The comment does not explain the purpose of the flag,

The TZLOAD_FROMENV flag's purpose is explained in the comment next to the flag's definition.

it just attacks FreeBSD

The comment does not mention FreeBSD. Although the commit message notes "Add comment re difference from FreeBSD", this was meant to say only that the two codebases differ.

you changed the meaning of this flag overnight
without warning or explanation

The flag still means what it originally meant in tzcode.

and then refused to help when I approached you about it

I've tried to explain localtime.c in some detail to be helpful, and I'm happy to continue clarifying code or comments where needed. If my emails have sounded sharp or dismissive, I apologize - that was not my intent.

Reply via email to