Using shell commands versus C equivalents

Joerg Sonnenberger joerg at britannica.bec.de
Wed Jun 13 18:21:23 UTC 2007


On Wed, Jun 13, 2007 at 10:23:36AM -0700, youshi10 at 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


More information about the freebsd-hackers mailing list