ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rob Oxspring" <roxspr...@yahoo.com>
Subject RE: [SUBMIT] Attrib task (chmod for Windows)
Date Fri, 25 Jan 2002 22:07:44 GMT


> -----Original Message-----
> From: Peter Janes [mailto:peterj@liberate.com]
> Sent: Friday, January 25, 2002 7:10 PM
> To: Ant Developers List
> Subject: Re: [SUBMIT] Attrib task (chmod for Windows)
>
>
> Jesse Stockall wrote:
> > On Fri, 2002-01-25 at 12:47, Peter Janes wrote:
> >
> >>As a simple example, take something like
> >>
> >><set-permissions
> >>   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}/file.java" perm="-w"/>
> > <attrib file="${src}/file.java" 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

I agree - part of the problem is the semantics of the "perm" string this is
specific to each command and IMHO would be far clearer to read as separate
attributes readable, writable, executable in the case of chmod and
readonly,hidden,system,archive for attrib - thus there would be no confusion
of what the R means in each perm string.

> 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}/file.java" ro="true" sticky="true">
> 	<group exec="true" ro="false"/>
> 	<other exec="false"/>
> 	<ntgroup name="Administrators" ro="false"/>
> </set-permissions>
>
> would be translated on UNIX as:
>
> chmod a-r ${src}/file.java
> chmod a+t ${src}/file.java
> chmod g+x ${src}/file.java
> chmod g+r ${src}/file.java
> chmod o-x ${src}/file.java
>
> on Win9x as:
>
> attrib +r ${src}\file.java
>
> on WinNT/2K as:
>
> attrib +r ${src}\file.java
> {plus some set of acl commands}

Determined to get some feedback (just tell me it sucks if you like) I'll
restate my proposed combined task:

<filerights>
  <fileset ... > ... </fileset>
  <fat readonly="no" hidden="no"/>
  <ntfs>
   <grant user="RobertO"  access="full"/>
   <grant user="Informatics"  access="read"/>
   <grant user="everyone" access="read"/>
  </ntfs>
  <unix>
    <user name="roberto"     readable="yes" writable="yes" executable="yes">
    <group name="informatics" readable="yes" writable="no" executable="yes">
    <all readable="yes" writable="no" executable="no">
  </unix>
  <fat readonly="yes" hidden="yes"/>
</filerights>

This would map to the following set of commands:
  attrib -rh ...
  cacls ...  /P Roberto:F
  cacls ...  /P Informatics:R
  cacls ...  /P Everyone:R
  chown roberto:informatics ...
  chmod 744 ...
  attrib +rh ...

The full list of commands should be attempted on every platform and warning
messages should be issued as commands fail (maybe calls to a given util
should not be attempted once they have failed once).  I think the big
selling point of a combined task is that people using it to set the unix
permissions (for example) will be confronted by a bunch of ntfs permissions
in the manual which should trigger the build engineer to think about NT
permissions required and vice versa.  Also there is the added bonus of
sneaking chown / chgrp functionality into ant here too!

I think this approach would cover all bases, and gives the engineer enough
control to specify the order in which the attribute setting gets attempted
so that the desired affect is achieved.

Rob




>
> --
> 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:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message