Update to systemd-231
[linux_from_scratch.git] / BOOK / chapter06 / shadow.xml
blob66482202c523424ccdb1404f94222c053d59f6a4
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3   "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4   <!ENTITY % general-entities SYSTEM "../general.ent">
5   %general-entities;
6 ]>
8 <sect1 id="ch-system-shadow" role="wrap">
9   <?dbhtml filename="shadow.html"?>
11   <sect1info condition="script">
12     <productname>shadow</productname>
13     <productnumber>&shadow-version;</productnumber>
14     <address>&shadow-url;</address>
15   </sect1info>
17   <title>Shadow-&shadow-version;</title>
19   <indexterm zone="ch-system-shadow">
20     <primary sortas="a-Shadow">Shadow</primary>
21   </indexterm>
23   <sect2 role="package">
24     <title/>
26     <para>The Shadow package contains programs for handling passwords in a secure
27     way.</para>
29     <segmentedlist>
30       <segtitle>&buildtime;</segtitle>
31       <segtitle>&diskspace;</segtitle>
33       <seglistitem>
34         <seg>&shadow-ch6-sbu;</seg>
35         <seg>&shadow-ch6-du;</seg>
36       </seglistitem>
37     </segmentedlist>
39   </sect2>
41   <sect2 role="installation">
42     <title>Installation of Shadow</title>
44     <note>
45       <para>If you would like to enforce the use of strong passwords, refer to
46       <ulink url="&blfs-book;postlfs/cracklib.html"/> for installing
47       CrackLib prior to building Shadow. Then add
48       <parameter>--with-libcrack</parameter> to the <command>configure</command>
49       command below.</para>
50     </note>
52     <para>Disable the installation of the <command>groups</command> program
53     and its man pages, as Coreutils provides a better version. Also 
54     Prevent the installation of manual pages that were already installed by the
55     <xref linkend="man-pages"/> package:</para>
57 <screen><userinput remap="pre">sed -i 's/groups$(EXEEXT) //' src/Makefile.in
58 find man -name Makefile.in -exec sed -i 's/groups\.1 / /'   {} \;
59 find man -name Makefile.in -exec sed -i 's/getspnam\.3 / /' {} \;
60 find man -name Makefile.in -exec sed -i 's/passwd\.5 / /'   {} \;</userinput></screen>
62     <para id="shadow-login_defs">Instead of using the default
63     <emphasis>crypt</emphasis> method, use the more secure
64     <emphasis>SHA-512</emphasis> method of password encryption, which also
65     allows passwords longer than 8 characters. It is also necessary to change
66     the obsolete <filename class="directory">/var/spool/mail</filename> location
67     for user mailboxes that Shadow uses by default to the <filename
68     class="directory">/var/mail</filename> location used currently:</para>
70 <screen><userinput remap="configure">sed -i -e 's@#ENCRYPT_METHOD DES@ENCRYPT_METHOD SHA512@' \
71        -e 's@/var/spool/mail@/var/mail@' etc/login.defs</userinput></screen>
73     <note>
74       <para>If you chose to build Shadow with Cracklib support, run the following:</para>
76 <screen role="nodump"><userinput>sed -i 's@DICTPATH.*@DICTPATH\t/lib/cracklib/pw_dict@' etc/login.defs</userinput></screen>
77     </note>
79     <para>Make a minor change to make the default useradd consistent with the LFS
80     groups file:</para>
82 <screen><userinput remap="pre">sed -i 's/1000/999/' etc/useradd</userinput></screen>
84     <para>Prepare Shadow for compilation:</para>
86 <screen><userinput remap="configure">./configure --sysconfdir=/etc --with-group-name-max-length=32</userinput></screen>
88     <variablelist>
89       <title>The meaning of the configure option:</title>
91       <varlistentry>
92         <term><parameter>--with-group-name-max-length=32</parameter></term>
93         <listitem>
94           <para>The maximum user name is 32 characters.  Make the maximum
95           group name the same.</para>
96         </listitem>
97       </varlistentry>
99     </variablelist>
101     <para>Compile the package:</para>
103 <screen><userinput remap="make">make</userinput></screen>
105     <para>This package does not come with a test suite.</para>
107     <para>Install the package:</para>
109 <screen><userinput remap="install">make install</userinput></screen>
111     <para>Move a misplaced program to its proper location:</para>
113 <screen><userinput remap="install">mv -v /usr/bin/passwd /bin</userinput></screen>
115     <!-- <para>Move Shadow's libraries to more appropriate locations:</para>
117 <screen><userinput remap="install">mv -v /lib/libshadow.*a /usr/lib
118 rm -v /lib/libshadow.so
119 ln -sfv ../../lib/libshadow.so.0 /usr/lib/libshadow.so</userinput></screen> -->
121   </sect2>
123   <sect2 id="conf-shadow" role="configuration">
124     <title>Configuring Shadow</title>
126     <indexterm zone="conf-shadow">
127       <primary sortas="a-Shadow">Shadow</primary>
128       <secondary>configuring</secondary>
129     </indexterm>
131     <para>This package contains utilities to add, modify, and delete users and
132     groups; set and change their passwords; and perform other administrative
133     tasks. For a full explanation of what <emphasis>password shadowing</emphasis>
134     means, see the <filename>doc/HOWTO</filename> file within the unpacked
135     source tree. If using Shadow support, keep in mind that programs which need
136     to verify passwords (display managers, FTP programs, pop3 daemons, etc.)
137     must be Shadow-compliant. That is, they need to be able to work with
138     shadowed passwords.</para>
140     <para>To enable shadowed passwords, run the following command:</para>
142 <screen><userinput>pwconv</userinput></screen>
144     <para>To enable shadowed group passwords, run:</para>
146 <screen><userinput>grpconv</userinput></screen>
148     <para>Shadow's stock configuration for the <command>useradd</command>
149     utility has a few caveats that need some explanation. First, the default
150     action for the <command>useradd</command> utility is to create the user and
151     a group of the same name as the user. By default the user ID (UID) and
152     group ID (GID) numbers will begin with 1000. This means if you don't pass
153     parameters to <command>useradd</command>, each user will be a member of a
154     unique group on the system. If this behavior is undesirable, you'll need
155     to pass the <parameter>-g</parameter> parameter to
156     <command>useradd</command>. The default parameters are stored in the
157     <filename>/etc/default/useradd</filename> file. You may need to modify two
158     parameters in this file to suit your particular needs.</para>
160     <variablelist>
161       <title><filename>/etc/default/useradd</filename> Parameter Explanations</title>
163       <varlistentry>
164         <term><parameter>GROUP=1000</parameter></term>
165         <listitem>
166           <para>This parameter sets the beginning of the group numbers used in
167           the /etc/group file. You can modify it to anything you desire. Note
168           that <command>useradd</command> will never reuse a UID or GID. If the
169           number identified in this parameter is used, it will use the next
170           available number after this. Note also that if you don't have a group
171           1000 on your system the first time you use <command>useradd</command>
172           without the <parameter>-g</parameter> parameter, you'll get a message
173           displayed on the terminal that says:
174           <computeroutput>useradd: unknown GID 1000</computeroutput>. You may
175           disregard this message and group number 1000 will be used.</para>
176         </listitem>
177       </varlistentry>
178       <varlistentry>
179         <term><parameter>CREATE_MAIL_SPOOL=yes</parameter></term>
180         <listitem>
181           <para>This parameter causes <command>useradd</command> to create a
182           mailbox file for the newly created user. <command>useradd</command>
183           will make the group ownership of this file to the
184           <systemitem class="groupname">mail</systemitem> group with 0660
185           permissions. If you would prefer that these mailbox files are not
186           created by <command>useradd</command>, issue the following
187           command:</para>
189 <screen><userinput>sed -i 's/yes/no/' /etc/default/useradd</userinput></screen>
190         </listitem>
191       </varlistentry>
193     </variablelist>
196   </sect2>
198   <sect2 role="configuration">
199     <title>Setting the root password</title>
201     <para>Choose a password for user <emphasis>root</emphasis> and set it
202     by running:</para>
204 <screen role="nodump"><userinput>passwd root</userinput></screen>
206   </sect2>
208   <sect2 id="contents-shadow" role="content">
209     <title>Contents of Shadow</title>
211     <segmentedlist>
212       <segtitle>Installed programs</segtitle>
213       <segtitle>Installed directory</segtitle>
215       <seglistitem>
216         <seg>chage, chfn, chgpasswd, chpasswd, chsh, expiry, faillog, gpasswd,
217         groupadd, groupdel, groupmems, groupmod, grpck, grpconv, grpunconv,
218         lastlog, login, logoutd, newgidmap, newgrp, newuidmap, newusers,
219         nologin, passwd, pwck, pwconv, pwunconv, sg (link to newgrp), su,
220         useradd, userdel, usermod, vigr (link to vipw), and vipw</seg>
221         <seg>/etc/default</seg>
222       </seglistitem>
223     </segmentedlist>
225     <variablelist>
226       <bridgehead renderas="sect3">Short Descriptions</bridgehead>
227       <?dbfo list-presentation="list"?>
228       <?dbhtml list-presentation="table"?>
230       <varlistentry id="chage">
231         <term><command>chage</command></term>
232         <listitem>
233           <para>Used to change the maximum number of days between obligatory
234           password changes</para>
235           <indexterm zone="ch-system-shadow chage">
236             <primary sortas="b-chage">chage</primary>
237           </indexterm>
238         </listitem>
239       </varlistentry>
241       <varlistentry id="chfn">
242         <term><command>chfn</command></term>
243         <listitem>
244           <para>Used to change a user's full name and other information</para>
245           <indexterm zone="ch-system-shadow chfn">
246             <primary sortas="b-chfn">chfn</primary>
247           </indexterm>
248         </listitem>
249       </varlistentry>
251       <varlistentry id="chgpasswd">
252         <term><command>chgpasswd</command></term>
253         <listitem>
254           <para>Used to update group passwords in batch mode</para>
255           <indexterm zone="ch-system-shadow chgpasswd">
256             <primary sortas="b-chgpasswd">chgpasswd</primary>
257           </indexterm>
258         </listitem>
259       </varlistentry>
261       <varlistentry id="chpasswd">
262         <term><command>chpasswd</command></term>
263         <listitem>
264           <para>Used to update user passwords in batch mode</para>
265           <indexterm zone="ch-system-shadow chpasswd">
266             <primary sortas="b-chpasswd">chpasswd</primary>
267           </indexterm>
268         </listitem>
269       </varlistentry>
271       <varlistentry id="chsh">
272         <term><command>chsh</command></term>
273         <listitem>
274           <para>Used to change a user's default login shell</para>
275           <indexterm zone="ch-system-shadow chsh">
276             <primary sortas="b-chsh">chsh</primary>
277           </indexterm>
278         </listitem>
279       </varlistentry>
281       <varlistentry id="expiry">
282         <term><command>expiry</command></term>
283         <listitem>
284           <para>Checks and enforces the current password expiration policy</para>
285           <indexterm zone="ch-system-shadow expiry">
286             <primary sortas="b-expiry">expiry</primary>
287           </indexterm>
288         </listitem>
289       </varlistentry>
291       <varlistentry id="faillog">
292         <term><command>faillog</command></term>
293         <listitem>
294           <para>Is used to examine the log of login failures, to set a maximum
295           number of failures before an account is blocked, or to reset the
296           failure count</para>
297           <indexterm zone="ch-system-shadow faillog">
298             <primary sortas="b-faillog">faillog</primary>
299           </indexterm>
300         </listitem>
301       </varlistentry>
303       <varlistentry id="gpasswd">
304         <term><command>gpasswd</command></term>
305         <listitem>
306           <para>Is used to add and delete members and administrators to
307           groups</para>
308           <indexterm zone="ch-system-shadow gpasswd">
309             <primary sortas="b-gpasswd">gpasswd</primary>
310           </indexterm>
311         </listitem>
312       </varlistentry>
314       <varlistentry id="groupadd">
315         <term><command>groupadd</command></term>
316         <listitem>
317           <para>Creates a group with the given name</para>
318           <indexterm zone="ch-system-shadow groupadd">
319             <primary sortas="b-groupadd">groupadd</primary>
320           </indexterm>
321         </listitem>
322       </varlistentry>
324       <varlistentry id="groupdel">
325         <term><command>groupdel</command></term>
326         <listitem>
327           <para>Deletes the group with the given name</para>
328           <indexterm zone="ch-system-shadow groupdel">
329             <primary sortas="b-groupdel">groupdel</primary>
330           </indexterm>
331         </listitem>
332       </varlistentry>
334       <varlistentry id="groupmems">
335         <term><command>groupmems</command></term>
336         <listitem>
337           <para>Allows a user to administer his/her own group membership list
338           without the requirement of super user privileges.</para>
339           <indexterm zone="ch-system-shadow groupmems">
340             <primary sortas="b-groupmems">groupmems</primary>
341           </indexterm>
342         </listitem>
343       </varlistentry>
345       <varlistentry id="groupmod">
346         <term><command>groupmod</command></term>
347         <listitem>
348           <para>Is used to modify the given group's name or GID</para>
349           <indexterm zone="ch-system-shadow groupmod">
350             <primary sortas="b-groupmod">groupmod</primary>
351           </indexterm>
352         </listitem>
353       </varlistentry>
355       <varlistentry id="grpck">
356         <term><command>grpck</command></term>
357         <listitem>
358           <para>Verifies the integrity of the group files
359           <filename>/etc/group</filename> and
360           <filename>/etc/gshadow</filename></para>
361           <indexterm zone="ch-system-shadow grpck">
362             <primary sortas="b-grpck">grpck</primary>
363           </indexterm>
364         </listitem>
365       </varlistentry>
367       <varlistentry id="grpconv">
368         <term><command>grpconv</command></term>
369         <listitem>
370           <para>Creates or updates the shadow group file from the normal
371           group file</para>
372           <indexterm zone="ch-system-shadow grpconv">
373             <primary sortas="b-grpconv">grpconv</primary>
374           </indexterm>
375         </listitem>
376       </varlistentry>
378       <varlistentry id="grpunconv">
379         <term><command>grpunconv</command></term>
380         <listitem>
381           <para>Updates <filename>/etc/group</filename> from
382           <filename>/etc/gshadow</filename> and then deletes the latter</para>
383           <indexterm zone="ch-system-shadow grpunconv">
384             <primary sortas="b-grpunconv">grpunconv</primary>
385           </indexterm>
386         </listitem>
387       </varlistentry>
389       <varlistentry id="lastlog">
390         <term><command>lastlog</command></term>
391         <listitem>
392           <para>Reports the most recent login of all users or of a
393           given user</para>
394           <indexterm zone="ch-system-shadow lastlog">
395             <primary sortas="b-lastlog">lastlog</primary>
396           </indexterm>
397         </listitem>
398       </varlistentry>
400       <varlistentry id="login">
401         <term><command>login</command></term>
402         <listitem>
403           <para>Is used by the system to let users sign on</para>
404           <indexterm zone="ch-system-shadow login">
405             <primary sortas="b-login">login</primary>
406           </indexterm>
407         </listitem>
408       </varlistentry>
410       <varlistentry id="logoutd">
411         <term><command>logoutd</command></term>
412         <listitem>
413           <para>Is a daemon used to enforce restrictions on log-on time
414           and ports</para>
415           <indexterm zone="ch-system-shadow logoutd">
416             <primary sortas="b-logoutd">logoutd</primary>
417           </indexterm>
418         </listitem>
419       </varlistentry>
421       <varlistentry id="newgidmap">
422         <term><command>newgidmap</command></term>
423         <listitem>
424           <para>Is used to set the gid mapping of a user namespace</para>
425           <indexterm zone="ch-system-shadow newgidmap">
426             <primary sortas="b-newgidmap">newgidmap</primary>
427           </indexterm>
428         </listitem>
429       </varlistentry>
431       <varlistentry id="newgrp">
432         <term><command>newgrp</command></term>
433         <listitem>
434           <para>Is used to change the current GID during a login session</para>
435           <indexterm zone="ch-system-shadow newgrp">
436             <primary sortas="b-newgrp">newgrp</primary>
437           </indexterm>
438         </listitem>
439       </varlistentry>
441       <varlistentry id="newuidmap">
442         <term><command>newuidmap</command></term>
443         <listitem>
444           <para>Is used to set the uid mapping of a user namespace</para>
445           <indexterm zone="ch-system-shadow newuidmap">
446             <primary sortas="b-newuidmap">newuidmap</primary>
447           </indexterm>
448         </listitem>
449       </varlistentry>
451       <varlistentry id="newusers">
452         <term><command>newusers</command></term>
453         <listitem>
454           <para>Is used to create or update an entire series of user
455           accounts</para>
456           <indexterm zone="ch-system-shadow newusers">
457             <primary sortas="b-newusers">newusers</primary>
458           </indexterm>
459         </listitem>
460       </varlistentry>
462       <varlistentry id="nologin">
463         <term><command>nologin</command></term>
464         <listitem>
465           <para>Displays a message that an account is not available; it is designed
466           to be used as the default shell for accounts that have been
467           disabled</para>
468           <indexterm zone="ch-system-shadow nologin">
469             <primary sortas="b-nologin">nologin</primary>
470           </indexterm>
471         </listitem>
472       </varlistentry>
474       <varlistentry id="passwd">
475         <term><command>passwd</command></term>
476         <listitem>
477           <para>Is used to change the password for a user or group account</para>
478           <indexterm zone="ch-system-shadow passwd">
479             <primary sortas="b-passwd">passwd</primary>
480           </indexterm>
481         </listitem>
482       </varlistentry>
484       <varlistentry id="pwck">
485         <term><command>pwck</command></term>
486         <listitem>
487           <para>Verifies the integrity of the password files
488           <filename>/etc/passwd</filename> and
489           <filename>/etc/shadow</filename></para>
490           <indexterm zone="ch-system-shadow pwck">
491             <primary sortas="b-pwck">pwck</primary>
492           </indexterm>
493         </listitem>
494       </varlistentry>
496       <varlistentry id="pwconv">
497         <term><command>pwconv</command></term>
498         <listitem>
499           <para>Creates or updates the shadow password file from the normal
500           password file</para>
501           <indexterm zone="ch-system-shadow pwconv">
502             <primary sortas="b-pwconv">pwconv</primary>
503           </indexterm>
504         </listitem>
505       </varlistentry>
507       <varlistentry id="pwunconv">
508         <term><command>pwunconv</command></term>
509         <listitem>
510           <para>Updates <filename>/etc/passwd</filename> from
511           <filename>/etc/shadow</filename> and then deletes the latter</para>
512           <indexterm zone="ch-system-shadow pwunconv">
513             <primary sortas="b-pwunconv">pwunconv</primary>
514           </indexterm>
515         </listitem>
516       </varlistentry>
518       <varlistentry id="sg">
519         <term><command>sg</command></term>
520         <listitem>
521           <para>Executes a given command while the user's GID
522           is set to that of the given group</para>
523           <indexterm zone="ch-system-shadow sg">
524             <primary sortas="b-sg">sg</primary>
525           </indexterm>
526         </listitem>
527       </varlistentry>
529       <varlistentry id="su">
530         <term><command>su</command></term>
531         <listitem>
532           <para>Runs a shell with substitute user and group IDs</para>
533           <indexterm zone="ch-system-shadow su">
534             <primary sortas="b-su">su</primary>
535           </indexterm>
536         </listitem>
537       </varlistentry>
539       <varlistentry id="useradd">
540         <term><command>useradd</command></term>
541         <listitem>
542           <para>Creates a new user with the given name, or updates the default
543           new-user information</para>
544           <indexterm zone="ch-system-shadow useradd">
545             <primary sortas="b-useradd">useradd</primary>
546           </indexterm>
547         </listitem>
548       </varlistentry>
550       <varlistentry id="userdel">
551         <term><command>userdel</command></term>
552         <listitem>
553           <para>Deletes the given user account</para>
554           <indexterm zone="ch-system-shadow userdel">
555             <primary sortas="b-userdel">userdel</primary>
556           </indexterm>
557         </listitem>
558       </varlistentry>
560       <varlistentry id="usermod">
561         <term><command>usermod</command></term>
562         <listitem>
563           <para>Is used to modify the given user's login name, User
564           Identification (UID), shell, initial group, home directory, etc.</para>
565           <indexterm zone="ch-system-shadow usermod">
566             <primary sortas="b-usermod">usermod</primary>
567           </indexterm>
568         </listitem>
569       </varlistentry>
571       <varlistentry id="vigr">
572         <term><command>vigr</command></term>
573         <listitem>
574           <para>Edits the <filename>/etc/group</filename> or
575           <filename>/etc/gshadow</filename> files</para>
576           <indexterm zone="ch-system-shadow vigr">
577             <primary sortas="b-vigr">vigr</primary>
578           </indexterm>
579         </listitem>
580       </varlistentry>
582       <varlistentry id="vipw">
583         <term><command>vipw</command></term>
584         <listitem>
585           <para>Edits the <filename>/etc/passwd</filename> or
586           <filename>/etc/shadow</filename> files</para>
587           <indexterm zone="ch-system-shadow vipw">
588             <primary sortas="b-vipw">vipw</primary>
589           </indexterm>
590         </listitem>
591       </varlistentry>
593     </variablelist>
595   </sect2>
597 </sect1>