From owner-freebsd-bugs@FreeBSD.ORG Thu Jan 12 05:00:27 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0B3E2106566B for ; Thu, 12 Jan 2012 05:00:27 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id D353A8FC14 for ; Thu, 12 Jan 2012 05:00:26 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q0C50QsE073904 for ; Thu, 12 Jan 2012 05:00:26 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q0C50Qq1073903; Thu, 12 Jan 2012 05:00:26 GMT (envelope-from gnats) Resent-Date: Thu, 12 Jan 2012 05:00:26 GMT Resent-Message-Id: <201201120500.q0C50Qq1073903@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Devin Teske Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E2A65106564A for ; Thu, 12 Jan 2012 04:56:47 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id D099F8FC12 for ; Thu, 12 Jan 2012 04:56:47 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q0C4ulRr067223 for ; Thu, 12 Jan 2012 04:56:47 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id q0C4ulMq067222; Thu, 12 Jan 2012 04:56:47 GMT (envelope-from nobody) Message-Id: <201201120456.q0C4ulMq067222@red.freebsd.org> Date: Thu, 12 Jan 2012 04:56:47 GMT From: Devin Teske To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/164039: [PATCH] tzsetup(8): Don't write /var/db/zoneinfo either when "-n" is passed or when install_zoneinfo_file returns failure X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jan 2012 05:00:27 -0000 >Number: 164039 >Category: bin >Synopsis: [PATCH] tzsetup(8): Don't write /var/db/zoneinfo either when "-n" is passed or when install_zoneinfo_file returns failure >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:00:26 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 root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64 >Description: The "-n" flag is described in tzsetup(8) as "Do not create or copy files," so it seems like a bug that /var/db/zoneinfo is created without regard to this flag's presence. Additionally, since SVN r198350 -- where install_zone_file() was split into install_zoneinfo_file()/install_zoneinfo() -- the /var/db/zoneinfo file is written without regard to whether the zoneinfo file was successfully installed or not. The attached patch.txt makes it so that /var/db/zoneinfo is only written if (a) a zoneinfo file was successfully installed (install_zoneinfo_file returns success) and (b) the "-n" flag is not present. >How-To-Repeat: Exec as root: tzsetup some/foo Notice that /var/db/zoneinfo contains "some/foo" despite given failure to install any zonefile by that name. Similarly, exec as root: tzsetup -n America/Los_Angeles Notice that /var/db/zoneinfo contains "America/Los_Angeles" >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:12:54 2012 @@ -801,9 +801,11 @@ install_zoneinfo(const char *zoneinfo) rv = install_zoneinfo_file(path_zoneinfo_file); /* Save knowledge for later */ - if ((f = fopen(path_db, "w")) != NULL) { - fprintf(f, "%s\n", zoneinfo); - fclose(f); + if (reallydoit && (rv & DITEM_FAILURE) == 0) { + if (f = fopen(path_db, "w")) != NULL) { + fprintf(f, "%s\n", zoneinfo); + fclose(f); + } } return (rv); >Release-Note: >Audit-Trail: >Unformatted: