diff options
author | pjd <pjd@FreeBSD.org> | 2013-07-18 21:56:10 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2013-07-18 21:56:10 +0000 |
commit | 1018d5b890d93ddbe1e307fbbfd090c3a883c428 (patch) | |
tree | 97d59c531cfd7cb47bc9ed16c15250c7a4ec4409 /usr.bin | |
parent | 040e350119d57b89bcd5aecfd05556d91b76169b (diff) | |
download | FreeBSD-src-1018d5b890d93ddbe1e307fbbfd090c3a883c428.zip FreeBSD-src-1018d5b890d93ddbe1e307fbbfd090c3a883c428.tar.gz |
- Make localtime(3) to work in sandbox.
- Move strerror(3) initialization to its own function.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/kdump/kdump.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index 77a0cae..0f1a26b 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -165,6 +165,31 @@ struct proc_info TAILQ_HEAD(trace_procs, proc_info) trace_procs; +static void +strerror_init(void) +{ + + /* + * Cache NLS data before entering capability mode. + * XXXPJD: There should be strerror_init() and strsignal_init() in libc. + */ + (void)catopen("libc", NL_CAT_LOCALE); +} + +static void +localtime_init(void) +{ + time_t ltime; + + /* + * Allow localtime(3) to cache /etc/localtime content before entering + * capability mode. + * XXXPJD: There should be localtime_init() in libc. + */ + (void)time(<ime); + (void)localtime(<ime); +} + int main(int argc, char *argv[]) { @@ -236,11 +261,9 @@ main(int argc, char *argv[]) if (!freopen(tracefile, "r", stdin)) err(1, "%s", tracefile); - /* - * Cache NLS data before entering capability mode. - * XXXPJD: There should be strerror_init() and strsignal_init() in libc. - */ - (void)catopen("libc", NL_CAT_LOCALE); + strerror_init(); + localtime_init(); + if (resolv == 0) { if (cap_enter() < 0 && errno != ENOSYS) err(1, "unable to enter capability mode"); |