From owner-svn-src-head@freebsd.org Mon Aug 7 21:38:11 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6F332DCA7AF; Mon, 7 Aug 2017 21:38:11 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 439A58491E; Mon, 7 Aug 2017 21:38:11 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77LcAY2009903; Mon, 7 Aug 2017 21:38:10 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77LcAiY009902; Mon, 7 Aug 2017 21:38:10 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201708072138.v77LcAiY009902@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Mon, 7 Aug 2017 21:38:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322203 - head/usr.sbin/tzsetup X-SVN-Group: head X-SVN-Commit-Author: marius X-SVN-Commit-Paths: head/usr.sbin/tzsetup X-SVN-Commit-Revision: 322203 X-SVN-Commit-Repository: base 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.23 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: Mon, 07 Aug 2017 21:38:11 -0000 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();