isposix

Un outil pour savoir si une commande est posix - retour accueil

git clone git://bebou.netlib.re/isposix
Log | Files | Refs | README |

umask.html (15138B)


      1 <!-- Copyright 2001-2024 IEEE and The Open Group, All Rights Reserved -->
      2 <!DOCTYPE HTML>
      3 <html lang="en">
      4 <head>
      5 <meta name="generator" content="HTML Tidy for HTML5 for Linux version 5.8.0">
      6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      7 <link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group rhtm tool v1.2.4 -->
      8 <!-- Copyright (c) 2001-2024 The Open Group, All Rights Reserved -->
      9 <title>umask</title>
     10 </head>
     11 <body bgcolor="white">
     12 <div class="NAVHEADER">
     13 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0">
     14 <tr class="nav">
     15 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/ulimit.html" accesskey="P">&lt;&lt;&lt;
     16 Previous</a></td>
     17 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td>
     18 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/unalias.html" accesskey="N">Next
     19 &gt;&gt;&gt;</a></td>
     20 </tr>
     21 </table>
     22 <hr align="left" width="100%"></div>
     23 <script language="JavaScript" src="../jscript/codes.js"></script><basefont size="3">
     24 <center><font size="2">The Open Group Base Specifications Issue 8<br>
     25 IEEE Std 1003.1-2024<br>
     26 Copyright © 2001-2024 The IEEE and The Open Group</font></center>
     27 <hr size="2" noshade>
     28 <a name="top" id="top"></a> <a name="umask" id="umask"></a> <a name="tag_20_132" id="tag_20_132"></a><!-- umask -->
     29 <h4 class="mansect"><a name="tag_20_132_01" id="tag_20_132_01"></a>NAME</h4>
     30 <blockquote>umask — get or set the file mode creation mask</blockquote>
     31 <h4 class="mansect"><a name="tag_20_132_02" id="tag_20_132_02"></a>SYNOPSIS</h4>
     32 <blockquote class="synopsis">
     33 <p><code><tt>umask</tt> <b>[</b><tt>-S</tt><b>] [</b><i>mask</i><b>]</b></code></p>
     34 </blockquote>
     35 <h4 class="mansect"><a name="tag_20_132_03" id="tag_20_132_03"></a>DESCRIPTION</h4>
     36 <blockquote>
     37 <p>The <i>umask</i> utility shall set the file mode creation mask of the current shell execution environment (see <a href=
     38 "../utilities/V3_chap02.html#tag_19_13"><i>2.13 Shell Execution Environment</i></a> ) to the value specified by the <i>mask</i>
     39 operand. This mask shall affect the initial value of the file permission bits of subsequently created files. If <i>umask</i> is
     40 called in a subshell or separate utility execution environment, such as one of the following:</p>
     41 <pre>
     42 <tt>(umask 002)
     43 nohup umask ...
     44 find . -exec umask ... \;
     45 </tt></pre>
     46 <p>it shall not affect the file mode creation mask of the caller's environment.</p>
     47 <p>If the <i>mask</i> operand is not specified, the <i>umask</i> utility shall write to standard output the value of the file mode
     48 creation mask of the invoking process.</p>
     49 </blockquote>
     50 <h4 class="mansect"><a name="tag_20_132_04" id="tag_20_132_04"></a>OPTIONS</h4>
     51 <blockquote>
     52 <p>The <i>umask</i> utility shall conform to XBD <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax
     53 Guidelines</i></a> .</p>
     54 <p>The following option shall be supported:</p>
     55 <dl compact>
     56 <dd></dd>
     57 <dt><b>-S</b></dt>
     58 <dd>Produce symbolic output.</dd>
     59 </dl>
     60 <p>The default output style is unspecified, but shall be recognized on a subsequent invocation of <i>umask</i> on the same system
     61 as a <i>mask</i> operand to restore the previous file mode creation mask.</p>
     62 </blockquote>
     63 <h4 class="mansect"><a name="tag_20_132_05" id="tag_20_132_05"></a>OPERANDS</h4>
     64 <blockquote>
     65 <p>The following operand shall be supported:</p>
     66 <dl compact>
     67 <dd></dd>
     68 <dt><i>mask</i></dt>
     69 <dd>A string specifying the new file mode creation mask. The string is treated in the same way as the <i>mode</i> operand described
     70 in the EXTENDED DESCRIPTION section for <a href="../utilities/chmod.html"><i>chmod</i></a>.
     71 <p>For a <i>symbolic_mode</i> value, the new value of the file mode creation mask shall be the logical complement of the file
     72 permission bits portion of the file mode specified by the <i>symbolic_mode</i> string.</p>
     73 <p>In a <i>symbolic_mode</i> value, the permissions <i>op</i> characters <tt>'+'</tt> and <tt>'-'</tt> shall be interpreted
     74 relative to the current file mode creation mask; <tt>'+'</tt> shall cause the bits for the indicated permissions to be cleared in
     75 the mask; <tt>'-'</tt> shall cause the bits for the indicated permissions to be set in the mask.</p>
     76 <p>The interpretation of <i>mode</i> values that specify file mode bits other than the file permission bits is unspecified.</p>
     77 <p>In the octal integer form of <i>mode</i>, the specified bits are set in the file mode creation mask.</p>
     78 <p>The file mode creation mask shall be set to the resulting numeric value.</p>
     79 <p>The default output of a prior invocation of <i>umask</i> on the same system with no operand also shall be recognized as a
     80 <i>mask</i> operand.</p>
     81 </dd>
     82 </dl>
     83 </blockquote>
     84 <h4 class="mansect"><a name="tag_20_132_06" id="tag_20_132_06"></a>STDIN</h4>
     85 <blockquote>
     86 <p>Not used.</p>
     87 </blockquote>
     88 <h4 class="mansect"><a name="tag_20_132_07" id="tag_20_132_07"></a>INPUT FILES</h4>
     89 <blockquote>
     90 <p>None.</p>
     91 </blockquote>
     92 <h4 class="mansect"><a name="tag_20_132_08" id="tag_20_132_08"></a>ENVIRONMENT VARIABLES</h4>
     93 <blockquote>
     94 <p>The following environment variables shall affect the execution of <i>umask</i>:</p>
     95 <dl compact>
     96 <dd></dd>
     97 <dt><i>LANG</i></dt>
     98 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href=
     99 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> for the precedence of internationalization
    100 variables used to determine the values of locale categories.)</dd>
    101 <dt><i>LC_ALL</i></dt>
    102 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
    103 <dt><i>LC_CTYPE</i></dt>
    104 <dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
    105 opposed to multi-byte characters in arguments).</dd>
    106 <dt><i>LC_MESSAGES</i></dt>
    107 <dd><br>
    108 Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.</dd>
    109 <dt><i>NLSPATH</i></dt>
    110 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
    111 Determine the location of messages objects and message catalogs. <img src="../images/opt-end.gif" alt="[Option End]" border=
    112 "0"></dd>
    113 </dl>
    114 </blockquote>
    115 <h4 class="mansect"><a name="tag_20_132_09" id="tag_20_132_09"></a>ASYNCHRONOUS EVENTS</h4>
    116 <blockquote>
    117 <p>Default.</p>
    118 </blockquote>
    119 <h4 class="mansect"><a name="tag_20_132_10" id="tag_20_132_10"></a>STDOUT</h4>
    120 <blockquote>
    121 <p>When the <i>mask</i> operand is not specified, the <i>umask</i> utility shall write a message to standard output that can later
    122 be used as a <i>umask</i> <i>mask</i> operand.</p>
    123 <p>If <b>-S</b> is specified, the message shall be in the following format:</p>
    124 <pre>
    125 <tt>"u=%s,g=%s,o=%s\n", &lt;</tt><i>owner permissions</i><tt>&gt;, &lt;</tt><i>group permissions</i><tt>&gt;,
    126     &lt;</tt><i>other permissions</i><tt>&gt;
    127 </tt></pre>
    128 <p>where the three values shall be combinations of letters from the set {<i>r</i>, <i>w</i>, <i>x</i>}; the presence of a letter
    129 shall indicate that the corresponding bit is clear in the file mode creation mask.</p>
    130 <p>If a <i>mask</i> operand is specified, there shall be no output written to standard output.</p>
    131 </blockquote>
    132 <h4 class="mansect"><a name="tag_20_132_11" id="tag_20_132_11"></a>STDERR</h4>
    133 <blockquote>
    134 <p>The standard error shall be used only for diagnostic messages.</p>
    135 </blockquote>
    136 <h4 class="mansect"><a name="tag_20_132_12" id="tag_20_132_12"></a>OUTPUT FILES</h4>
    137 <blockquote>
    138 <p>None.</p>
    139 </blockquote>
    140 <h4 class="mansect"><a name="tag_20_132_13" id="tag_20_132_13"></a>EXTENDED DESCRIPTION</h4>
    141 <blockquote>
    142 <p>None.</p>
    143 </blockquote>
    144 <h4 class="mansect"><a name="tag_20_132_14" id="tag_20_132_14"></a>EXIT STATUS</h4>
    145 <blockquote>
    146 <p>The following exit values shall be returned:</p>
    147 <dl compact>
    148 <dd></dd>
    149 <dt>&nbsp;0</dt>
    150 <dd>The file mode creation mask was successfully changed, or no <i>mask</i> operand was supplied.</dd>
    151 <dt>&gt;0</dt>
    152 <dd>An error occurred.</dd>
    153 </dl>
    154 </blockquote>
    155 <h4 class="mansect"><a name="tag_20_132_15" id="tag_20_132_15"></a>CONSEQUENCES OF ERRORS</h4>
    156 <blockquote>
    157 <p>Default.</p>
    158 </blockquote>
    159 <hr>
    160 <div class="box"><em>The following sections are informative.</em></div>
    161 <h4 class="mansect"><a name="tag_20_132_16" id="tag_20_132_16"></a>APPLICATION USAGE</h4>
    162 <blockquote>
    163 <p>This utility is required to be intrinsic. See <a href="../utilities/V3_chap01.html#tag_18_07"><i>1.7 Intrinsic Utilities</i></a>
    164 for details.</p>
    165 <p>Since <i>umask</i> affects the current shell execution environment, it is generally provided as a shell regular built-in.</p>
    166 <p>In contrast to the negative permission logic provided by the file mode creation mask and the octal number form of the
    167 <i>mask</i> argument, the symbolic form of the <i>mask</i> argument specifies those permissions that are left alone.</p>
    168 </blockquote>
    169 <h4 class="mansect"><a name="tag_20_132_17" id="tag_20_132_17"></a>EXAMPLES</h4>
    170 <blockquote>
    171 <p>Either of the commands:</p>
    172 <pre>
    173 <tt>umask a=rx,ug+w
    174 <br>
    175 umask 002
    176 </tt></pre>
    177 <p>sets the mode mask so that subsequently created files have their S_IWOTH bit cleared.</p>
    178 <p>After setting the mode mask with either of the above commands, the <i>umask</i> command can be used to write out the current
    179 value of the mode mask:</p>
    180 <pre>
    181 <b>$ </b><tt>umask
    182 </tt><b>0002</b><tt>
    183 </tt></pre>
    184 <p>(The output format is unspecified, but historical implementations use the octal integer mode format.)</p>
    185 <pre>
    186 <b>$ </b><tt>umask -S
    187 </tt><b>u=rwx,g=rwx,o=rx</b><tt>
    188 </tt></pre>
    189 <p>Either of these outputs can be used as the mask operand to a subsequent invocation of the <i>umask</i> utility.</p>
    190 <p>Assuming the mode mask is set as above, the command:</p>
    191 <pre>
    192 <tt>umask g-w
    193 </tt></pre>
    194 <p>sets the mode mask so that subsequently created files have their S_IWGRP and S_IWOTH bits cleared.</p>
    195 <p>The command:</p>
    196 <pre>
    197 <tt>umask -- -w
    198 </tt></pre>
    199 <p>sets the mode mask so that subsequently created files have all their write bits cleared. Note that <i>mask</i> operands
    200 <b>-r</b>, <b>-w</b>, <b>-x</b> or anything beginning with a &lt;hyphen-minus&gt;, must be preceded by <tt>"--"</tt> to keep it
    201 from being interpreted as an option.</p>
    202 </blockquote>
    203 <h4 class="mansect"><a name="tag_20_132_18" id="tag_20_132_18"></a>RATIONALE</h4>
    204 <blockquote>
    205 <p>Since <i>umask</i> affects the current shell execution environment, it is generally provided as a shell regular built-in. If it
    206 is called in a subshell or separate utility execution environment, such as one of the following:</p>
    207 <pre>
    208 <tt>(umask 002)
    209 nohup umask ...
    210 find . -exec umask ... \;
    211 </tt></pre>
    212 <p>it does not affect the file mode creation mask of the environment of the caller.</p>
    213 <p>The description of the historical utility was modified to allow it to use the symbolic modes of <a href=
    214 "../utilities/chmod.html"><i>chmod</i></a>. The <b>-s</b> option used in early proposals was changed to <b>-S</b> because <b>-s</b>
    215 could be confused with a <i>symbolic_mode</i> form of mask referring to the S_ISUID and S_ISGID bits.</p>
    216 <p>The default output style is unspecified to permit implementors to provide migration to the new symbolic style at the time most
    217 appropriate to their users. A <b>-o</b> flag to force octal mode output was omitted because the octal mode may not be sufficient to
    218 specify all of the information that may be present in the file mode creation mask when more secure file access permission checks
    219 are implemented.</p>
    220 <p>It has been suggested that trusted systems developers might appreciate ameliorating the requirement that the mode mask
    221 &quot;affects&quot; the file access permissions, since it seems access control lists might replace the mode mask to some degree. The
    222 wording has been changed to say that it affects the file permission bits, and it leaves the details of the behavior of how they
    223 affect the file access permissions to the description in the System Interfaces volume of POSIX.1-2024.</p>
    224 </blockquote>
    225 <h4 class="mansect"><a name="tag_20_132_19" id="tag_20_132_19"></a>FUTURE DIRECTIONS</h4>
    226 <blockquote>
    227 <p>None.</p>
    228 </blockquote>
    229 <h4 class="mansect"><a name="tag_20_132_20" id="tag_20_132_20"></a>SEE ALSO</h4>
    230 <blockquote>
    231 <p><a href="../utilities/V3_chap02.html#tag_19"><i>2. Shell Command Language</i></a> , <a href=
    232 "../utilities/chmod.html#tag_20_17"><i>chmod</i></a></p>
    233 <p>XBD <a href="../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a> , <a href=
    234 "../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax Guidelines</i></a></p>
    235 <p>XSH <a href="../functions/umask.html#tag_17_645"><i>umask</i></a></p>
    236 </blockquote>
    237 <h4 class="mansect"><a name="tag_20_132_21" id="tag_20_132_21"></a>CHANGE HISTORY</h4>
    238 <blockquote>
    239 <p>First released in Issue 2.</p>
    240 </blockquote>
    241 <h4 class="mansect"><a name="tag_20_132_22" id="tag_20_132_22"></a>Issue 6</h4>
    242 <blockquote>
    243 <p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p>
    244 <ul>
    245 <li>
    246 <p>The octal mode is supported.</p>
    247 </li>
    248 </ul>
    249 <p>IEEE&nbsp;Std&nbsp;1003.1-2001/Cor&nbsp;2-2004, item XCU/TC2/D6/34 is applied, making a correction to the RATIONALE.</p>
    250 </blockquote>
    251 <h4 class="mansect"><a name="tag_20_132_23" id="tag_20_132_23"></a>Issue 7</h4>
    252 <blockquote>
    253 <p>SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.</p>
    254 <p>POSIX.1-2008, Technical Corrigendum 2, XCU/TC2-2008/0197 [584] is applied.</p>
    255 </blockquote>
    256 <h4 class="mansect"><a name="tag_20_132_24" id="tag_20_132_24"></a>Issue 8</h4>
    257 <blockquote>
    258 <p>Austin Group Defect 854 is applied, adding a note to the APPLICATION USAGE section that this utility is required to be
    259 intrinsic.</p>
    260 <p>Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p>
    261 </blockquote>
    262 <div class="box"><em>End of informative text.</em></div>
    263 <hr>
    264 <p>&nbsp;</p>
    265 <a href="#top"><span class="topOfPage">return to top of page</span></a><br>
    266 <hr size="2" noshade>
    267 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br>
    268 POSIX™ is a Trademark of The IEEE.<br>
    269 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br>
    270 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
    271 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a>
    272 ]</font></center>
    273 <hr size="2" noshade>
    274 <div class="NAVHEADER">
    275 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0">
    276 <tr class="nav">
    277 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/ulimit.html" accesskey="P">&lt;&lt;&lt;
    278 Previous</a></td>
    279 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td>
    280 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/unalias.html" accesskey="N">Next
    281 &gt;&gt;&gt;</a></td>
    282 </tr>
    283 </table>
    284 <hr align="left" width="100%"></div>
    285 </body>
    286 </html>