1 | <!--
|
---|
2 | Licensed to the Apache Software Foundation (ASF) under one or more
|
---|
3 | contributor license agreements. See the NOTICE file distributed with
|
---|
4 | this work for additional information regarding copyright ownership.
|
---|
5 | The ASF licenses this file to You under the Apache License, Version 2.0
|
---|
6 | (the "License"); you may not use this file except in compliance with
|
---|
7 | the License. You may obtain a copy of the License at
|
---|
8 |
|
---|
9 | http://www.apache.org/licenses/LICENSE-2.0
|
---|
10 |
|
---|
11 | Unless required by applicable law or agreed to in writing, software
|
---|
12 | distributed under the License is distributed on an "AS IS" BASIS,
|
---|
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
14 | See the License for the specific language governing permissions and
|
---|
15 | limitations under the License.
|
---|
16 | -->
|
---|
17 | <html>
|
---|
18 |
|
---|
19 | <head>
|
---|
20 | <meta http-equiv="Content-Language" content="en-us">
|
---|
21 | <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
|
---|
22 | <title>Chmod Task</title>
|
---|
23 | </head>
|
---|
24 |
|
---|
25 | <body>
|
---|
26 |
|
---|
27 | <h2><a name="chmod">Chmod</a></h2>
|
---|
28 | <h3>Description</h3>
|
---|
29 | <p>Changes the permissions of a file or all files inside specified
|
---|
30 | directories. Right now it has effect only under Unix or NonStop Kernel (Tandem).
|
---|
31 | The permissions are also UNIX style, like the argument for the chmod command.</p>
|
---|
32 | <p>See the section on <a href="../dirtasks.html#directorybasedtasks">directory based
|
---|
33 | tasks</a>, on how the inclusion/exclusion of files works, and how to
|
---|
34 | write patterns.</p>
|
---|
35 |
|
---|
36 | <p>This task holds an implicit <a
|
---|
37 | href="../CoreTypes/fileset.html">FileSet</a> and supports all of
|
---|
38 | FileSet's attributes and nested elements directly. More sets can be
|
---|
39 | specified using nested <code><fileset></code> or
|
---|
40 | <code><dirset></code> (<em>since Ant 1.6</em>) elements. </p>
|
---|
41 |
|
---|
42 | <p>Starting with Ant 1.6, this task also supports nested <a
|
---|
43 | href="../CoreTypes/filelist.html">filelist</a>s.</p>
|
---|
44 |
|
---|
45 | <p>Starting with Ant 1.7, this task supports arbitrary <a
|
---|
46 | href="../CoreTypes/resources.html#collection">Resource Collection</a>s
|
---|
47 | as nested elements.</p>
|
---|
48 |
|
---|
49 | <p>By default this task will use a single invocation of the underlying
|
---|
50 | chmod command. If you are working on a large number of files this may
|
---|
51 | result in a command line that is too long for your operating system.
|
---|
52 | If you encounter such problems, you should set the maxparallel
|
---|
53 | attribute of this task to a non-zero value. The number to use highly
|
---|
54 | depends on the length of your file names (the depth of your directory
|
---|
55 | tree) and your operating system, so you'll have to experiment a
|
---|
56 | little. POSIX recommends command line length limits of at least 4096
|
---|
57 | characters, this may give you an approximation for the number you
|
---|
58 | could use as initial value for these experiments.</p>
|
---|
59 |
|
---|
60 | <h3>Parameters</h3>
|
---|
61 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
62 | <tr>
|
---|
63 | <td valign="top"><b>Attribute</b></td>
|
---|
64 | <td valign="top"><b>Description</b></td>
|
---|
65 | <td align="center" valign="top"><b>Required</b></td>
|
---|
66 | </tr>
|
---|
67 | <tr>
|
---|
68 | <td valign="top">file</td>
|
---|
69 | <td valign="top">the file or single directory of which the permissions
|
---|
70 | must be changed.</td>
|
---|
71 | <td valign="top" valign="middle" rowspan="2">exactly one of the two or nested <code><fileset/list></code> elements.</td>
|
---|
72 | </tr>
|
---|
73 | <tr>
|
---|
74 | <td valign="top">dir</td>
|
---|
75 | <td valign="top">the directory which holds the files whose permissions
|
---|
76 | must be changed.</td>
|
---|
77 | </tr>
|
---|
78 | <tr>
|
---|
79 | <td valign="top">perm</td>
|
---|
80 | <td valign="top">the new permissions.</td>
|
---|
81 | <td valign="top" align="center">Yes</td>
|
---|
82 | </tr>
|
---|
83 | <tr>
|
---|
84 | <td valign="top">includes</td>
|
---|
85 | <td valign="top">comma- or space-separated list of patterns of files that must be
|
---|
86 | included.</td>
|
---|
87 | <td valign="top" align="center">No</td>
|
---|
88 | </tr>
|
---|
89 | <tr>
|
---|
90 | <td valign="top">excludes</td>
|
---|
91 | <td valign="top">comma- or space-separated list of patterns of files that must be
|
---|
92 | excluded. No files (except default excludes) are excluded when omitted.</td>
|
---|
93 | <td valign="top" align="center">No</td>
|
---|
94 | </tr>
|
---|
95 | <tr>
|
---|
96 | <td valign="top">defaultexcludes</td>
|
---|
97 | <td valign="top">indicates whether default excludes should be used or not
|
---|
98 | ("yes"/"no"). Default excludes are used when omitted.</td>
|
---|
99 | <td valign="top" align="center">No</td>
|
---|
100 | </tr>
|
---|
101 | <tr>
|
---|
102 | <td valign="top">parallel</td>
|
---|
103 | <td valign="top">process all specified files using a single
|
---|
104 | <code>chmod</code> command. Defaults to true.</td>
|
---|
105 | <td valign="top" align="center">No</td>
|
---|
106 | </tr>
|
---|
107 | <tr>
|
---|
108 | <td valign="top">type</td>
|
---|
109 | <td valign="top">One of <i>file</i>, <i>dir</i> or
|
---|
110 | <i>both</i>. If set to <i>file</i>, only the permissions of
|
---|
111 | plain files are going to be changed. If set to <i>dir</i>, only
|
---|
112 | the directories are considered.<br>
|
---|
113 | <strong>Note:</strong> The type attribute does not apply to
|
---|
114 | nested <i>dirset</i>s - <i>dirset</i>s always implicitly
|
---|
115 | assume type to be <i>dir</i>.</td>
|
---|
116 | <td align="center" valign="top">No, default is <i>file</i></td>
|
---|
117 | </tr>
|
---|
118 | <tr>
|
---|
119 | <td valign="top">maxparallel</td>
|
---|
120 | <td valign="top">Limit the amount of parallelism by passing at
|
---|
121 | most this many sourcefiles at once. Set it to <= 0 for
|
---|
122 | unlimited. Defaults to unlimited. <em>Since Ant 1.6.</em></td>
|
---|
123 | <td align="center" valign="top">No</td>
|
---|
124 | </tr>
|
---|
125 | <tr>
|
---|
126 | <td valign="top">verbose</td>
|
---|
127 | <td valign="top">Whether to print a summary after execution or not.
|
---|
128 | Defaults to <code>false</code>. <em>Since Ant 1.6.</em></td>
|
---|
129 | <td align="center" valign="top">No</td>
|
---|
130 | </tr>
|
---|
131 | </table>
|
---|
132 | <h3>Examples</h3>
|
---|
133 | <blockquote><pre>
|
---|
134 | <chmod file="${dist}/start.sh" perm="ugo+rx"/>
|
---|
135 | </pre></blockquote>
|
---|
136 | <p>makes the "start.sh" file readable and executable for anyone on a
|
---|
137 | UNIX system.</p>
|
---|
138 | <blockquote><pre>
|
---|
139 | <chmod file="${dist}/start.sh" perm="700"/>
|
---|
140 | </pre></blockquote>
|
---|
141 | <p>makes the "start.sh" file readable, writable and executable only for the owner on a
|
---|
142 | UNIX system.</p>
|
---|
143 | <blockquote>
|
---|
144 | <pre>
|
---|
145 | <chmod dir="${dist}/bin" perm="ugo+rx"
|
---|
146 | includes="**/*.sh"/>
|
---|
147 | </pre>
|
---|
148 | </blockquote>
|
---|
149 | <p>makes all ".sh" files below <code>${dist}/bin</code>
|
---|
150 | readable and executable for anyone on a UNIX system.</p>
|
---|
151 | <blockquote>
|
---|
152 | <pre>
|
---|
153 | <chmod perm="g+w">
|
---|
154 | <fileset dir="shared/sources1">
|
---|
155 | <exclude name="**/trial/**"/>
|
---|
156 | </fileset>
|
---|
157 | <fileset refid="other.shared.sources"/>
|
---|
158 | </chmod>
|
---|
159 | </pre>
|
---|
160 | </blockquote>
|
---|
161 | <p>makes all files below <code>shared/sources1</code> (except those
|
---|
162 | below any directory named trial) writable for members of the same
|
---|
163 | group on a UNIX system. In addition all files belonging to a FileSet
|
---|
164 | with <code>id</code> <code>other.shared.sources</code> get the same
|
---|
165 | permissions.</p>
|
---|
166 |
|
---|
167 | <blockquote>
|
---|
168 | <pre>
|
---|
169 | <chmod perm="go-rwx" type="file">
|
---|
170 | <fileset dir="/web">
|
---|
171 | <include name="**/*.cgi"/>
|
---|
172 | <include name="**/*.old"/>
|
---|
173 | </fileset>
|
---|
174 | <dirset dir="/web">
|
---|
175 | <include name="**/private_*"/>
|
---|
176 | </dirset>
|
---|
177 | </chmod>
|
---|
178 | </pre>
|
---|
179 | </blockquote>
|
---|
180 |
|
---|
181 | <p>keeps non-owners from touching cgi scripts, files with a <code>.old</code>
|
---|
182 | extension or directories beginning with <code>private_</code>. A directory
|
---|
183 | ending in <code>.old</code> or a file beginning with private_ would remain
|
---|
184 | unaffected.</p>
|
---|
185 |
|
---|
186 |
|
---|
187 |
|
---|
188 | </body>
|
---|
189 | </html>
|
---|
190 |
|
---|