Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Jun 2007 10:23:36 -0700 (PDT)
From:      youshi10@u.washington.edu
To:        hackers@freebsd.org
Subject:   Re: Using shell commands versus C equivalents
Message-ID:  <Pine.LNX.4.43.0706131023360.25469@hymn01.u.washington.edu>
In-Reply-To: <20070613162559.GA5093@britannica.bec.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 13 Jun 2007, Joerg Sonnenberger wrote:

> On Wed, Jun 13, 2007 at 11:15:52AM -0500, Rick C. Petty wrote:
>> Another improvement made by using stat(2)/chmod(2) over chmod(1) using
>> system(3) variants is the protection against malicious filenames.  The
>> original code should have used fork/execv instead anyway.
>
> To be precise, this case should use open/fstat/fchmod to avoid another
> bunch of race conditions.
>
> Joerg

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).

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).

-Garrett




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