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.4 KiB

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