Skip to content

system.timezone does not observe /etc/timezone #636

Description

@haribo

Part of #634.

system.timezone's apply writes two things:

ln -sf "/usr/share/zoneinfo/$zone" /etc/localtime
printf '%s\n' "$zone" > /etc/timezone

Its observe reads one:

readlink -f /etc/localtime | sed 's#^/usr/share/zoneinfo/##'

A host whose /etc/localtime is right and whose /etc/timezone is wrong — or missing — is
reported converged, and the file stays wrong. That file is what dpkg-reconfigure tzdata,
tzupdate and several distro tools read, so it is not decorative.

The def already carries a note about why it observes the link rather than date +%Z
(seasonal abbreviations). It says nothing about the second file.

Build

Observe both, or stop writing the second one. Observing both is the smaller claim and
matches the apply: state(zone: <link>, recorded: <file contents>).

Worth settling in passing: on a host where /etc/timezone does not exist at all (not every
distribution ships it), writing it is either right or noise — the def's comment about
dpkg-reconfigure suggests Debian is the assumption, and this is a good place to say so.

Validation

  • An adverse case: correct link, /etc/timezone holding another zone, then the def, then
    assert the file's contents on the machine. Red first.
  • coverage.shellf's existing call still converges on a second run.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugdefect or malfunction

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions