From owner-freebsd-current@FreeBSD.ORG Wed Feb 4 02:11:04 2015 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 66E68CCB; Wed, 4 Feb 2015 02:11:04 +0000 (UTC) Received: from anubis.delphij.net (anubis.delphij.net [IPv6:2001:470:1:117::25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "anubis.delphij.net", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BC9E2AE; Wed, 4 Feb 2015 02:11:04 +0000 (UTC) Received: from zeta.ixsystems.com (unknown [12.229.62.2]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by anubis.delphij.net (Postfix) with ESMTPSA id 3D8572C0B; Tue, 3 Feb 2015 18:11:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=delphij.net; s=anubis; t=1423015863; x=1423030263; bh=DhfDeQ91bYpr9U8b1UdIoEnish7b0D2EAKhOMZPmMVs=; h=Date:From:Reply-To:To:CC:Subject:References:In-Reply-To; b=uUgWK9sXhgGOW2Yr40waAUzpe4bfYVzeM+OlajgbKLLDjqtbBBbtyn95ysOQP8rRL BZaIKGrwcj+e34d5wc+Lb7bxDzxIHMRuvFj3DSUGfc4lSVTOXFdZjnkB9BhttnEx79 gStTACGD0VZXCkRtmjDIVkfpuB/KPv5ce8VVAOmo= Message-ID: <54D17FB6.1080400@delphij.net> Date: Tue, 03 Feb 2015 18:11:02 -0800 From: Xin Li Reply-To: d@delphij.net Organization: The FreeBSD Project MIME-Version: 1.0 To: Nick Frampton , freebsd-current@freebsd.org Subject: Re: tzsetup chroot References: <54D1704B.8050900@akips.com> In-Reply-To: <54D1704B.8050900@akips.com> Content-Type: multipart/mixed; boundary="------------050606050705040702090400" Cc: edwin@FreeBSD.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Feb 2015 02:11:04 -0000 This is a multi-part message in MIME format. --------------050606050705040702090400 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On 02/03/15 17:05, Nick Frampton wrote: > We have our own FreeBSD 10.1 installation script in which we call > tzsetup. > > I'm seeing different behaviour in tzsetup between these two > invocations: > > tzsetup -C /mnt chroot /mnt /usr/sbin/tzsetup > > With the -C option, no matter which time zone I select, it asks: > > Does the abbreviation 'UTC' look reasonable? > > Using chroot, I get the expected behaviour, e.g. selecting > America/New_York: > > Does the abbreviation 'EST' look reasonable? > > /mnt contains the contents of base.txz, so it looks like all the > zoneinfo files are there. Could you please submit a bug ticket for this? It looks like what happens is that tzsetup does not really do a chroot(2) system call. Instead, it simulated the effect by prefixing all paths with the chroot environment. The problem is that when tzsetup is going to verify your configuration, it would use tzset(3), which does not respect the simulated chroot effect. When no zoneinfo data is present, everything would be considered as UTC. Attached is an dirty hack (ugly enough that I don't wish to commit) that changes tzsetup to use chroot instead, which should fix the problem. I'm not very satisfied with it as it does chroot() before doing init_dialog, which may well fail as the devfs is not necessarily mounted in the chroot, and on the other hand all termcap related data would be sourced from the chroot, which is probably an undesirable side effect. Cheers, - -- Xin LI https://www.delphij.net/ FreeBSD - The Power to Serve! Live free or die -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.1.1 (FreeBSD) iQIcBAEBCgAGBQJU0X+zAAoJEJW2GBstM+nsfpwQAIwPBj11lzJS662RPBPQR6dB vb3gCGJjqRANCD+Sr8EqxzPlKOcC4UiBB5Khy39lidC+d4qgGQ3Mz3qIwjCdl3Aw KUzkFfhvspGzE25tIwsPJ3A00NjXNJGqGqcDMitfls4SdYZWzCgs+gwa3zGq+yO3 /pPMQVVhhBz2pgkqxCtznFqY9paN5lzwaOqp9HepNz1g99Q4u+KpIUI93BMcMdMD 9HtY7YQYzDCnhi4OskdIB2BrLm1NSFPMkALASTMuCplFwtyI+emYD/GzOwUF5zay Vk4QQ33Z9G1pw6jU730kFl/FU5tps35leUYUMcgiz2CG9DTz/wFRJ4SjwD4b1NYx 35nwbrhnp5TV4g94zFfY1NejSwmCpdzq5fvSYwu73yQ+pzwqA2xjXGMwICEo95Tj Zop/T9gU3g2Hglmz6zTe7m4EXdruFZrADlI6K6cPg/52HosSi7iLnkebwX0nClbQ HQeCdved38nzRBDZGaJmrDebHD3Uy+qrP5dxTaDe49JZZ+lnkceqy5s+OLQb78S3 Wt9q6GgdKLwa157K74ci/T3rSnty+dJlOXlaq2Bhbru8O7GGmIcmMtsAYzI7+C0z 0cuqsI2sXvT6i/XSjt2VK0D/aQfJ0NfpWDJ6rtlAnFc0g5UBncd8MrAfWo/KOPdH nIdamgVfmtHcglu07fBq =0pwZ -----END PGP SIGNATURE----- --------------050606050705040702090400 Content-Type: text/plain; charset=UTF-8; name="tzsetup.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="tzsetup.diff" Index: tzsetup.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- tzsetup.c (revision 278173) +++ tzsetup.c (working copy) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include =20 @@ -944,24 +945,19 @@ main(int argc, char **argv) if (argc - optind > 1) usage(); =20 - if (chrootenv =3D=3D NULL) { - strcpy(path_zonetab, _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); + strcpy(path_zonetab, _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); + + if (chrootenv !=3D NULL) { + rv =3D chroot(chrootenv); + if (rv !=3D 0) + err(EX_OSERR, "chroot to %s", chrootenv); } =20 - /* Override the user-supplied umask. */ (void)umask(S_IWGRP | S_IWOTH); =20 --------------050606050705040702090400--