From owner-freebsd-ports-bugs@FreeBSD.ORG Sat May 10 17:10:01 2014 Return-Path: Delivered-To: freebsd-ports-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EE60A464 for ; Sat, 10 May 2014 17:10:00 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (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 CB09E695 for ; Sat, 10 May 2014 17:10:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s4AHA0Qm025145 for ; Sat, 10 May 2014 17:10:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s4AHA0aI025133; Sat, 10 May 2014 17:10:00 GMT (envelope-from gnats) Resent-Date: Sat, 10 May 2014 17:10:00 GMT Resent-Message-Id: <201405101710.s4AHA0aI025133@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Yasuhito FUTATSUKI Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CD769281 for ; Sat, 10 May 2014 17:05:48 +0000 (UTC) Received: from cgiserv.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BA11665A for ; Sat, 10 May 2014 17:05:48 +0000 (UTC) Received: from cgiserv.freebsd.org ([127.0.1.6]) by cgiserv.freebsd.org (8.14.8/8.14.8) with ESMTP id s4AH5l2x084990 for ; Sat, 10 May 2014 17:05:47 GMT (envelope-from nobody@cgiserv.freebsd.org) Received: (from nobody@localhost) by cgiserv.freebsd.org (8.14.8/8.14.8/Submit) id s4AH5l68084989; Sat, 10 May 2014 17:05:47 GMT (envelope-from nobody) Message-Id: <201405101705.s4AH5l68084989@cgiserv.freebsd.org> Date: Sat, 10 May 2014 17:05:47 GMT From: Yasuhito FUTATSUKI To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: ports/189618: net/GeoIP: geoipupdate.sh don't update file atomically X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 May 2014 17:10:01 -0000 >Number: 189618 >Category: ports >Synopsis: net/GeoIP: geoipupdate.sh don't update file atomically >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat May 10 17:10:00 UTC 2014 >Closed-Date: >Last-Modified: >Originator: Yasuhito FUTATSUKI >Release: FreeBSD 10.0-RELEASE-p2 >Organization: DEBUG, a users group of *BSD, in Japan >Environment: FreeBSD sv.debug.gr.jp 10.0-RELEASE-p2 FreeBSD 10.0-RELEASE-p2 #0 r29:30: Thu May 1 19:43:20 JST 2014 root@:/usr/obj/usr/src/sys/XEN-IPSEC amd64 >Description: geoipupdate.sh provided from net/GeoIP, produced from files/geoipupdate.sh.in, don't update GeoIP.dat atomically. It clears original file by using shell redirect (>), then download and gunzip to it. So, if other process try to use it while updating, the process will see broken data. >How-To-Repeat: run /usr/local/bin/geoipupdate.sh as root >Fix: fetch GeoIP.dat.gz and gunzip it as filename other than GeoIP.dat in the same file system, then rename(2) to GeoIP.dat. Patch attached with submission follows: Index: files/geoipupdate.sh.in =================================================================== --- files/geoipupdate.sh.in (revision 353207) +++ files/geoipupdate.sh.in (working copy) @@ -1,2 +1,14 @@ #!/bin/sh -fetch -o - http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz | gunzip > %%DATADIR%%/GeoIP.dat +TEMPFILE=`mktemp %%DATADIR%%/GeoIP.dat-XXXXXX` +if fetch -o - http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz | gunzip >> $TEMPFILE ; then + chmod og+r $TEMPFILE + if ! mv $TEMPFILE %%DATADIR%%/GeoIP.dat ; then + rm $TEMPFILE + echo fail to substitute GeoIP.dat + exit 2 + fi +else + rm $TEMPFILE + echo fail to update GeoIP.dat + exit 1 +fi >Release-Note: >Audit-Trail: >Unformatted: