Date: Mon, 7 Aug 2017 21:38:10 +0000 (UTC) From: Marius Strobl <marius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322203 - head/usr.sbin/tzsetup Message-ID: <201708072138.v77LcAiY009902@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marius Date: Mon Aug 7 21:38:10 2017 New Revision: 322203 URL: https://svnweb.freebsd.org/changeset/base/322203 Log: Revert the parts of r322097 related to /etc/wall_cmos_clock handling as the previous behavior actually is required for setting up configurations in which the RTC is using UTC but the timezone is not. Still, besides uniform error handling, that file should get the same treatment in the non-interactive variants supported by tzsetup(8). Modified: head/usr.sbin/tzsetup/tzsetup.c Modified: head/usr.sbin/tzsetup/tzsetup.c ============================================================================== --- head/usr.sbin/tzsetup/tzsetup.c Mon Aug 7 21:29:55 2017 (r322202) +++ head/usr.sbin/tzsetup/tzsetup.c Mon Aug 7 21:38:10 2017 (r322203) @@ -866,48 +866,10 @@ install_zoneinfo_file(const char *zoneinfo_file) static int install_zoneinfo(const char *zoneinfo) { - int fd, rv; + int rv; FILE *f; char path_zoneinfo_file[MAXPATHLEN]; - char prompt[SILLY_BUFFER_SIZE], title[64]; - if (reallydoit) { - if (strcmp(zoneinfo, "UTC") == 0) { - if (unlink(path_wall_cmos_clock) < 0 && - errno != ENOENT) { - snprintf(title, sizeof(title), "Error"); - snprintf(prompt, sizeof(prompt), - "Could not delete %s: %s", - path_wall_cmos_clock, strerror(errno)); -#ifdef HAVE_DIALOG - if (usedialog) - dialog_msgbox(title, prompt, 8, 72, 1); - else -#endif - fprintf(stderr, "%s\n", prompt); - - return (DITEM_FAILURE | DITEM_RECREATE); - } - } else { - fd = open(path_wall_cmos_clock, O_WRONLY | O_CREAT | - O_TRUNC, S_IRUSR | S_IRGRP | S_IROTH); - if (fd < 0) { - snprintf(title, sizeof(title), "Error"); - snprintf(prompt, sizeof(prompt), - "Could not create %s: %s", - path_wall_cmos_clock, strerror(errno)); -#ifdef HAVE_DIALOG - if (usedialog) - dialog_msgbox(title, prompt, 8, 72, 1); - else -#endif - fprintf(stderr, "%s\n", prompt); - return (DITEM_FAILURE | DITEM_RECREATE); - } - close(fd); - } - } - if ((size_t)snprintf(path_zoneinfo_file, sizeof(path_zoneinfo_file), "%s/%s", path_zoneinfo, zoneinfo) >= sizeof(path_zoneinfo_file)) errx(1, "%s/%s name too long", path_zoneinfo, zoneinfo); @@ -938,6 +900,7 @@ main(int argc, char **argv) { #ifdef HAVE_DIALOG char title[64], prompt[128]; + int fd; #endif int c, rv, skiputc; char vm_guest[16] = ""; @@ -992,7 +955,6 @@ main(int argc, char **argv) _PATH_WALL_CMOS_CLOCK); } - /* Override the user-supplied umask. */ (void)umask(S_IWGRP | S_IWOTH); @@ -1059,11 +1021,19 @@ main(int argc, char **argv) yesno = dialog_yesno(title, prompt, 7, 73); dlg_restore_vars(&save_vars); if (!yesno) { + if (reallydoit) + unlink(path_wall_cmos_clock); + } else { if (reallydoit) { - rv = install_zoneinfo("UTC"); - dlg_clear(); - end_dialog(); - exit(rv & ~DITEM_LEAVE_MENU); + fd = open(path_wall_cmos_clock, + O_WRONLY | O_CREAT | O_TRUNC, + S_IRUSR | S_IRGRP | S_IROTH); + if (fd < 0) { + end_dialog(); + err(1, "create %s", + path_wall_cmos_clock); + } + close(fd); } } dlg_clear();
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708072138.v77LcAiY009902>