HomeFreeBSD

tzcode: Limit TZ for setugid programs

Description

tzcode: Limit TZ for setugid programs

The zoneinfo parser can be told to read any file the program can access
by setting TZ to either an absolute path, or a path relative to the
zoneinfo directory. For setugid programs, we previously had a hack from
OpenBSD which rejects values of TZ deemed unsafe, but that was rather
arbitrary (anything containing a dot, for instance). Leverage openat()
with AT_RESOLVE_BENEATH instead.

For simplicity, move the TZ change detection code to after we've opened
the file, and stat the file descriptor rather than the name.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D52029

Details

Provenance
desAuthored on Aug 21 2025, 4:34 PM
Reviewer
jhb
Differential Revision
D52029: tzcode: Limit TZ for setugid programs
Parents
rGf5efc804294c: tzcode: Reduce diff to upstream
Branches
Unknown
Tags
Unknown