ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Janes <>
Subject Re: [SUBMIT] Attrib task (chmod for Windows)
Date Fri, 25 Jan 2002 19:09:46 GMT
Jesse Stockall wrote:
> On Fri, 2002-01-25 at 12:47, Peter Janes wrote:
>>As a simple example, take something like
>>   file="foo"
>>   executable="true"
>>   readonly="true"
>>   hidden="true"
>>On Windows (which doesn't have "executable" files) this would translate to
>>   attrib +r +h foo
>>On UNIX (which doesn't have "hidden" files) it would become
>>   chmod 0555 foo
> This is fine if you want all user to have the same permissions.
> But you would be losing most of the current chmod's capabilities. Keep
> in mind that you have the following choices
> ugoa (user, group, other, all)
> +-=  (add, remove, only)
> rwxXstugo  (r) read 
> 	   (w) write
> 	   (x) execute (or access for directo­ries)
> 	   (X) execute only if the file is a directory or already has 	   
> execute permission for some user
> 	   (s) set user or group ID on execution
> 	   (t) sticky
> 	   (u) the permissions that the user who owns the file currently 	   
> has for it
> 	   (g) the permissions that other users in the file's group have 	   
> for it 
> 	   (o) and the permissions that other users not in the file's 	   
> group have for it
> That is allot of combinations to handle gracefully.
> With the chmod task for Unix & the Attrib task for Windows I can make a
> file read-only for both platforms with the following
> <chmod file="${src}/" perm="-w"/>
> <attrib file="${src}/" perm="+R"/>
> Each task is only executed on the appropriate platform.

With two tasks, you have to duplicate every set of permissions in build.xml 
and know the syntax of the applicable commands on each platform, or risk 
breaking on platforms you haven't considered (for example, what happens when 
I compile your code on Mac?).  Plus, remember that NT can have "extended" 
permissions similar to UNIX ACLs.

My point, I think, is that chmod and attrib (and the NT ACL stuff) do 
essentially the same thing, within the limitations of their respective 
platforms.  It's similar to javac and jikes, or gcc and cc.  (And I'd bet 
money that your example, setting permissions for all, is the use case for 
upwards of 90% of the task's users.)

Because permissions can't be read, addition, removal and outright setting of 
permissions would be handled identically by the task.  To expand slightly on 
my original example, something like

<set-permissions file="${src}/" ro="true" sticky="true">
	<group exec="true" ro="false"/>
	<other exec="false"/>
	<ntgroup name="Administrators" ro="false"/>

would be translated on UNIX as:

chmod a-r ${src}/
chmod a+t ${src}/
chmod g+x ${src}/
chmod g+r ${src}/
chmod o-x ${src}/

on Win9x as:

attrib +r ${src}\

on WinNT/2K as:

attrib +r ${src}\
{plus some set of acl commands}

fix, n., v.  What one does when a problem has been reported too many
times to be ignored.
   --The New Hacker's Dictionary, 3rd ed.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message