Date: Tue, 29 Mar 2011 06:49:37 GMT From: "Daniel O'Connor" <doconnor@gsoft.com.au> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/156019: Add a menu entry to tzsetup to select UTC Message-ID: <201103290649.p2T6nbKc091653@maarsy-acq.gsoft.com.au> Resent-Message-ID: <201103290650.p2T6o8GH007688@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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 <gcooper@FreeBSD.org> >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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103290649.p2T6nbKc091653>