xref: /freebsd/usr.bin/chpass/chpass.1 (revision dcc4d2939f789a6d1f272ffeab2068ba2b7525ea)
1.\" Copyright (c) 1988, 1990, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"     @(#)chpass.1	8.2 (Berkeley) 12/30/93
29.\"
30.Dd May 25, 2021
31.Dt CHPASS 1
32.Os
33.Sh NAME
34.Nm chpass ,
35.Nm chfn ,
36.Nm chsh ,
37.Nm ypchpass ,
38.Nm ypchfn ,
39.Nm ypchsh
40.Nd add or change user database information
41.Sh SYNOPSIS
42.Nm chpass
43.Op Fl a Ar list
44.Op Fl e Ar expiretime
45.Op Fl p Ar encpass
46.Op Fl s Ar newshell
47.Op user
48.Nm ypchpass
49.Op Fl loy
50.Op Fl a Ar list
51.Op Fl d Ar domain
52.Op Fl e Ar expiretime
53.Op Fl h Ar host
54.Op Fl p Ar encpass
55.Op Fl s Ar newshell
56.Op user
57.Sh DESCRIPTION
58The
59.Nm
60utility
61allows editing of the user database information associated
62with
63.Ar user
64or, by default, the current user.
65.Pp
66The
67.Nm chfn ,
68.Nm chsh ,
69.Nm ypchpass ,
70.Nm ypchfn
71and
72.Nm ypchsh
73utilities behave identically to
74.Nm .
75(There is only one program.)
76.Pp
77The information is formatted and supplied to an editor for changes.
78.Pp
79Only the information that the user is allowed to change is displayed.
80.Pp
81The options are as follows:
82.Bl -tag -width "-e expiretime"
83.It Fl a Ar list
84The super-user is allowed to directly supply a user database
85entry, in the format specified by
86.Xr passwd 5 ,
87as an argument.
88This argument must be a colon
89.Pq Dq \&:
90separated list of all the
91user database fields, although they may be empty.
92.It Fl e Ar expiretime
93Change the account expire time.
94This option is used to set the expire time
95from a script as if it was done in the interactive editor.
96.It Fl p Ar encpass
97The super-user is allowed to directly supply an encrypted password field,
98in the format used by
99.Xr crypt 3 ,
100as an argument.
101.It Fl s Ar newshell
102Attempt to change the user's shell to
103.Ar newshell .
104.El
105.Pp
106Possible display items are as follows:
107.Pp
108.Bl -tag -width "Other Information:" -compact -offset indent
109.It Login:
110user's login name
111.It Password:
112user's encrypted password
113.It Uid:
114user's login
115.It Gid:
116user's login group
117.It Class:
118user's general classification
119.It Change:
120password change time
121.It Expire:
122account expiration time
123.It Full Name:
124user's real name
125.It Office Location:
126user's office location (1)
127.It Office Phone:
128user's office phone (1)
129.It Home Phone:
130user's home phone (1)
131.It Other Information:
132any locally defined parameters for user (1)
133.It Home Directory:
134user's home directory
135.It Shell:
136user's login shell
137.Pp
138.It NOTE(1) -
139In the actual master.passwd file, these fields are comma-delimited
140fields embedded in the FullName field.
141.El
142.Pp
143The
144.Ar login
145field is the user name used to access the computer account.
146.Pp
147The
148.Ar password
149field contains the encrypted form of the user's password.
150.Pp
151The
152.Ar uid
153field is the number associated with the
154.Ar login
155field.
156Both of these fields should be unique across the system (and often
157across a group of systems) as they control file access.
158.Pp
159While it is possible to have multiple entries with identical login names
160and/or identical user id's, it is usually a mistake to do so.
161Routines
162that manipulate these files will often return only one of the multiple
163entries, and that one by random selection.
164.Pp
165The
166.Ar gid
167field is the group that the user will be placed in at login.
168Since
169.Bx
170supports multiple groups (see
171.Xr groups 1 )
172this field currently has little special meaning.
173This field may be filled in with either a number or a group name (see
174.Xr group 5 ) .
175.Pp
176The
177.Ar class
178field references class descriptions in
179.Pa /etc/login.conf
180and is typically used to initialize the user's system resource limits
181when they login.
182.Pp
183The
184.Ar change
185field is the date by which the password must be changed.
186.Pp
187The
188.Ar expire
189field is the date on which the account expires.
190.Pp
191Both the
192.Ar change
193and
194.Ar expire
195fields should be entered in the form
196.Dq month day year
197where
198.Ar month
199is the month name (the first three characters are sufficient),
200.Ar day
201is the day of the month, and
202.Ar year
203is the year.
204.Pp
205Five fields are available for storing the user's
206.Ar full name , office location ,
207.Ar work
208and
209.Ar home telephone
210numbers and finally
211.Ar other information
212which is a single comma delimited string to represent any additional
213gecos fields (typically used for site specific user information).
214Note that
215.Xr finger 1
216will display the office location and office phone together under the
217heading
218.Ar Office\&: .
219.Pp
220The user's
221.Ar home directory
222is the full
223.Ux
224path name where the user
225will be placed at login.
226.Pp
227The
228.Ar shell
229field is the command interpreter the user prefers.
230If the
231.Ar shell
232field is empty, the Bourne shell,
233.Pa /bin/sh ,
234is assumed.
235When altering a login shell, and not the super-user, the user
236may not change from a non-standard shell or to a non-standard
237shell.
238Non-standard is defined as a shell not found in
239.Pa /etc/shells .
240.Pp
241Once the information has been verified,
242.Nm
243uses
244.Xr pwd_mkdb 8
245to update the user database.
246.Sh ENVIRONMENT
247The
248.Xr vi 1
249editor will be used unless the environment variable
250.Ev EDITOR
251is set to
252an alternate editor.
253When the editor terminates, the information is re-read and used to
254update the user database itself.
255Only the user, or the super-user, may edit the information associated
256with the user.
257.Pp
258See
259.Xr pwd_mkdb 8
260for an explanation of the impact of setting the
261.Ev PW_SCAN_BIG_IDS
262environment variable.
263.Sh NIS INTERACTION
264The
265.Nm
266utility can also be used in conjunction with NIS, however some restrictions
267apply.
268Currently,
269.Nm
270can only make changes to the NIS passwd maps through
271.Xr rpc.yppasswdd 8 ,
272which normally only permits changes to a user's password, shell and GECOS
273fields.
274Except when invoked by the super-user on the NIS master server,
275.Nm
276(and, similarly,
277.Xr passwd 1 )
278cannot use the
279.Xr rpc.yppasswdd 8
280server to change other user information or
281add new records to the NIS passwd maps.
282Furthermore,
283.Xr rpc.yppasswdd 8
284requires password authentication before it will make any
285changes.
286The only user allowed to submit changes without supplying
287a password is the super-user on the NIS master server; all other users,
288including those with root privileges on NIS clients (and NIS slave
289servers) must enter a password.
290(The super-user on the NIS master is allowed to bypass these restrictions
291largely for convenience: a user with root access
292to the NIS master server already has the privileges required to make
293updates to the NIS maps, but editing the map source files by hand can
294be cumbersome.
295.Pp
296Note: these exceptions only apply when the NIS master server is a
297.Fx
298system).
299.Pp
300Consequently, except where noted, the following restrictions apply when
301.Nm
302is used with NIS:
303.Bl -enum -offset indent
304.It
305.Em "Only the shell and GECOS information may be changed" .
306All other
307fields are restricted, even when
308.Nm
309is invoked by the super-user.
310While support for
311changing other fields could be added, this would lead to
312compatibility problems with other NIS-capable systems.
313Even though the super-user may supply data for other fields
314while editing an entry, the extra information (other than the
315password \(em see below) will be silently discarded.
316.Pp
317Exception: the super-user on the NIS master server is permitted to
318change any field.
319.It
320.Em "Password authentication is required" .
321The
322.Nm
323utility will prompt for the user's NIS password before effecting
324any changes.
325If the password is invalid, all changes will be
326discarded.
327.Pp
328Exception: the super-user on the NIS master server is allowed to
329submit changes without supplying a password.
330(The super-user may
331choose to turn off this feature using the
332.Fl o
333flag, described below.)
334.It
335.Em "Adding new records to the local password database is discouraged" .
336The
337.Nm
338utility will allow the administrator to add new records to the
339local password database while NIS is enabled, but this can lead to
340some confusion since the new records are appended to the end of
341the master password file, usually after the special NIS '+' entries.
342The administrator should use
343.Xr vipw 8
344to modify the local password
345file when NIS is running.
346.Pp
347The super-user on the NIS master server is permitted to add new records
348to the NIS password maps, provided the
349.Xr rpc.yppasswdd 8
350server has been started with the
351.Fl a
352flag to permitted additions (it refuses them by default).
353The
354.Nm
355utility tries to update the local password database by default; to update the
356NIS maps instead, invoke chpass with the
357.Fl y
358flag.
359.It
360.Em "Password changes are not permitted".
361Users should use
362.Xr passwd 1
363or
364.Xr yppasswd 1
365to change their NIS passwords.
366The super-user is allowed to specify
367a new password (even though the
368.Dq Password:
369field does not show
370up in the editor template, the super-user may add it back by hand),
371but even the super-user must supply the user's original password
372otherwise
373.Xr rpc.yppasswdd 8
374will refuse to update the NIS maps.
375.Pp
376Exception: the super-user on the NIS master server is permitted to
377change a user's NIS password with
378.Nm .
379.El
380.Pp
381There are also a few extra option flags that are available when
382.Nm
383is compiled with NIS support:
384.Bl -tag -width "-d domain"
385.It Fl d Ar domain
386Specify a particular NIS domain.
387The
388.Nm
389utility uses the system domain name by default, as set by the
390.Xr domainname 1
391utility.
392The
393.Fl d
394option can be used to override a default, or to specify a domain
395when the system domain name is not set.
396.It Fl h Ar host
397Specify the name or address of an NIS server to query.
398Normally,
399.Nm
400will communicate with the NIS master host specified in the
401.Pa master.passwd
402or
403.Pa passwd
404maps.
405On hosts that have not been configured as NIS clients, there is
406no way for the program to determine this information unless the user
407provides the hostname of a server.
408Note that the specified hostname need
409not be that of the NIS master server; the name of any server, master or
410slave, in a given NIS domain will do.
411.Pp
412When using the
413.Fl d
414option, the hostname defaults to
415.Dq localhost .
416The
417.Fl h
418option can be used in conjunction with the
419.Fl d
420option, in which case the user-specified hostname will override
421the default.
422.It Fl l
423Force
424.Nm
425to modify the local copy of a user's password
426information in the event that a user exists in both
427the local and NIS databases.
428.It Fl o
429Force the use of RPC-based updates when communicating with
430.Xr rpc.yppasswdd 8
431.Pq Dq old-mode .
432When invoked by the super-user on the NIS master server,
433.Nm
434allows unrestricted changes to the NIS passwd maps using dedicated,
435non-RPC-based mechanism (in this case, a
436.Ux
437domain socket).
438The
439.Fl o
440flag can be used to force
441.Nm
442to use the standard update mechanism instead.
443This option is provided
444mainly for testing purposes.
445.It Fl y
446Opposite effect of
447.Fl l .
448This flag is largely redundant since
449.Nm
450operates on NIS entries by default if NIS is enabled.
451.El
452.Sh FILES
453.Bl -tag -width /etc/master.passwd -compact
454.It Pa /etc/master.passwd
455the user database
456.It Pa /etc/passwd
457a Version 7 format password file
458.It Pa /etc/pw.XXXXXX
459temporary file
460.It Pa /etc/shells
461the list of approved shells
462.El
463.Sh EXAMPLES
464Change the shell of the current user to
465.Ql /usr/local/bin/zsh :
466.Bd -literal -offset indent
467chsh -s /usr/local/bin/zsh
468.Ed
469.Sh SEE ALSO
470.Xr finger 1 ,
471.Xr login 1 ,
472.Xr passwd 1 ,
473.Xr getusershell 3 ,
474.Xr login.conf 5 ,
475.Xr passwd 5 ,
476.Xr pw 8 ,
477.Xr pwd_mkdb 8 ,
478.Xr vipw 8
479.Rs
480.%A Robert Morris
481.%A Ken Thompson
482.%T "UNIX Password security"
483.Re
484.Sh HISTORY
485The
486.Nm
487utility appeared in
488.Bx 4.3 Reno .
489.Sh BUGS
490User information should (and eventually will) be stored elsewhere.
491