⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newgrp.html

📁 IEEE 1003.1-2003, Single Unix Specification v3
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>newgrp</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="newgrp"></a> <a name="tag_04_91"></a><!-- newgrp --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright &copy; 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_04_91_01"></a>NAME</h4><blockquote>newgrp - change to a new group</blockquote><h4><a name="tag_04_91_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><div class="box"><code><tt><sup>[<a href="javascript:open_code('UP')">UP</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> newgrp</tt> <b>[</b><tt>-l</tt><b>][</b><i>group</i><b>]</b><tt><img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div></blockquote><h4><a name="tag_04_91_03"></a>DESCRIPTION</h4><blockquote><p>The <i>newgrp</i> utility shall create a new shell execution environment with a new real and effective group identification. Ofthe attributes listed in <a href="xcu_chap02.html#tag_02_12"><i>Shell Execution Environment</i></a> , the new shell executionenvironment shall retain the working directory, file creation mask, and exported variables from the previous environment (that is,open files, traps, unexported variables, alias definitions, shell functions, and <a href="../utilities/set.html"><i>set</i></a> options may be lost). All other aspects of the process environment that arepreserved by the <i>exec</i> family of functions defined in the System Interfaces volume of IEEE&nbsp;Std&nbsp;1003.1-2001 shallalso be preserved by <i>newgrp</i>; whether other aspects are preserved is unspecified.</p><p>A failure to assign the new group identifications (for example, for security or password-related reasons) shall not prevent thenew shell execution environment from being created.</p><p>The <i>newgrp</i> utility shall affect the supplemental groups for the process as follows:</p><ul><li><p>On systems where the effective group ID is normally in the supplementary group list (or whenever the old effective group IDactually is in the supplementary group list):</p><ul><li><p>If the new effective group ID is also in the supplementary group list, <i>newgrp</i> shall change the effective group ID.</p></li><li><p>If the new effective group ID is not in the supplementary group list, <i>newgrp</i> shall add the new effective group ID to thelist, if there is room to add it.</p></li></ul></li><li><p>On systems where the effective group ID is not normally in the supplementary group list (or whenever the old effective group IDis not in the supplementary group list):</p><ul><li><p>If the new effective group ID is in the supplementary group list, <i>newgrp</i> shall delete it.</p></li><li><p>If the old effective group ID is not in the supplementary list, <i>newgrp</i> shall add it if there is room.</p></li></ul></li></ul><basefont size="2"> <dl><dt><b>Note:</b></dt><dd>The System Interfaces volume of IEEE&nbsp;Std&nbsp;1003.1-2001 does not specify whether the effective group ID of a process isincluded in its supplementary group list.</dd></dl><basefont size="3"> <p>With no operands, <i>newgrp</i> shall change the effective group back to the groups identified in the user's user entry, andshall set the list of supplementary groups to that set in the user's group database entries.</p><p>If a password is required for the specified group, and the user is not listed as a member of that group in the group database,the user shall be prompted to enter the correct password for that group. If the user is listed as a member of that group, nopassword shall be requested. If no password is required for the specified group, it is implementation-defined whether users notlisted as members of that group can change to that group. Whether or not a password is required, implementation-defined systemaccounting or security mechanisms may impose additional authorization restrictions that may cause <i>newgrp</i> to write adiagnostic message and suppress the changing of the group identification.</p></blockquote><h4><a name="tag_04_91_04"></a>OPTIONS</h4><blockquote><p>The <i>newgrp</i> utility shall conform to the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/xbd_chap12.html#tag_12_02">Section 12.2, Utility Syntax Guidelines</a>.</p><p>The following option shall be supported:</p><dl compact><dt><b>-l</b></dt><dd>(The letter ell.) Change the environment to what would be expected if the user actually logged in again.</dd></dl></blockquote><h4><a name="tag_04_91_05"></a>OPERANDS</h4><blockquote><p>The following operand shall be supported:</p><dl compact><dt><i>group</i></dt><dd>A group name from the group database or a non-negative numeric group ID. Specifies the group ID to which the real and effectivegroup IDs shall be set. If <i>group</i> is a non-negative numeric string and exists in the group database as a group name (see <ahref="../functions/getgrnam.html"><i>getgrnam</i>()</a>), the numeric group ID associated with that group name shall be used as thegroup ID.</dd></dl></blockquote><h4><a name="tag_04_91_06"></a>STDIN</h4><blockquote><p>Not used.</p></blockquote><h4><a name="tag_04_91_07"></a>INPUT FILES</h4><blockquote><p>The file <b>/dev/tty</b> shall be used to read a single line of text for password checking, when one is required.</p></blockquote><h4><a name="tag_04_91_08"></a>ENVIRONMENT VARIABLES</h4><blockquote><p>The following environment variables shall affect the execution of <i>newgrp</i>:</p><dl compact><dt><i>LANG</i></dt><dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume ofIEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> forthe precedence of internationalization variables used to determine the values of locale categories.)</dd><dt><i>LC_ALL</i></dt><dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd><dt><i>LC_CTYPE</i></dt><dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte asopposed to multi-byte characters in arguments).</dd><dt><i>LC_MESSAGES</i></dt><dd>Determine the locale that should be used to affect the format and contents of diagnostic messages written to standarderror.</dd><dt><i>NLSPATH</i></dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Determine the location of message catalogs for the processing of <i>LC_MESSAGES .</i> <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl></blockquote><h4><a name="tag_04_91_09"></a>ASYNCHRONOUS EVENTS</h4><blockquote><p>Default.</p></blockquote><h4><a name="tag_04_91_10"></a>STDOUT</h4><blockquote><p>Not used.</p></blockquote><h4><a name="tag_04_91_11"></a>STDERR</h4><blockquote><p>The standard error shall be used for diagnostic messages and a prompt string for a password, if one is required. Diagnosticmessages may be written in cases where the exit status is not available. See the EXIT STATUS section.</p></blockquote><h4><a name="tag_04_91_12"></a>OUTPUT FILES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_91_13"></a>EXTENDED DESCRIPTION</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_91_14"></a>EXIT STATUS</h4><blockquote><p>If <i>newgrp</i> succeeds in creating a new shell execution environment, whether or not the group identification was changedsuccessfully, the exit status shall be the exit status of the shell. Otherwise, the following exit value shall be returned:</p><dl compact><dt>&gt;0</dt><dd>An error occurred.</dd></dl></blockquote><h4><a name="tag_04_91_15"></a>CONSEQUENCES OF ERRORS</h4><blockquote><p>The invoking shell may terminate.</p></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_04_91_16"></a>APPLICATION USAGE</h4><blockquote><p>There is no convenient way to enter a password into the group database. Use of group passwords is not encouraged, because bytheir very nature they encourage poor security practices. Group passwords may disappear in the future.</p><p>A common implementation of <i>newgrp</i> is that the current shell uses <i>exec</i> to overlay itself with <i>newgrp</i>, whichin turn overlays itself with a new shell after changing group. On some implementations, however, this may not occur and<i>newgrp</i> may be invoked as a subprocess.</p><p>The <i>newgrp</i> command is intended only for use from an interactive terminal. It does not offer a useful interface for thesupport of applications.</p><p>The exit status of <i>newgrp</i> is generally inapplicable. If <i>newgrp</i> is used in a script, in most cases it successfullyinvokes a new shell and the rest of the original shell script is bypassed when the new shell exits. Used interactively,<i>newgrp</i> displays diagnostic messages to indicate problems. But usage such as:</p><pre><tt>newgrp fooecho $?</tt></pre><p>is not useful because the new shell might not have access to any status <i>newgrp</i> may have generated (and most historicalsystems do not provide this status). A zero status echoed here does not necessarily indicate that the user has changed to the newgroup successfully. Following <i>newgrp</i> with the <a href="../utilities/id.html"><i>id</i></a> command provides a portable meansof determining whether the group change was successful or not.</p></blockquote><h4><a name="tag_04_91_17"></a>EXAMPLES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_91_18"></a>RATIONALE</h4><blockquote><p>Most historical implementations use one of the <i>exec</i> functions to implement the behavior of <i>newgrp</i>. Errors detectedbefore the <i>exec</i> leave the environment unchanged, while errors detected after the <i>exec</i> leave the user in a changedenvironment. While it would be useful to have <i>newgrp</i> issue a diagnostic message to tell the user that the environmentchanged, it would be inappropriate to require this change to some historical implementations.</p><p>The password mechanism is allowed in the group database, but how this would be implemented is not specified.</p><p>The <i>newgrp</i> utility was retained in this volume of IEEE&nbsp;Std&nbsp;1003.1-2001, even given the existence of themultiple group permissions feature in the System Interfaces volume of IEEE&nbsp;Std&nbsp;1003.1-2001, for several reasons. First,in some implementations, the group ownership of a newly created file is determined by the group of the directory in which the fileis created, as allowed by the System Interfaces volume of IEEE&nbsp;Std&nbsp;1003.1-2001; on other implementations, the groupownership of a newly created file is determined by the effective group ID. On implementations of the latter type, <i>newgrp</i>allows files to be created with a specific group ownership. Finally, many implementations use the real group ID in accounting, andon such systems, <i>newgrp</i> allows the accounting identity of the user to be changed.</p></blockquote><h4><a name="tag_04_91_19"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_91_20"></a>SEE ALSO</h4><blockquote><p><a href="xcu_chap02.html#tag_02"><i>Shell Command Language</i></a> , <a href="sh.html"><i>sh</i></a> , the System Interfacesvolume of IEEE&nbsp;Std&nbsp;1003.1-2001, <i>exec</i>, <a href="../functions/getgrnam.html"><i>getgrnam</i>()</a></p></blockquote><h4><a name="tag_04_91_21"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 2.</p></blockquote><h4><a name="tag_04_91_22"></a>Issue 6</h4><blockquote><p>This utility is marked as part of the User Portability Utilities option.</p><p>The obsolescent SYNOPSIS is removed.</p><p>The text describing supplemental groups is no longer conditional on {NGROUPS_MAX} being greater than 1. This is because{NGROUPS_MAX} now has a minimum value of 8. This is a FIPS requirement.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX &reg; is a registered Trademark of The Open Group.<br>POSIX &reg; is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -