1NEWGRP(1P)                 POSIX Programmer's Manual                NEWGRP(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       newgrp - change to a new group
13

SYNOPSIS

15       newgrp [-l][group]
16

DESCRIPTION

18       The newgrp utility shall create a new shell execution environment  with
19       a new real and effective group identification. Of the attributes listed
20       in Shell Execution Environment, the  new  shell  execution  environment
21       shall  retain  the  working directory, file creation mask, and exported
22       variables from the previous environment (that is,  open  files,  traps,
23       unexported  variables,  alias  definitions,  shell  functions,  and set
24       options may be lost). All other aspects of the process environment that
25       are  preserved  by  the  exec family of functions defined in the System
26       Interfaces volume of IEEE Std 1003.1-2001 shall also  be  preserved  by
27       newgrp; whether other aspects are preserved is unspecified.
28
29       A  failure  to  assign  the new group identifications (for example, for
30       security or password-related reasons) shall not prevent the  new  shell
31       execution environment from being created.
32
33       The newgrp utility shall affect the supplemental groups for the process
34       as follows:
35
36        * On systems where the effective group ID is normally in  the  supple‐
37          mentary  group list (or whenever the old effective group ID actually
38          is in the supplementary group list):
39
40           * If the new effective group ID is also in the supplementary  group
41             list, newgrp shall change the effective group ID.
42
43           * If  the  new effective group ID is not in the supplementary group
44             list, newgrp shall add the new effective group ID to the list, if
45             there is room to add it.
46
47        * On  systems where the effective group ID is not normally in the sup‐
48          plementary group list (or whenever the old effective group ID is not
49          in the supplementary group list):
50
51           * If the new effective group ID is in the supplementary group list,
52             newgrp shall delete it.
53
54           * If the old effective group ID is not in the  supplementary  list,
55             newgrp shall add it if there is room.
56
57       Note:  The  System  Interfaces  volume of IEEE Std 1003.1-2001 does not
58              specify whether the effective group ID of a process is  included
59              in its supplementary group list.
60
61
62       With  no  operands, newgrp shall change the effective group back to the
63       groups identified in the user's user entry, and shall set the  list  of
64       supplementary groups to that set in the user's group database entries.
65
66       If  a password is required for the specified group, and the user is not
67       listed as a member of that group in the group database, the user  shall
68       be  prompted  to enter the correct password for that group. If the user
69       is listed as a member of that group, no password shall be requested. If
70       no  password is required for the specified group, it is implementation-
71       defined whether users not listed as members of that group can change to
72       that  group.  Whether  or  not  a password is required, implementation-
73       defined system accounting or security mechanisms may impose  additional
74       authorization  restrictions that may cause newgrp to write a diagnostic
75       message and suppress the changing of the group identification.
76

OPTIONS

78       The newgrp utility shall conform to  the  Base  Definitions  volume  of
79       IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
80
81       The following option shall be supported:
82
83       -l     (The  letter  ell.)  Change  the  environment  to  what would be
84              expected if the user actually logged in again.
85
86

OPERANDS

88       The following operand shall be supported:
89
90       group  A group name from the group database or a  non-negative  numeric
91              group ID. Specifies the group ID to which the real and effective
92              group IDs shall be set.  If  group  is  a  non-negative  numeric
93              string  and  exists  in  the group database as a group name (see
94              getgrnam()), the numeric group ID  associated  with  that  group
95              name shall be used as the group ID.
96
97

STDIN

99       Not used.
100

INPUT FILES

102       The file /dev/tty shall be used to read a single line of text for pass‐
103       word checking, when one is required.
104

ENVIRONMENT VARIABLES

106       The following environment variables shall affect the execution of  new‐
107       grp:
108
109       LANG   Provide  a  default value for the internationalization variables
110              that are unset or null. (See  the  Base  Definitions  volume  of
111              IEEE Std 1003.1-2001,  Section  8.2,  Internationalization Vari‐
112              ables for the precedence of internationalization variables  used
113              to determine the values of locale categories.)
114
115       LC_ALL If  set  to a non-empty string value, override the values of all
116              the other internationalization variables.
117
118       LC_CTYPE
119              Determine the locale for  the  interpretation  of  sequences  of
120              bytes  of  text  data as characters (for example, single-byte as
121              opposed to multi-byte characters in arguments).
122
123       LC_MESSAGES
124              Determine the locale that should be used to  affect  the  format
125              and contents of diagnostic messages written to standard error.
126
127       NLSPATH
128              Determine the location of message catalogs for the processing of
129              LC_MESSAGES .
130
131

ASYNCHRONOUS EVENTS

133       Default.
134

STDOUT

136       Not used.
137

STDERR

139       The standard error shall be used for diagnostic messages and  a  prompt
140       string  for  a password, if one is required. Diagnostic messages may be
141       written in cases where the exit status is not available.  See the  EXIT
142       STATUS section.
143

OUTPUT FILES

145       None.
146

EXTENDED DESCRIPTION

148       None.
149

EXIT STATUS

151       If  newgrp  succeeds  in  creating  a  new shell execution environment,
152       whether or not the group identification was changed  successfully,  the
153       exit status shall be the exit status of the shell.  Otherwise, the fol‐
154       lowing exit value shall be returned:
155
156       >0     An error occurred.
157
158

CONSEQUENCES OF ERRORS

160       The invoking shell may terminate.
161
162       The following sections are informative.
163

APPLICATION USAGE

165       There is no convenient way to enter a password into the group database.
166       Use  of group passwords is not encouraged, because by their very nature
167       they encourage poor security practices. Group passwords  may  disappear
168       in the future.
169
170       A  common  implementation of newgrp is that the current shell uses exec
171       to overlay itself with newgrp, which in turn overlays itself with a new
172       shell  after changing group. On some implementations, however, this may
173       not occur and newgrp may be invoked as a subprocess.
174
175       The newgrp command is intended only for use from an interactive  termi‐
176       nal.  It  does not offer a useful interface for the support of applica‐
177       tions.
178
179       The exit status of newgrp is generally inapplicable. If newgrp is  used
180       in  a script, in most cases it successfully invokes a new shell and the
181       rest of the original shell script is bypassed when the new shell exits.
182       Used  interactively,  newgrp  displays  diagnostic messages to indicate
183       problems. But usage such as:
184
185
186              newgrp foo
187              echo $?
188
189       is not useful because the new shell might not have access to any status
190       newgrp  may  have generated (and most historical systems do not provide
191       this status). A zero status echoed here does not  necessarily  indicate
192       that the user has changed to the new group successfully. Following new‐
193       grp with the id  command  provides  a  portable  means  of  determining
194       whether the group change was successful or not.
195

EXAMPLES

197       None.
198

RATIONALE

200       Most historical implementations use one of the exec functions to imple‐
201       ment the behavior of newgrp. Errors detected before the exec leave  the
202       environment  unchanged,  while errors detected after the exec leave the
203       user in a changed environment. While it would be useful to have  newgrp
204       issue  a  diagnostic  message  to  tell  the  user that the environment
205       changed, it would be inappropriate to require this change to some  his‐
206       torical implementations.
207
208       The  password  mechanism is allowed in the group database, but how this
209       would be implemented is not specified.
210
211       The newgrp utility was retained in this volume of IEEE Std 1003.1-2001,
212       even  given  the existence of the multiple group permissions feature in
213       the System Interfaces volume of IEEE Std 1003.1-2001, for several  rea‐
214       sons.  First,  in  some implementations, the group ownership of a newly
215       created file is determined by the group of the directory in  which  the
216       file  is  created,  as  allowed  by  the  System  Interfaces  volume of
217       IEEE Std 1003.1-2001; on other implementations, the group ownership  of
218       a newly created file is determined by the effective group ID. On imple‐
219       mentations of the latter type, newgrp allows files to be created with a
220       specific  group  ownership.  Finally, many implementations use the real
221       group ID in accounting, and on such systems, newgrp allows the account‐
222       ing identity of the user to be changed.
223

FUTURE DIRECTIONS

225       None.
226

SEE ALSO

228       Shell   Command   Language,   sh,   the  System  Interfaces  volume  of
229       IEEE Std 1003.1-2001, exec, getgrnam()
230
232       Portions of this text are reprinted and reproduced in  electronic  form
233       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
234       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
235       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
236       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
237       event of any discrepancy between this version and the original IEEE and
238       The Open Group Standard, the original IEEE and The Open Group  Standard
239       is  the  referee document. The original Standard can be obtained online
240       at http://www.opengroup.org/unix/online.html .
241
242
243
244IEEE/The Open Group                  2003                           NEWGRP(1P)
Impressum