summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2015-10-27 00:37:19 +0000
committerdelphij <delphij@FreeBSD.org>2015-10-27 00:37:19 +0000
commit06466cc0fc6d68c87903b53bbdf43b338db42dfe (patch)
tree757c8d5239c19707b5cefeff05b15421e1a94b33 /usr.sbin
parentc471bb0905d0facc37791937ea42608d103b75b1 (diff)
downloadFreeBSD-src-06466cc0fc6d68c87903b53bbdf43b338db42dfe.zip
FreeBSD-src-06466cc0fc6d68c87903b53bbdf43b338db42dfe.tar.gz
MFC r289269:
Use chroot(2) instead of using prefixes for files. Previously, the code prefixes the chroot path to actual file paths to simulate the effect. This, however, will not work for tzset(3) which expects the current system have a working set of timezone data files, and that is not always the case. This changeset simplifies the handling of paths and use an actual chroot(2) call to implement the effect. PR: bin/197313
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/tzsetup/tzsetup.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/usr.sbin/tzsetup/tzsetup.c b/usr.sbin/tzsetup/tzsetup.c
index cea8533..5fe4f86 100644
--- a/usr.sbin/tzsetup/tzsetup.c
+++ b/usr.sbin/tzsetup/tzsetup.c
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sysexits.h>
#include <time.h>
#include <unistd.h>
@@ -935,23 +936,18 @@ main(int argc, char **argv)
if (argc - optind > 1)
usage();
- if (chrootenv == 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);
+ if (chrootenv != NULL) {
+ rv = chroot(chrootenv);
+ if (rv != 0)
+ err(EX_OSERR, "chroot to %s", chrootenv);
}
+ 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);
/* Override the user-supplied umask. */
(void)umask(S_IWGRP | S_IWOTH);
OpenPOWER on IntegriCloud