Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 09 Apr 2004 11:20:44 +0200
From:      Uwe Doering <gemini@geminix.org>
To:        freebsd-questions@freebsd.org
Subject:   Re: changing directory permissions recursively
Message-ID:  <40766AEC.9060906@geminix.org>
In-Reply-To: <20040409090351.GB3094@adaptableit.com>
References:  <000501c41df5$519419f0$0200a8c0@satellite> <20040409055515.GA50737@alexis.mi.celestial.com> <407646EB.7020708@geminix.org> <20040409090351.GB3094@adaptableit.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Cory Petkovsek wrote:
> On Fri, Apr 09, 2004 at 08:47:07AM +0200, Uwe Doering wrote:
> 
>>>cd $topdir
>>>find . -type d | xargs chmod 755
>>
>>In case (potentially) untrusted users have had write permission in this 
>>directory tree in the past, a safer alternative would be
>>
>>  find /path/to/tree/root -type d -print0 | xargs -0 chmod 755
> 
> Please explain the "safer" difference in your eyes, Uwe.  Are you thinking the
> admin might have ./ in their path?

No, but specially crafted file names can contain spaces and newlines. 
Since xargs(1) by default considers whitespace to be argument separators 
users can easily inject absolute paths to files somewhere else in the 
filesystem and wreak havoc this way.  They just have to wait until 
'root' traverses over their files with 'find' and 'xargs'.

The '0' options for find(1) and xargs(1) have been introduced to counter 
these attacks.

    Uwe
-- 
Uwe Doering         |  EscapeBox - Managed On-Demand UNIX Servers
gemini@geminix.org  |  http://www.escapebox.net



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