From owner-freebsd-hackers@FreeBSD.ORG Wed Jun 13 18:21:23 2007 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 426B216A46C; Wed, 13 Jun 2007 18:21:23 +0000 (UTC) (envelope-from joerg@britannica.bec.de) Received: from www.pkgsrc-box.org (www.ostsee-abc.de [62.206.222.50]) by mx1.freebsd.org (Postfix) with ESMTP id F3DA613C469; Wed, 13 Jun 2007 18:21:22 +0000 (UTC) (envelope-from joerg@britannica.bec.de) Received: from britannica.bec.de (www.pkgsrc-box.org [127.0.0.1]) by www.pkgsrc-box.org (Postfix) with ESMTP id 3C16FE7A3FA; Wed, 13 Jun 2007 18:21:21 +0000 (UTC) Received: by britannica.bec.de (Postfix, from userid 1000) id 779A67D3C; Wed, 13 Jun 2007 20:20:48 +0200 (CEST) Date: Wed, 13 Jun 2007 20:20:47 +0200 From: Joerg Sonnenberger To: freebsd-hackers@freebsd.org, hackers@freebsd.org Message-ID: <20070613182046.GC8427@britannica.bec.de> Mail-Followup-To: freebsd-hackers@freebsd.org, hackers@freebsd.org References: <20070613162559.GA5093@britannica.bec.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.13 (2006-08-11) Cc: Subject: Re: Using shell commands versus C equivalents X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2007 18:21:23 -0000 On Wed, Jun 13, 2007 at 10:23:36AM -0700, youshi10@u.washington.edu wrote: > Should I briefly lock (flock) the file when running open/fstat/fchmod then > to avoid issues? This may become a problem as pkg_*/make becomes more > parallelized (another student's goals for his SoC project). Looking does not change the issue. The problem here to protect against is that a process renames a file between the stat and the chmod. See the classic tmp file class of security vulnerabilities. > Needless to say, pkg_* is by no means threadsafe in its current form > though. It uses some global vars that are currently not mutex locked, and > this type of file access is another issue (I wonder if spinlocking or > sleeping waiting for flock to finish would be better in this case). I'm perfectly aware of the state of pkg_install. I also believe that it is a bad idea to parallelise it, but I don't want to argue with FreeBSD/Ports about that. Joerg