Update to Python-3.8.2.
[linux_from_scratch.git] / chapter06 / shadow.xml
blobb052ab3abe39ad20e8f1dcd1abfe8bef5dae3ce3
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 in
55     <xref linkend="ch-system-man-pages"/>:</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="pre">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 first group number generated
80     by useradd 1000:</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>
110     <!--
111     <para>Move a misplaced program to its proper location:</para>
113 <screen><userinput remap="install">mv -v /usr/bin/passwd /bin</userinput></screen>
114     -->
116     <!-- <para>Move Shadow's libraries to more appropriate locations:</para>
118 <screen><userinput remap="install">mv -v /lib/libshadow.*a /usr/lib
119 rm -v /lib/libshadow.so
120 ln -sfv ../../lib/libshadow.so.0 /usr/lib/libshadow.so</userinput></screen> -->
122   </sect2>
124   <sect2 id="conf-shadow" role="configuration">
125     <title>Configuring Shadow</title>
127     <indexterm zone="conf-shadow">
128       <primary sortas="a-Shadow">Shadow</primary>
129       <secondary>configuring</secondary>
130     </indexterm>
132     <para>This package contains utilities to add, modify, and delete users and
133     groups; set and change their passwords; and perform other administrative
134     tasks. For a full explanation of what <emphasis>password shadowing</emphasis>
135     means, see the <filename>doc/HOWTO</filename> file within the unpacked
136     source tree. If using Shadow support, keep in mind that programs which need
137     to verify passwords (display managers, FTP programs, pop3 daemons, etc.)
138     must be Shadow-compliant. That is, they need to be able to work with
139     shadowed passwords.</para>
141     <para>To enable shadowed passwords, run the following command:</para>
143 <screen><userinput>pwconv</userinput></screen>
145     <para>To enable shadowed group passwords, run:</para>
147 <screen><userinput>grpconv</userinput></screen>
149     <para>Shadow's stock configuration for the <command>useradd</command>
150     utility has a few caveats that need some explanation. First, the default
151     action for the <command>useradd</command> utility is to create the user and
152     a group of the same name as the user. By default the user ID (UID) and
153     group ID (GID) numbers will begin with 1000. This means if you don't pass
154     parameters to <command>useradd</command>, each user will be a member of a
155     unique group on the system. If this behavior is undesirable, you'll need
156     to pass the <parameter>-g</parameter> parameter to
157     <command>useradd</command>. The default parameters are stored in the
158     <filename>/etc/default/useradd</filename> file. You may need to modify two
159     parameters in this file to suit your particular needs.</para>
161     <variablelist>
162       <title><filename>/etc/default/useradd</filename> Parameter Explanations</title>
164       <varlistentry>
165         <term><parameter>GROUP=1000</parameter></term>
166         <listitem>
167           <para>This parameter sets the beginning of the group numbers used in
168           the /etc/group file. You can modify it to anything you desire. Note
169           that <command>useradd</command> will never reuse a UID or GID. If the
170           number identified in this parameter is used, it will use the next
171           available number after this. Note also that if you don't have a group
172           1000 on your system the first time you use <command>useradd</command>
173           without the <parameter>-g</parameter> parameter, you'll get a message
174           displayed on the terminal that says:
175           <computeroutput>useradd: unknown GID 1000</computeroutput>. You may
176           disregard this message and group number 1000 will be used.</para>
177         </listitem>
178       </varlistentry>
179       <varlistentry>
180         <term><parameter>CREATE_MAIL_SPOOL=yes</parameter></term>
181         <listitem>
182           <para>This parameter causes <command>useradd</command> to create a
183           mailbox file for the newly created user. <command>useradd</command>
184           will make the group ownership of this file to the
185           <systemitem class="groupname">mail</systemitem> group with 0660
186           permissions. If you would prefer that these mailbox files are not
187           created by <command>useradd</command>, issue the following
188           command:</para>
190 <screen><userinput>sed -i 's/yes/no/' /etc/default/useradd</userinput></screen>
191         </listitem>
192       </varlistentry>
194     </variablelist>
197   </sect2>
199   <sect2 role="configuration">
200     <title>Setting the root password</title>
202     <para>Choose a password for user <emphasis>root</emphasis> and set it
203     by running:</para>
205 <screen role="nodump"><userinput>passwd root</userinput></screen>
207   </sect2>
209   <sect2 id="contents-shadow" role="content">
210     <title>Contents of Shadow</title>
212     <segmentedlist>
213       <segtitle>Installed programs</segtitle>
214       <segtitle>Installed directory</segtitle>
216       <seglistitem>
217         <seg>chage, chfn, chgpasswd, chpasswd, chsh, expiry, faillog, gpasswd,
218         groupadd, groupdel, groupmems, groupmod, grpck, grpconv, grpunconv,
219         lastlog, login, logoutd, newgidmap, newgrp, newuidmap, newusers,
220         nologin, passwd, pwck, pwconv, pwunconv, sg (link to newgrp), su,
221         useradd, userdel, usermod, vigr (link to vipw), and vipw</seg>
222         <seg>/etc/default</seg>
223       </seglistitem>
224     </segmentedlist>
226     <variablelist>
227       <bridgehead renderas="sect3">Short Descriptions</bridgehead>
228       <?dbfo list-presentation="list"?>
229       <?dbhtml list-presentation="table"?>
231       <varlistentry id="chage">
232         <term><command>chage</command></term>
233         <listitem>
234           <para>Used to change the maximum number of days between obligatory
235           password changes</para>
236           <indexterm zone="ch-system-shadow chage">
237             <primary sortas="b-chage">chage</primary>
238           </indexterm>
239         </listitem>
240       </varlistentry>
242       <varlistentry id="chfn">
243         <term><command>chfn</command></term>
244         <listitem>
245           <para>Used to change a user's full name and other information</para>
246           <indexterm zone="ch-system-shadow chfn">
247             <primary sortas="b-chfn">chfn</primary>
248           </indexterm>
249         </listitem>
250       </varlistentry>
252       <varlistentry id="chgpasswd">
253         <term><command>chgpasswd</command></term>
254         <listitem>
255           <para>Used to update group passwords in batch mode</para>
256           <indexterm zone="ch-system-shadow chgpasswd">
257             <primary sortas="b-chgpasswd">chgpasswd</primary>
258           </indexterm>
259         </listitem>
260       </varlistentry>
262       <varlistentry id="chpasswd">
263         <term><command>chpasswd</command></term>
264         <listitem>
265           <para>Used to update user passwords in batch mode</para>
266           <indexterm zone="ch-system-shadow chpasswd">
267             <primary sortas="b-chpasswd">chpasswd</primary>
268           </indexterm>
269         </listitem>
270       </varlistentry>
272       <varlistentry id="chsh">
273         <term><command>chsh</command></term>
274         <listitem>
275           <para>Used to change a user's default login shell</para>
276           <indexterm zone="ch-system-shadow chsh">
277             <primary sortas="b-chsh">chsh</primary>
278           </indexterm>
279         </listitem>
280       </varlistentry>
282       <varlistentry id="expiry">
283         <term><command>expiry</command></term>
284         <listitem>
285           <para>Checks and enforces the current password expiration policy</para>
286           <indexterm zone="ch-system-shadow expiry">
287             <primary sortas="b-expiry">expiry</primary>
288           </indexterm>
289         </listitem>
290       </varlistentry>
292       <varlistentry id="faillog">
293         <term><command>faillog</command></term>
294         <listitem>
295           <para>Is used to examine the log of login failures, to set a maximum
296           number of failures before an account is blocked, or to reset the
297           failure count</para>
298           <indexterm zone="ch-system-shadow faillog">
299             <primary sortas="b-faillog">faillog</primary>
300           </indexterm>
301         </listitem>
302       </varlistentry>
304       <varlistentry id="gpasswd">
305         <term><command>gpasswd</command></term>
306         <listitem>
307           <para>Is used to add and delete members and administrators to
308           groups</para>
309           <indexterm zone="ch-system-shadow gpasswd">
310             <primary sortas="b-gpasswd">gpasswd</primary>
311           </indexterm>
312         </listitem>
313       </varlistentry>
315       <varlistentry id="groupadd">
316         <term><command>groupadd</command></term>
317         <listitem>
318           <para>Creates a group with the given name</para>
319           <indexterm zone="ch-system-shadow groupadd">
320             <primary sortas="b-groupadd">groupadd</primary>
321           </indexterm>
322         </listitem>
323       </varlistentry>
325       <varlistentry id="groupdel">
326         <term><command>groupdel</command></term>
327         <listitem>
328           <para>Deletes the group with the given name</para>
329           <indexterm zone="ch-system-shadow groupdel">
330             <primary sortas="b-groupdel">groupdel</primary>
331           </indexterm>
332         </listitem>
333       </varlistentry>
335       <varlistentry id="groupmems">
336         <term><command>groupmems</command></term>
337         <listitem>
338           <para>Allows a user to administer his/her own group membership list
339           without the requirement of super user privileges.</para>
340           <indexterm zone="ch-system-shadow groupmems">
341             <primary sortas="b-groupmems">groupmems</primary>
342           </indexterm>
343         </listitem>
344       </varlistentry>
346       <varlistentry id="groupmod">
347         <term><command>groupmod</command></term>
348         <listitem>
349           <para>Is used to modify the given group's name or GID</para>
350           <indexterm zone="ch-system-shadow groupmod">
351             <primary sortas="b-groupmod">groupmod</primary>
352           </indexterm>
353         </listitem>
354       </varlistentry>
356       <varlistentry id="grpck">
357         <term><command>grpck</command></term>
358         <listitem>
359           <para>Verifies the integrity of the group files
360           <filename>/etc/group</filename> and
361           <filename>/etc/gshadow</filename></para>
362           <indexterm zone="ch-system-shadow grpck">
363             <primary sortas="b-grpck">grpck</primary>
364           </indexterm>
365         </listitem>
366       </varlistentry>
368       <varlistentry id="grpconv">
369         <term><command>grpconv</command></term>
370         <listitem>
371           <para>Creates or updates the shadow group file from the normal
372           group file</para>
373           <indexterm zone="ch-system-shadow grpconv">
374             <primary sortas="b-grpconv">grpconv</primary>
375           </indexterm>
376         </listitem>
377       </varlistentry>
379       <varlistentry id="grpunconv">
380         <term><command>grpunconv</command></term>
381         <listitem>
382           <para>Updates <filename>/etc/group</filename> from
383           <filename>/etc/gshadow</filename> and then deletes the latter</para>
384           <indexterm zone="ch-system-shadow grpunconv">
385             <primary sortas="b-grpunconv">grpunconv</primary>
386           </indexterm>
387         </listitem>
388       </varlistentry>
390       <varlistentry id="lastlog">
391         <term><command>lastlog</command></term>
392         <listitem>
393           <para>Reports the most recent login of all users or of a
394           given user</para>
395           <indexterm zone="ch-system-shadow lastlog">
396             <primary sortas="b-lastlog">lastlog</primary>
397           </indexterm>
398         </listitem>
399       </varlistentry>
401       <varlistentry id="login">
402         <term><command>login</command></term>
403         <listitem>
404           <para>Is used by the system to let users sign on</para>
405           <indexterm zone="ch-system-shadow login">
406             <primary sortas="b-login">login</primary>
407           </indexterm>
408         </listitem>
409       </varlistentry>
411       <varlistentry id="logoutd">
412         <term><command>logoutd</command></term>
413         <listitem>
414           <para>Is a daemon used to enforce restrictions on log-on time
415           and ports</para>
416           <indexterm zone="ch-system-shadow logoutd">
417             <primary sortas="b-logoutd">logoutd</primary>
418           </indexterm>
419         </listitem>
420       </varlistentry>
422       <varlistentry id="newgidmap">
423         <term><command>newgidmap</command></term>
424         <listitem>
425           <para>Is used to set the gid mapping of a user namespace</para>
426           <indexterm zone="ch-system-shadow newgidmap">
427             <primary sortas="b-newgidmap">newgidmap</primary>
428           </indexterm>
429         </listitem>
430       </varlistentry>
432       <varlistentry id="newgrp">
433         <term><command>newgrp</command></term>
434         <listitem>
435           <para>Is used to change the current GID during a login session</para>
436           <indexterm zone="ch-system-shadow newgrp">
437             <primary sortas="b-newgrp">newgrp</primary>
438           </indexterm>
439         </listitem>
440       </varlistentry>
442       <varlistentry id="newuidmap">
443         <term><command>newuidmap</command></term>
444         <listitem>
445           <para>Is used to set the uid mapping of a user namespace</para>
446           <indexterm zone="ch-system-shadow newuidmap">
447             <primary sortas="b-newuidmap">newuidmap</primary>
448           </indexterm>
449         </listitem>
450       </varlistentry>
452       <varlistentry id="newusers">
453         <term><command>newusers</command></term>
454         <listitem>
455           <para>Is used to create or update an entire series of user
456           accounts</para>
457           <indexterm zone="ch-system-shadow newusers">
458             <primary sortas="b-newusers">newusers</primary>
459           </indexterm>
460         </listitem>
461       </varlistentry>
463       <varlistentry id="nologin">
464         <term><command>nologin</command></term>
465         <listitem>
466           <para>Displays a message that an account is not available; it is designed
467           to be used as the default shell for accounts that have been
468           disabled</para>
469           <indexterm zone="ch-system-shadow nologin">
470             <primary sortas="b-nologin">nologin</primary>
471           </indexterm>
472         </listitem>
473       </varlistentry>
475       <varlistentry id="passwd">
476         <term><command>passwd</command></term>
477         <listitem>
478           <para>Is used to change the password for a user or group account</para>
479           <indexterm zone="ch-system-shadow passwd">
480             <primary sortas="b-passwd">passwd</primary>
481           </indexterm>
482         </listitem>
483       </varlistentry>
485       <varlistentry id="pwck">
486         <term><command>pwck</command></term>
487         <listitem>
488           <para>Verifies the integrity of the password files
489           <filename>/etc/passwd</filename> and
490           <filename>/etc/shadow</filename></para>
491           <indexterm zone="ch-system-shadow pwck">
492             <primary sortas="b-pwck">pwck</primary>
493           </indexterm>
494         </listitem>
495       </varlistentry>
497       <varlistentry id="pwconv">
498         <term><command>pwconv</command></term>
499         <listitem>
500           <para>Creates or updates the shadow password file from the normal
501           password file</para>
502           <indexterm zone="ch-system-shadow pwconv">
503             <primary sortas="b-pwconv">pwconv</primary>
504           </indexterm>
505         </listitem>
506       </varlistentry>
508       <varlistentry id="pwunconv">
509         <term><command>pwunconv</command></term>
510         <listitem>
511           <para>Updates <filename>/etc/passwd</filename> from
512           <filename>/etc/shadow</filename> and then deletes the latter</para>
513           <indexterm zone="ch-system-shadow pwunconv">
514             <primary sortas="b-pwunconv">pwunconv</primary>
515           </indexterm>
516         </listitem>
517       </varlistentry>
519       <varlistentry id="sg">
520         <term><command>sg</command></term>
521         <listitem>
522           <para>Executes a given command while the user's GID
523           is set to that of the given group</para>
524           <indexterm zone="ch-system-shadow sg">
525             <primary sortas="b-sg">sg</primary>
526           </indexterm>
527         </listitem>
528       </varlistentry>
530       <varlistentry id="su">
531         <term><command>su</command></term>
532         <listitem>
533           <para>Runs a shell with substitute user and group IDs</para>
534           <indexterm zone="ch-system-shadow su">
535             <primary sortas="b-su">su</primary>
536           </indexterm>
537         </listitem>
538       </varlistentry>
540       <varlistentry id="useradd">
541         <term><command>useradd</command></term>
542         <listitem>
543           <para>Creates a new user with the given name, or updates the default
544           new-user information</para>
545           <indexterm zone="ch-system-shadow useradd">
546             <primary sortas="b-useradd">useradd</primary>
547           </indexterm>
548         </listitem>
549       </varlistentry>
551       <varlistentry id="userdel">
552         <term><command>userdel</command></term>
553         <listitem>
554           <para>Deletes the given user account</para>
555           <indexterm zone="ch-system-shadow userdel">
556             <primary sortas="b-userdel">userdel</primary>
557           </indexterm>
558         </listitem>
559       </varlistentry>
561       <varlistentry id="usermod">
562         <term><command>usermod</command></term>
563         <listitem>
564           <para>Is used to modify the given user's login name, User
565           Identification (UID), shell, initial group, home directory, etc.</para>
566           <indexterm zone="ch-system-shadow usermod">
567             <primary sortas="b-usermod">usermod</primary>
568           </indexterm>
569         </listitem>
570       </varlistentry>
572       <varlistentry id="vigr">
573         <term><command>vigr</command></term>
574         <listitem>
575           <para>Edits the <filename>/etc/group</filename> or
576           <filename>/etc/gshadow</filename> files</para>
577           <indexterm zone="ch-system-shadow vigr">
578             <primary sortas="b-vigr">vigr</primary>
579           </indexterm>
580         </listitem>
581       </varlistentry>
583       <varlistentry id="vipw">
584         <term><command>vipw</command></term>
585         <listitem>
586           <para>Edits the <filename>/etc/passwd</filename> or
587           <filename>/etc/shadow</filename> files</para>
588           <indexterm zone="ch-system-shadow vipw">
589             <primary sortas="b-vipw">vipw</primary>
590           </indexterm>
591         </listitem>
592       </varlistentry>
594     </variablelist>
596   </sect2>
598 </sect1>