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