Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Jun 2007 20:20:47 +0200
From:      Joerg Sonnenberger <joerg@britannica.bec.de>
To:        freebsd-hackers@freebsd.org, hackers@freebsd.org
Subject:   Re: Using shell commands versus C equivalents
Message-ID:  <20070613182046.GC8427@britannica.bec.de>
In-Reply-To: <Pine.LNX.4.43.0706131023360.25469@hymn01.u.washington.edu>
References:  <20070613162559.GA5093@britannica.bec.de> <Pine.LNX.4.43.0706131023360.25469@hymn01.u.washington.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070613182046.GC8427>