git: 030c387f5d74 - main - tzsetup: correct timezone symlink target

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Mon, 30 Sep 2024 14:22:56 UTC
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=030c387f5d74a66d0d5950e3450d6da24237fb2e

commit 030c387f5d74a66d0d5950e3450d6da24237fb2e
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2024-09-21 11:13:27 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-09-30 14:22:34 +0000

    tzsetup: correct timezone symlink target
    
    In chroot mode tzsetup prepended the chroot path to the symlink target,
    which is not correct.  Use the same path for the symlink regardless of
    chroot mode.
    
    PR:             281332
    Reported by:    scf, Herbert J. Skuhra
    Reviewed by:    olce
    Fixes: 5e16809c953f ("tzsetup: symlink /etc/localtime instead of co...")
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D46725
---
 usr.sbin/tzsetup/tzsetup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/usr.sbin/tzsetup/tzsetup.c b/usr.sbin/tzsetup/tzsetup.c
index 617de4efb765..914eeb145a09 100644
--- a/usr.sbin/tzsetup/tzsetup.c
+++ b/usr.sbin/tzsetup/tzsetup.c
@@ -877,19 +877,19 @@ main(int argc, char **argv)
 		else
 			strlcpy(path_zonetab, dztpath, sizeof(path_zonetab));
 		strcpy(path_iso3166, _PATH_ISO3166);
-		strcpy(path_zoneinfo, _PATH_ZONEINFO);
 		strcpy(path_localtime, _PATH_LOCALTIME);
 		strcpy(path_db, _PATH_DB);
 		strcpy(path_wall_cmos_clock, _PATH_WALL_CMOS_CLOCK);
 	} else {
 		sprintf(path_zonetab, "%s/%s", chrootenv, _PATH_ZONETAB);
 		sprintf(path_iso3166, "%s/%s", chrootenv, _PATH_ISO3166);
-		sprintf(path_zoneinfo, "%s/%s", chrootenv, _PATH_ZONEINFO);
 		sprintf(path_localtime, "%s/%s", chrootenv, _PATH_LOCALTIME);
 		sprintf(path_db, "%s/%s", chrootenv, _PATH_DB);
 		sprintf(path_wall_cmos_clock, "%s/%s", chrootenv,
 		    _PATH_WALL_CMOS_CLOCK);
 	}
+	/* Symlink target is the same regardless of chroot */
+	strcpy(path_zoneinfo, _PATH_ZONEINFO);
 
 	/* Override the user-supplied umask. */
 	(void)umask(S_IWGRP | S_IWOTH);