]> git.cameronkatri.com Git - pw-darwin.git/blob - adduser/adduser.8
mdoc(7) police: overhaul.
[pw-darwin.git] / adduser / adduser.8
1 .\" Copyright (c) 1995-1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
2 .\" All rights reserved.
3 .\" Copyright (c) 2002 Michael Telahun Makonnen <makonnen@pacbell.net>
4 .\" All rights reserved.
5 .\"
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
8 .\" are met:
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\"
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 .\" SUCH DAMAGE.
26 .\"
27 .\" $FreeBSD$
28 .\"
29 .Dd August 14, 2002
30 .Dt ADDUSER 8
31 .Os
32 .Sh NAME
33 .Nm adduser
34 .Nd command for adding new users
35 .Sh SYNOPSIS
36 .Nm
37 .Op Fl CENhq
38 .Op Fl G Ar groups
39 .Op Fl L Ar login_class
40 .Op Fl d Ar partition
41 .Op Fl f Ar file
42 .Op Fl k Ar dotdir
43 .Op Fl m Ar message_file
44 .Op Fl s Ar shell
45 .Op Fl u Ar uid_start
46 .Op Fl w Ar type
47 .Sh DESCRIPTION
48 The
49 .Nm
50 utility is a shell script, implemented around the
51 .Xr pw 8
52 command, for adding new users.
53 It creates passwd/group entries, a home directory,
54 copies dotfiles and sends the new user a welcome message.
55 It supports two modes of operation.
56 It may be used interactively
57 at the command line to add one user at a time, or it may be directed
58 to get the list of new users from a file and operate in batch mode
59 without requiring any user interaction.
60 .Sh RESTRICTIONS
61 .Bl -tag -width indent
62 .It username
63 Login name.
64 The user name is restricted to whatever
65 .Xr pw 8
66 will accept.
67 Generally this means it
68 may contain only lowercase characters or digits.
69 Maximum length
70 is 16 characters.
71 The reasons for this limit are historical.
72 Given that people have traditionally wanted to break this
73 limit for aesthetic reasons, it has never been of great importance to break
74 such a basic fundamental parameter in
75 .Ux .
76 You can change
77 .Dv UT_NAMESIZE
78 in
79 .Pa /usr/include/utmp.h
80 and recompile the
81 world; people have done this and it works, but you will have problems
82 with any precompiled programs, or source that assumes the 8-character
83 name limit and NIS.
84 The NIS protocol mandates an 8-character username.
85 If you need a longer login name for e-mail addresses,
86 you can define an alias in
87 .Pa /etc/mail/aliases .
88 .It "full name"
89 This is typically known as the gecos field and usually contains
90 the user's full name.
91 Additionally, it may contain a comma separated
92 list of values such as office number and work and home phones.
93 If the
94 name contains an amperstand it will be replaced by the capitalized
95 login name when displayed by other programs.
96 The
97 .Ql \&:
98 character is not allowed.
99 .It shell
100 Only valid shells from the shell database
101 .Pq Pa /etc/shells
102 are allowed.
103 In
104 addition, only the base name of the shell is necessary, not the full path.
105 .It UID
106 Automatically generated or your choice.
107 It must be less than 32000.
108 .It "GID/login group"
109 Automatically generated or your choice.
110 It must be less than 32000.
111 .It password
112 You may choose an empty password, disable the password, use a
113 randomly generated password or specify your own plaintext password,
114 which will be encrypted before being stored in the user database.
115 .El
116 .Sh UNIQUE GROUPS
117 Perhaps you are missing what
118 .Em can
119 be done with this scheme that falls apart
120 with most other schemes.
121 With each user in his/her own group, the user can
122 safely run with a umask of 002 instead of the usual 022
123 and create files in their home directory
124 without worrying about others being able to change them.
125 .Pp
126 For a shared area you create a separate UID/GID (like cvs or ncvs on freefall),
127 you place each person that should be able to access this area into that new
128 group.
129 .Pp
130 This model of UID/GID administration allows far greater flexibility than lumping
131 users into groups and having to muck with the umask when working in a shared
132 area.
133 .Pp
134 I have been using this model for almost 10 years and found that it works
135 for most situations, and has never gotten in the way.
136 (Rod Grimes)
137 .Sh CONFIGURATION
138 The
139 .Nm
140 utility reads its configuration information from
141 .Pa /etc/adduser.conf .
142 If this file does not exist, it will use predefined defaults.
143 While this file may be edited by hand,
144 the safer option is to use the
145 .Fl C
146 command line argument.
147 With this argument,
148 .Nm
149 will start interactive input, save the answers to its prompts in
150 .Pa /etc/adduser.conf ,
151 and promptly exit without modifying the user
152 database.
153 Options specified on the command line will take precedence over
154 any values saved in this file.
155 .Sh OPTIONS
156 .Bl -tag -width indent
157 .It Fl C
158 Create new configuration file and exit.
159 This option is mutually exclusive with the
160 .Fl f
161 option.
162 .It Fl d Ar partition
163 Home partition.
164 Default partition, under which all user directories
165 will be located.
166 .It Fl E
167 Disable the account.
168 This option will lock the account by prepending the string
169 .Dq Li *LOCKED*
170 to the password field.
171 The account may be unlocked
172 by the super-user with the
173 .Xr pw 8
174 command:
175 .Pp
176 .D1 Nm pw Cm unlock Op Ar name | uid
177 .It Fl f Ar file
178 Get the list of accounts to create from
179 .Ar file .
180 If
181 .Ar file
182 is
183 .Dq Fl ,
184 then get the list from standard input.
185 If this option is specified,
186 .Nm
187 will operate in batch mode and will not seek any user input.
188 If an error is encountered while processing an account, it will write a
189 message to standard error and move to the next account.
190 The format
191 of the input file is described below.
192 .It Fl G Ar groups
193 Additional groups.
194 By default, the user name is used as the login group.
195 This option allows the user to specify additional groups to add users to.
196 .It Fl h
197 Print a summary of options and exit.
198 .It Fl k Ar directory
199 Copy files from
200 .Ar directory
201 into the home
202 directory of new users;
203 .Pa dot.foo
204 will be renamed to
205 .Pa .foo .
206 .It Fl L Ar login_class
207 Set default login class.
208 .It Fl m Ar file
209 Send new users a welcome message from
210 .Ar file .
211 Specifying a value of
212 .Cm no
213 for
214 .Ar file
215 causes no message to be sent to new users.
216 Please note that the message
217 file can reference the internal variables of the
218 .Nm
219 script.
220 .It Fl N
221 Do not read the default configuration file.
222 .It Fl q
223 Minimal user feedback.
224 In particular, the random password will not be echoed to
225 standard output.
226 .It Fl s Ar shell
227 Default shell for new users.
228 The
229 .Ar shell
230 argument must be the base name of the shell,
231 .Em not
232 the full path.
233 It must exist in
234 .Pa /etc/shells
235 to be considered a valid shell.
236 .It Fl u Ar uid
237 Use UIDs from
238 .Ar uid
239 on up.
240 .It Fl w Ar type
241 Password type.
242 The
243 .Nm
244 utility allows the user to specify what type of password to create.
245 The
246 .Ar type
247 argument may have one of the following values:
248 .Bl -tag -width ".Cm random"
249 .It Cm no
250 Disable the password.
251 Instead of an encrypted string, the passowrd field will contain a single
252 .Ql *
253 character.
254 The user may not log in until the super-user
255 manually enables the password.
256 .It Cm none
257 Use an empty string as the password.
258 .It Cm yes
259 Use a user-supplied string as the password.
260 In interactive mode,
261 the user will be prompted for the password.
262 In batch mode, the
263 last (10th) field in the line is assumed to be the password.
264 .It Cm random
265 Generate a random string and use it as a password.
266 The password will be echoed to standard output.
267 In addition, it will be available for inclusion in the message file in the
268 .Va randompass
269 variable.
270 .El
271 .El
272 .Sh FORMAT
273 When the
274 .Fl f
275 option is used, the account information must be stored in a specific
276 format.
277 All empty lines or lines beginning with a
278 .Ql #
279 will be ignored.
280 All other lines must contain ten colon
281 .Pq Ql \&:
282 separated fields as described below.
283 Command line options do not take precedence
284 over values in the fields.
285 Only the password field may contain a
286 .Ql \&:
287 character as part of the string.
288 .Pp
289 .Sm off
290 .D1 Ar name : uid : gid : class : change : expire : gecos : home_dir : shell : password
291 .Sm on
292 .Bl -tag -width ".Ar password"
293 .It Ar name
294 Login name.
295 This field may not be empty.
296 .It Ar uid
297 Numeric login user ID.
298 If this field is left empty, it will be automatically generated.
299 .It Ar gid
300 Numeric primary group ID.
301 If this field is left empty, a group with the
302 same name as the user name will be created and its GID will be used
303 instead.
304 .It Ar class
305 Login class.
306 This field may be left empty.
307 .It Ar change
308 Password ageing.
309 This field denotes the password change date for the account.
310 The format of this field is the same as the format of the
311 .Fl p
312 argument to
313 .Xr pw 8 .
314 It may be
315 .Ar dd Ns - Ns Ar mmm Ns - Ns Ar yy Ns Op Ar yy ,
316 where
317 .Ar dd
318 is for the day,
319 .Ar mmm
320 is for the month in numeric or alphabetical format:
321 .Dq Li 10
322 or
323 .Dq Li Oct ,
324 and
325 .Ar yy Ns Op Ar yy
326 is the four or two digit year.
327 To denote a time relative to the current date the format is:
328 .No + Ns Ar n Ns Op Ar mhdwoy ,
329 where
330 .Ar n
331 denotes a number, followed by the minutes, hours, days, weeks,
332 months or years after which the password must be changed.
333 This field may be left empty to turn it off.
334 .It Ar expire
335 Account expiration.
336 This field denotes the expiry date of the account.
337 The account may not be used after the specified date.
338 The format of this field is the same as that for password ageing.
339 This field may be left empty to turn it off.
340 .It Ar gecos
341 Full name and other extra information about the user.
342 .It Ar home_dir
343 Home directory.
344 If this field is left empty, it will be automatically
345 created by appending the username to the home partition.
346 .It Ar shell
347 Login shell.
348 This field should contain the full path to a valid login shell.
349 .It Ar password
350 User password.
351 This field should contain a plaintext string, which will
352 be encrypted before being placed in the user database.
353 If the password type is
354 .Cm yes
355 and this field is empty, it is assumed the account will have an empty password.
356 If the password type is
357 .Cm random
358 and this field is
359 .Em not
360 empty, its contents will be used
361 as a password.
362 This field will be ignored if the
363 .Fl p
364 option is used with a
365 .Cm no
366 or
367 .Cm none
368 argument.
369 Be carefull not to terminate this field with a closing
370 .Ql \&:
371 because it will be treated as part of the password.
372 .El
373 .Sh FILES
374 .Bl -tag -width ".Pa /etc/adduser.message" -compact
375 .It Pa /etc/master.passwd
376 user database
377 .It Pa /etc/group
378 group database
379 .It Pa /etc/shells
380 shell database
381 .It Pa /etc/login.conf
382 login classes database
383 .It Pa /etc/adduser.conf
384 configuration file for
385 .Nm
386 .It Pa /etc/adduser.message
387 message file for
388 .Nm
389 .It Pa /usr/share/skel
390 skeletal login directory
391 .It Pa /var/log/adduser
392 logfile for
393 .Nm
394 .El
395 .Sh SEE ALSO
396 .Xr chpass 1 ,
397 .Xr passwd 1 ,
398 .Xr aliases 5 ,
399 .Xr group 5 ,
400 .Xr login.conf 5 ,
401 .Xr passwd 5 ,
402 .Xr shells 5 ,
403 .Xr pw 8 ,
404 .Xr pwd_mkdb 8 ,
405 .Xr rmuser 8 ,
406 .Xr vipw 8 ,
407 .Xr yp 8
408 .Sh HISTORY
409 The
410 .Nm
411 command appeared in
412 .Fx 2.1 .
413 .Sh AUTHORS
414 .An -nosplit
415 This manual page and the original script, in Perl, was written by
416 .An Wolfram Schneider Aq wosch@FreeBSD.org .
417 The replacement script, written as a Bourne
418 shell script with some enhancements, and the man page modification that
419 came with it were done by
420 .An Mike Makonnen Aq mtm@identd.net .
421 .Sh BUGS
422 In order for
423 .Nm
424 to correctly expand variables such as
425 .Va $username
426 and
427 .Va $randompass
428 in the message sent to new users, it must let the shell evaluate
429 each line of the message file.
430 This means that shell commands can also be embedded in the message file.
431 The
432 .Nm
433 utility attemps to mitigate the possibility of an attacker using this
434 feature by refusing to evaluate the file if it is not owned and writeable
435 only by the root user.
436 In addition, shell special characters and operators will have to be
437 escaped when used in the message file.
438 .Pp
439 Also, password ageing and account expiry times are currently setable
440 only in batch mode.
441 The user should be able to set them in interactive mode as well.