From owner-freebsd-bugs@FreeBSD.ORG Tue Mar 29 06:50:09 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1D9481065673 for ; Tue, 29 Mar 2011 06:50:09 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id D30D08FC0C for ; Tue, 29 Mar 2011 06:50:08 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p2T6o84x007689 for ; Tue, 29 Mar 2011 06:50:08 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p2T6o8GH007688; Tue, 29 Mar 2011 06:50:08 GMT (envelope-from gnats) Resent-Date: Tue, 29 Mar 2011 06:50:08 GMT Resent-Message-Id: <201103290650.p2T6o8GH007688@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "Daniel O'Connor" Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1D3CA106566B for ; Tue, 29 Mar 2011 06:49:40 +0000 (UTC) (envelope-from radar@maarsy-acq.gsoft.com.au) Received: from maarsy-acq.gsoft.com.au (unknown [IPv6:2001:44b8:7c07:5581:225:90ff:fe32:91e]) by mx1.freebsd.org (Postfix) with ESMTP id 60EA68FC0C for ; Tue, 29 Mar 2011 06:49:38 +0000 (UTC) Received: from maarsy-acq.gsoft.com.au (localhost [127.0.0.1]) by maarsy-acq.gsoft.com.au (8.14.4/8.14.4) with ESMTP id p2T6nbYS091654 for ; Tue, 29 Mar 2011 06:49:37 GMT (envelope-from radar@maarsy-acq.gsoft.com.au) Received: (from radar@localhost) by maarsy-acq.gsoft.com.au (8.14.4/8.14.4/Submit) id p2T6nbKc091653; Tue, 29 Mar 2011 06:49:37 GMT (envelope-from radar) Message-Id: <201103290649.p2T6nbKc091653@maarsy-acq.gsoft.com.au> Date: Tue, 29 Mar 2011 06:49:37 GMT From: "Daniel O'Connor" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/156019: Add a menu entry to tzsetup to select UTC X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 06:50:09 -0000 >Number: 156019 >Category: bin >Synopsis: Add a menu entry to tzsetup to select UTC >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Mar 29 06:50:08 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Radar User >Release: FreeBSD 9.0-CURRENT amd64 >Organization: >Environment: System: FreeBSD maarsy-acq.gsoft.com.au 9.0-CURRENT FreeBSD 9.0-CURRENT #0 r219926M: Sat Mar 26 02:15:22 UTC 2011 root@maarsy-acq.gsoft.com.au:/usr/obj/usr/src/sys/GENERIC amd64 >Description: This patch allows you to select UTC as a time zone (which removes /etc/localtime) Reviewed by: Garrett Cooper >How-To-Repeat: >Fix: http://www.gsoft.com.au/~doconnor/tzsetup-utc-menu.diff # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # tzsetup-utc-menu.diff # echo x - tzsetup-utc-menu.diff sed 's/^X//' >tzsetup-utc-menu.diff << '25aa59230e4eb211a79aefc8fd34a91c' X--- tzsetup.c.orig 2011-03-23 08:46:40.000000000 +0000 X+++ tzsetup.c 2011-03-29 06:43:48.000000000 +0000 X@@ -66,10 +66,13 @@ X static char *chrootenv = NULL; X X static void usage(void); X+static int confirm_zone(const char *filename); X static int continent_country_menu(dialogMenuItem *); X+static int install_zoneinfo_file(const char *zoneinfo_file); X static int set_zone_multi(dialogMenuItem *); X static int set_zone_whole_country(dialogMenuItem *); X static int set_zone_menu(dialogMenuItem *); X+static int set_zone_utc(void); X X struct continent { X dialogMenuItem *menu; X@@ -79,7 +82,7 @@ X }; X X static struct continent africa, america, antarctica, arctic, asia, atlantic; X-static struct continent australia, europe, indian, pacific; X+static struct continent australia, europe, indian, pacific, utc; X X static struct continent_names { X const char *name; X@@ -94,7 +97,8 @@ X { "Australia", &australia }, X { "Europe", &europe }, X { "Indian", &indian }, X- { "Pacific", &pacific } X+ { "Pacific", &pacific }, X+ { "UTC", &utc } X }; X X static struct continent_items { X@@ -110,7 +114,8 @@ X { "7", "Australia" }, X { "8", "Europe" }, X { "9", "Indian Ocean" }, X- { "0", "Pacific Ocean" } X+ { "0", "Pacific Ocean" }, X+ { "a", "UTC" } X }; X X #define NCONTINENTS \ X@@ -128,6 +133,9 @@ X int menulen; X int rv; X X+ if (!strcmp(continent->title, "UTC")) X+ return set_zone_utc(); X+ X /* Short cut -- if there's only one country, don't post a menu. */ X if (contp->nitems == 1) X return (contp->menu[0].fire(&contp->menu[0])); X@@ -502,6 +510,15 @@ X return (DITEM_LEAVE_MENU); X } X X+int X+set_zone_utc(void) X+{ X+ if (!confirm_zone(NULL)) X+ return (DITEM_FAILURE | DITEM_RECREATE); X+ X+ return (install_zoneinfo_file(NULL)); X+} X+ X static int X install_zoneinfo_file(const char *zoneinfo_file) X { X@@ -526,7 +543,7 @@ X else X snprintf(prompt, sizeof(prompt), X "Creating symbolic link %s to %s", X- path_localtime, zoneinfo_file); X+ path_localtime, zoneinfo_file == NULL ? "(UTC)" : zoneinfo_file); X if (usedialog) X dialog_notify(prompt); X else X@@ -534,6 +551,22 @@ X #endif X X if (reallydoit) { X+ if (zoneinfo_file == NULL) { X+ if (unlink(path_localtime) < 0 && errno != ENOENT) { X+ snprintf(title, sizeof(title), "Error"); X+ snprintf(prompt, sizeof(prompt), X+ "Could not delete %s: %s", path_localtime, X+ strerror(errno)); X+ if (usedialog) X+ dialog_mesgbox(title, prompt, 8, 72); X+ else X+ fprintf(stderr, "%s\n", prompt); X+ X+ return (DITEM_FAILURE | DITEM_RECREATE); X+ } X+ return (DITEM_LEAVE_MENU); X+ } X+ X if (copymode) { X fd1 = open(zoneinfo_file, O_RDONLY, 0); X if (fd1 < 0) { X@@ -656,7 +689,7 @@ X struct tm *tm; X int rv; X X- setenv("TZ", filename, 1); X+ setenv("TZ", filename == NULL ? "" : filename, 1); X tzset(); X tm = localtime(&t); X 25aa59230e4eb211a79aefc8fd34a91c exit >Release-Note: >Audit-Trail: >Unformatted: