>Number: 164041 >Category: bin >Synopsis: [PATCH] tzsetup(8): Remove unnecessary code duplication and >clean-up reinstall option >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Jan 12 05:30:11 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Devin Teske >Release: FreeBSD 9.0-RELEASE amd64 >Organization: FIS Global, Inc. >Environment: FreeBSD scribe.vicor.com 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:46:30 UTC 2010 r...@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64 >Description: This makes some code-cleanups to the "reinstall" option added in SVN r198267.
Most notably, it moves the reinstall logic to be before the initialization of the menus (as the menus are not needed in reinstalling a zonefile). Additionally, remove unnecessary re-initialization of path_db. Further, since SVN r198350, the logic would be clearer if "zoneinfo" is used instead of "zonefile" as the contents no longer contain a path to a file but the name of a zone relative to /usr/share/zoneinfo. >How-To-Repeat: >Fix: See attached patch.txt Patch attached with submission follows: --- usr.sbin/tzsetup/tzsetup.c.orig Fri Dec 2 11:19:10 2011 +++ usr.sbin/tzsetup/tzsetup.c Wed Jan 11 20:07:00 2012 @@ -914,32 +914,16 @@ main(int argc, char **argv) /* Override the user-supplied umask. */ (void)umask(S_IWGRP | S_IWOTH); - read_iso3166_table(); - read_zones(); - sort_countries(); - make_menus(); - if (reinstall == 1) { FILE *f; - char zonefile[MAXPATHLEN]; - char path_db[MAXPATHLEN]; - - zonefile[0] = '\0'; - path_db[0] = '\0'; - if (chrootenv != NULL) { - sprintf(zonefile, "%s/", chrootenv); - sprintf(path_db, "%s/", chrootenv); - } - strcat(zonefile, _PATH_ZONEINFO); - strcat(zonefile, "/"); - strcat(path_db, _PATH_DB); + char zoneinfo[MAXPATHLEN]; if ((f = fopen(path_db, "r")) != NULL) { - if (fgets(zonefile, sizeof(zonefile), f) != NULL) { - zonefile[sizeof(zonefile) - 1] = 0; - if (strlen(zonefile) > 0) { - zonefile[strlen(zonefile) - 1] = 0; - rv = install_zoneinfo(zonefile); + if (fgets(zoneinfo, sizeof(zoneinfo), f) != NULL) { + zoneinfo[sizeof(zoneinfo) - 1] = 0; + if (strlen(zoneinfo) > 0) { + zoneinfo[strlen(zoneinfo) - 1] = 0; + rv = install_zoneinfo(zoneinfo); exit(rv & ~DITEM_LEAVE_MENU); } errx(1, "Error reading %s.\n", path_db); @@ -947,7 +931,7 @@ main(int argc, char **argv) fclose(f); errx(1, "Unable to determine earlier installed zoneinfo " - "file. Check %s", path_db); + "name. Check %s", path_db); } errx(1, "Cannot open %s for reading. Does it exist?", path_db); } @@ -966,6 +950,11 @@ main(int argc, char **argv) } /* FALLTHROUGH */ } + + read_iso3166_table(); + read_zones(); + sort_countries(); + make_menus(); init_dialog(stdin, stdout); if (skiputc == 0) { >Release-Note: >Audit-Trail: >Unformatted: _______________________________________________ freebsd-bugs@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-bugs To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"