From owner-svn-src-stable@freebsd.org Thu Aug 10 21:39:23 2017 Return-Path: Delivered-To: svn-src-stable@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 A245FDDD852; Thu, 10 Aug 2017 21:39:23 +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 7DA97724ED; Thu, 10 Aug 2017 21:39:23 +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 v7ALdMNw009826; Thu, 10 Aug 2017 21:39:22 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7ALdMYg009825; Thu, 10 Aug 2017 21:39:22 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201708102139.v7ALdMYg009825@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Thu, 10 Aug 2017 21:39:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r322376 - stable/10/usr.sbin/tzsetup X-SVN-Group: stable-10 X-SVN-Commit-Author: marius X-SVN-Commit-Paths: stable/10/usr.sbin/tzsetup X-SVN-Commit-Revision: 322376 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Aug 2017 21:39:23 -0000 Author: marius Date: Thu Aug 10 21:39:22 2017 New Revision: 322376 URL: https://svnweb.freebsd.org/changeset/base/322376 Log: MFC: r322097, r322203 - Since r301131 (MFCed to stable/10 in r321895), /etc/localtime is also installed when selecting UTC in interactive configurations. Thus, the code added in r220172 which treats a NULL zone file name as UTC and removes /etc/localtime in that case can go again. - Consistently refer to "could not delete" (as chosen by the oldest such code in here) when unlink(2) fails instead of a to mixture of "delete" and "unlink" in error messages. Modified: stable/10/usr.sbin/tzsetup/tzsetup.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/tzsetup/tzsetup.c ============================================================================== --- stable/10/usr.sbin/tzsetup/tzsetup.c Thu Aug 10 21:39:10 2017 (r322375) +++ stable/10/usr.sbin/tzsetup/tzsetup.c Thu Aug 10 21:39:22 2017 (r322376) @@ -107,7 +107,7 @@ xdialog_count_rows(const char *p) rows++; } - return rows ? rows : 1; + return (rows ? rows : 1); } static int @@ -124,7 +124,7 @@ xdialog_count_columns(const char *p) len = strlen(p); max_len = MAX(max_len, len); - return max_len; + return (max_len); } static int @@ -164,7 +164,8 @@ xdialog_menu(const char *title, const char *cprompt, i tag_x = MAX(tag_x, l + k + 2); } } - width = MAX(xdialog_count_columns(cprompt), title != NULL ? xdialog_count_columns(title) : 0); + width = MAX(xdialog_count_columns(cprompt), title != NULL ? + xdialog_count_columns(title) : 0); width = MAX(width, tag_x + 4) + 4; } width = MAX(width, 24); @@ -199,7 +200,7 @@ again: free(listitems); dlg_restore_vars(&save_vars); - return result; + return (result); } static int usedialog = 1; @@ -269,7 +270,7 @@ continent_country_menu(dialogMenuItem *continent) int rv; if (strcmp(continent->title, "UTC") == 0) - return set_zone_utc(); + return (set_zone_utc()); /* Short cut -- if there's only one country, don't post a menu. */ if (contp->nitems == 1) @@ -642,7 +643,7 @@ set_zone_menu(dialogMenuItem *dmi) static int set_zone_utc(void) { - if (!confirm_zone(NULL)) + if (!confirm_zone("UTC")) return (DITEM_FAILURE | DITEM_RECREATE); return (install_zoneinfo("UTC")); @@ -656,7 +657,7 @@ confirm_zone(const char *filename) struct tm *tm; int rv; - setenv("TZ", filename == NULL ? "" : filename, 1); + setenv("TZ", filename, 1); tzset(); tm = localtime(&t); @@ -714,11 +715,8 @@ install_zoneinfo_file(const char *zoneinfo_file) #ifdef VERBOSE snprintf(title, sizeof(title), "Info"); - if (zoneinfo_file == NULL) + if (copymode) snprintf(prompt, sizeof(prompt), - "Removing %s", path_localtime); - else if (copymode) - snprintf(prompt, sizeof(prompt), "Copying %s to %s", zoneinfo_file, path_localtime); else snprintf(prompt, sizeof(prompt), @@ -733,49 +731,6 @@ install_zoneinfo_file(const char *zoneinfo_file) #endif if (reallydoit) { - if (zoneinfo_file == NULL) { - if (unlink(path_localtime) < 0 && errno != ENOENT) { - snprintf(title, sizeof(title), "Error"); - snprintf(prompt, sizeof(prompt), - "Could not delete %s: %s", path_localtime, - 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); - } - if (unlink(path_db) < 0 && errno != ENOENT) { - snprintf(title, sizeof(title), "Error"); - snprintf(prompt, sizeof(prompt), - "Could not delete %s: %s", path_db, - 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); - } -#ifdef VERBOSE - snprintf(title, sizeof(title), "Done"); - snprintf(prompt, sizeof(prompt), - "Removed %s", path_localtime); -#ifdef HAVE_DIALOG - if (usedialog) - dialog_msgbox(title, prompt, 8, 72, 1); - else -#endif - fprintf(stderr, "%s\n", prompt); -#endif - return (DITEM_LEAVE_MENU); - } - if (copymode) { fd1 = open(zoneinfo_file, O_RDONLY, 0); if (fd1 < 0) { @@ -794,7 +749,7 @@ install_zoneinfo_file(const char *zoneinfo_file) if (unlink(path_localtime) < 0 && errno != ENOENT) { snprintf(prompt, sizeof(prompt), - "Could not unlink %s: %s", + "Could not delete %s: %s", path_localtime, strerror(errno)); #ifdef HAVE_DIALOG if (usedialog) { @@ -859,7 +814,7 @@ install_zoneinfo_file(const char *zoneinfo_file) } if (unlink(path_localtime) < 0 && errno != ENOENT) { snprintf(prompt, sizeof(prompt), - "Could not unlink %s: %s", + "Could not delete %s: %s", path_localtime, strerror(errno)); #ifdef HAVE_DIALOG if (usedialog) { @@ -999,7 +954,6 @@ main(int argc, char **argv) sprintf(path_wall_cmos_clock, "%s/%s", chrootenv, _PATH_WALL_CMOS_CLOCK); } - /* Override the user-supplied umask. */ (void)umask(S_IWGRP | S_IWOTH);