From owner-svn-src-head@FreeBSD.ORG Thu Jul 18 21:56:10 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id DDF7415E; Thu, 18 Jul 2013 21:56:10 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id D098EB70; Thu, 18 Jul 2013 21:56:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6ILuAas085065; Thu, 18 Jul 2013 21:56:10 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6ILuAt4085064; Thu, 18 Jul 2013 21:56:10 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201307182156.r6ILuAt4085064@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Thu, 18 Jul 2013 21:56:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r253456 - head/usr.bin/kdump X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jul 2013 21:56:10 -0000 Author: pjd Date: Thu Jul 18 21:56:10 2013 New Revision: 253456 URL: http://svnweb.freebsd.org/changeset/base/253456 Log: - Make localtime(3) to work in sandbox. - Move strerror(3) initialization to its own function. Modified: head/usr.bin/kdump/kdump.c Modified: head/usr.bin/kdump/kdump.c ============================================================================== --- head/usr.bin/kdump/kdump.c Thu Jul 18 20:59:58 2013 (r253455) +++ head/usr.bin/kdump/kdump.c Thu Jul 18 21:56:10 2013 (r253456) @@ -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");