You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

chmod.html 6.5 KiB

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