develooper Front page | perl.perl6.language | Postings from November 2008

Re: S16: chown, chmod

Thread Previous | Thread Next
From:
Brandon S. Allbery KF8NH
Date:
November 24, 2008 22:20
Subject:
Re: S16: chown, chmod
Message ID:
C0BF845A-B2EF-4319-8494-8009D51EBA50@ece.cmu.edu
On 2008 Nov 24, at 10:36, dpuu wrote:
> On Nov 23, 3:56 pm, allb...@ece.cmu.edu (Brandon S. Allbery KF8NH)
> wrote:
>> I think you're seeing something other than what we are.  Checking any
>> external resource before operating on it introduces a race condition
>> which can allow an attacker to swap resources on you, so the item you
>> (in this case) chown() isn't the one you tested.
>
> If the "chown" is restricted then it's going to fail anyway, assuming
> that the underlying Unix function fails. If "chown" can succeed
> incorrectly then there's nothing that P6 can do to prevent that. My

Still misunderstanding, I think.  Yes, it will fail anyway, but in the  
general case you're checking to see if as a privileged process it is  
safe to operate on a given file.  In such case the correct thing to do  
is relinquish privilege and then simply do the operation, trapping any  
error --- not testing and then doing it.

(I grant this isn't quite the same thing --- unless you're trying to  
decide if your root process should chown() a file on behalf of an  
unprivileged process.)

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About