source: postlfs/security/shadow.xml@ 574d896d

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 7.10 7.4 7.5 7.6 7.6-blfs 7.6-systemd 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind gnome kde5-13430 kde5-14269 kde5-14686 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts krejzi/svn lazarus lxqt nosym perl-modules plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition systemd-11177 systemd-13485 trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since 574d896d was 574d896d, checked in by Krejzi <krejzi@…>, 12 years ago

new shadow patch

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@9863 af4574ff-66df-0310-9fd7-8a98e5e911e0

  • Property mode set to 100644
File size: 23.2 KB
Line 
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
7 <!ENTITY shadow-download-http
8 "http://pkg-shadow.alioth.debian.org/releases/shadow-&shadow-version;.tar.bz2 ">
9 <!ENTITY shadow-download-ftp " ">
10 <!ENTITY shadow-md5sum "d5f7a588fadb79faeb4b08b1eee82e9a">
11 <!ENTITY shadow-size "2.1 MB">
12 <!ENTITY shadow-buildsize "35 MB">
13 <!ENTITY shadow-time "0.3 SBU">
14]>
15
16<sect1 id="shadow" xreflabel="Shadow-&shadow-version;">
17 <?dbhtml filename="shadow.html"?>
18
19 <sect1info>
20 <othername>$LastChangedBy$</othername>
21 <date>$Date$</date>
22 </sect1info>
23
24 <title>Shadow-&shadow-version;</title>
25
26 <indexterm zone="shadow">
27 <primary sortas="a-Shadow">Shadow</primary>
28 </indexterm>
29
30 <sect2 role="package">
31 <title>Introduction to Shadow</title>
32
33 <para>
34 <application>Shadow</application> was indeed installed in LFS and there is
35 no reason to reinstall it unless you installed
36 <application>CrackLib</application> or
37 <application>Linux-PAM</application> after your LFS system was completed.
38 If you have installed <application>CrackLib</application> after LFS, then
39 reinstalling <application>Shadow</application> will enable strong password
40 support. If you have installed <application>Linux-PAM</application>,
41 reinstalling <application>Shadow</application> will allow programs such as
42 <command>login</command> and <command>su</command> to utilize PAM.
43 </para>
44
45 &lfs71_checked;
46
47 <bridgehead renderas="sect3">Package Information</bridgehead>
48 <itemizedlist spacing="compact">
49 <listitem>
50 <para>
51 Download (HTTP): <ulink url="&shadow-download-http;"/>
52 </para>
53 </listitem>
54 <listitem>
55 <para>
56 Download (FTP): <ulink url="&shadow-download-ftp;"/>
57 </para>
58 </listitem>
59 <listitem>
60 <para>
61 Download MD5 sum: &shadow-md5sum;
62 </para>
63 </listitem>
64 <listitem>
65 <para>
66 Download size: &shadow-size;
67 </para>
68 </listitem>
69 <listitem>
70 <para>
71 Estimated disk space required: &shadow-buildsize;
72 </para>
73 </listitem>
74 <listitem>
75 <para>
76 Estimated build time: &shadow-time;
77 </para>
78 </listitem>
79 </itemizedlist>
80
81 <bridgehead renderas="sect3">Additional Downloads</bridgehead>
82 <itemizedlist spacing='compact'>
83 <listitem>
84 <para>
85 Required patch: <ulink
86 url="&patch-root;/shadow-&shadow-version;-fixes-1.patch"/>
87 </para>
88 </listitem>
89 </itemizedlist>
90
91 <bridgehead renderas="sect3">Shadow Dependencies</bridgehead>
92
93 <bridgehead renderas="sect4">Required</bridgehead>
94 <para role="required">
95 <xref linkend="linux-pam"/> or
96 <xref linkend="cracklib"/>
97 </para>
98
99 <para condition="html" role="usernotes">
100 User Notes: <ulink url="&blfs-wiki;/shadow"/>
101 </para>
102 </sect2>
103
104 <sect2 role="installation">
105 <title>Installation of Shadow</title>
106
107 <important>
108 <para>
109 The installation commands shown below are for installations where
110 <application>Linux-PAM</application> has been installed (with or
111 without a <application>CrackLib</application> installation) and
112 <application>Shadow</application> is being reinstalled to support the
113 <application>Linux-PAM</application> installation.
114 </para>
115
116 <para>
117 If you are reinstalling <application>Shadow</application> to provide
118 strong password support using the <application>CrackLib</application>
119 library without using <application>Linux-PAM</application>, ensure you
120 add the <parameter>--with-libcrack</parameter> parameter to the
121 <command>configure</command> script below and also issue the following
122 command:
123 </para>
124
125<screen><userinput>sed -i 's@DICTPATH.*@DICTPATH\t/lib/cracklib/pw_dict@' etc/login.defs</userinput></screen>
126 </important>
127
128 <para>
129 Reinstall <application>Shadow</application> by running the following
130 commands:
131 </para>
132
133<screen><userinput>sed -i 's/groups$(EXEEXT) //' src/Makefile.in &amp;&amp;
134find man -name Makefile.in -exec sed -i 's/groups\.1 / /' {} \; &amp;&amp;
135sed -i -e 's/ ko//' -e 's/ zh_CN zh_TW//' man/Makefile.in &amp;&amp;
136
137sed -i -e 's@#ENCRYPT_METHOD DES@ENCRYPT_METHOD SHA512@' \
138 -e 's@/var/spool/mail@/var/mail@' etc/login.defs &amp;&amp;
139
140sed -i -e 's@PATH=/sbin:/bin:/usr/sbin:/usr/bin@&amp;:/usr/local/sbin:/usr/local/bin@' \
141 -e 's@PATH=/bin:/usr/bin@&amp;:/usr/local/bin@' etc/login.defs &amp;&amp;
142
143patch -Np1 -i ../shadow-&shadow-version;-fixes-1.patch &amp;&amp;
144
145./configure --prefix=/usr --sysconfdir=/etc &amp;&amp;
146make</userinput></screen>
147
148 <para>
149 This package does not come with a test suite.
150 </para>
151
152 <para>
153 Now, as the <systemitem class="username">root</systemitem> user:
154 </para>
155
156<screen role="root"><userinput>make install &amp;&amp;
157mv -v /usr/bin/passwd /bin</userinput></screen>
158 </sect2>
159
160 <sect2 role="commands">
161 <title>Command Explanations</title>
162
163 <para>
164 <command>sed -i 's/groups$(EXEEXT) //' src/Makefile.in</command>: This sed
165 is used to suppress the installation of the <command>groups</command>
166 program as the version from the <application>Coreutils</application>
167 package installed during LFS is preferred.
168 </para>
169
170 <para>
171 <command>find man -name Makefile.in -exec ... {} \;</command>: This
172 command is used to suppress the installation of the
173 <command>groups</command> man pages so the existing ones installed from
174 the <application>Coreutils</application> package are not replaced.
175 </para>
176
177 <para>
178 <command>sed -i -e '...' -e '...' man/Makefile.in</command>: This command
179 disables the installation of Chinese and Korean manual pages, since
180 <application>Man-DB</application> cannot format them properly.
181 </para>
182
183 <para>
184 <command>sed -i -e 's@#ENCRYPT_METHOD DES@ENCRYPT_METHOD SHA512@' -e
185 's@/var/spool/mail@/var/mail@' etc/login.defs</command>: Instead of using
186 the default 'DES' method, this command modifies the installation to use
187 the more secure 'SHA512' method of hashing passwords, which also allows
188 passwords longer than eight characters. It also changes the obsolete
189 <filename class="directory">/var/spool/mail</filename> location for user
190 mailboxes that <application>Shadow</application> uses by default to the
191 <filename class="directory">/var/mail</filename> location.
192 </para>
193
194 <para>
195 <command>sed -i -e
196 's@PATH=/sbin:/bin:/usr/sbin:/usr/bin@&amp;:/usr/local/sbin:/usr/local/bin@'
197 -e 's@PATH=/bin:/usr/bin@&amp;:/usr/local/bin@' etc/login.defs</command>:
198 This sed expands PATH to
199 <filename class="directory">/usr/local/bin</filename> for normal and
200 <systemitem class="username">root</systemitem> user and to
201 <filename class="directory">/usr/local/sbin</filename> for
202 <systemitem class="username">root</systemitem> user only.
203 </para>
204
205 <para>
206 <command>mv -v /usr/bin/passwd /bin</command>: The
207 <command>passwd</command> program may be needed during times when the
208 <filename class='directory'>/usr</filename> filesystem is not mounted so
209 it is moved into the root partition.
210 </para>
211 </sect2>
212
213 <sect2 role="configuration">
214 <title>Configuring Shadow</title>
215
216 <para>
217 <application>Shadow</application>'s stock configuration for the
218 <command>useradd</command> utility may not be desirable for your
219 installation. One default parameter causes <command>useradd</command> to
220 create a mailbox file for any newly created user.
221 <command>useradd</command> will make the group ownership of this file to
222 the <systemitem class="groupname">mail</systemitem> group with 0660
223 permissions. If you would prefer that these mailbox files are not created
224 by <command>useradd</command>, issue the following command as the
225 <systemitem class="username">root</systemitem> user:
226 </para>
227
228<screen role="root"><userinput>sed -i 's/yes/no/' /etc/default/useradd</userinput></screen>
229 </sect2>
230
231 <sect2 role="configuration">
232 <title>Configuring Linux-PAM to Work with Shadow</title>
233
234 <note>
235 <para>
236 The rest of this page is devoted to configuring
237 <application>Shadow</application> to work properly with
238 <application>Linux-PAM</application>. If you do not have
239 <application>Linux-PAM</application> installed, and you reinstalled
240 <application>Shadow</application> to support strong passwords via the
241 <application>CrackLib</application> library, no further configuration is
242 required.
243 </para>
244 </note>
245
246 <sect3 id="pam.d">
247 <title>Config Files</title>
248
249 <para>
250 <filename>/etc/pam.d/*</filename> or alternatively
251 <filename>/etc/pam.conf</filename>,
252 <filename>/etc/login.defs</filename> and
253 <filename>/etc/security/*</filename>
254 </para>
255
256 <indexterm zone="shadow pam.d">
257 <primary sortas="e-etc-pam.d">/etc/pam.d/*</primary>
258 </indexterm>
259
260 <indexterm zone="shadow pam.d">
261 <primary sortas="e-etc-pam.conf">/etc/pam.conf</primary>
262 </indexterm>
263
264 <indexterm zone="shadow pam.d">
265 <primary sortas="e-etc-login.defs">/etc/login.defs</primary>
266 </indexterm>
267
268 <indexterm zone="shadow pam.d">
269 <primary sortas="e-etc-security">/etc/security/*</primary>
270 </indexterm>
271 </sect3>
272
273 <sect3>
274 <title>Configuration Information</title>
275
276 <para>
277 Configuring your system to use <application>Linux-PAM</application> can
278 be a complex task. The information below will provide a basic setup so
279 that <application>Shadow</application>'s login and password
280 functionality will work effectively with
281 <application>Linux-PAM</application>. Review the information and links
282 on the <xref linkend="linux-pam"/> page for further configuration
283 information. For information specific to integrating
284 <application>Shadow</application>, <application>Linux-PAM</application>
285 and <application>CrackLib</application>, you can visit the following
286 link:
287 </para>
288
289 <itemizedlist spacing="compact">
290 <listitem>
291 <para>
292 <ulink url="http://www.deer-run.com/~hal/sysadmin/pam_cracklib.html"/>
293 </para>
294 </listitem>
295 </itemizedlist>
296
297 <sect4 id="pam-login-defs">
298 <title>Configuring /etc/login.defs</title>
299
300 <para>
301 The <command>login</command> program currently performs many functions
302 which <application>Linux-PAM</application> modules should now handle.
303 The following <command>sed</command> command will comment out the
304 appropriate lines in <filename>/etc/login.defs</filename>, and stop
305 <command>login</command> from performing these functions (a backup
306 file named <filename>/etc/login.defs.orig</filename> is also created
307 to preserve the original file's contents). Issue the following
308 commands as the <systemitem class="username">root</systemitem> user:
309 </para>
310
311 <indexterm zone="shadow pam-login-defs">
312 <primary sortas="e-etc-login.defs">/etc/login.defs</primary>
313 </indexterm>
314
315<screen role="root"><userinput>install -v -m644 /etc/login.defs /etc/login.defs.orig &amp;&amp;
316for FUNCTION in FAIL_DELAY FAILLOG_ENAB \
317 LASTLOG_ENAB \
318 MAIL_CHECK_ENAB \
319 OBSCURE_CHECKS_ENAB \
320 PORTTIME_CHECKS_ENAB \
321 QUOTAS_ENAB \
322 CONSOLE MOTD_FILE \
323 FTMP_FILE NOLOGINS_FILE \
324 ENV_HZ PASS_MIN_LEN \
325 SU_WHEEL_ONLY \
326 CRACKLIB_DICTPATH \
327 PASS_CHANGE_TRIES \
328 PASS_ALWAYS_WARN \
329 CHFN_AUTH ENCRYPT_METHOD \
330 ENVIRON_FILE
331do
332 sed -i "s/^${FUNCTION}/# &amp;/" /etc/login.defs
333done</userinput></screen>
334 </sect4>
335
336 <sect4>
337 <title>Configuring the /etc/pam.d/ Files</title>
338
339 <para>
340 As mentioned previously in the <application>Linux-PAM</application>
341 instructions, <application>Linux-PAM</application> has two supported
342 methods for configuration. The commands below assume that you've
343 chosen to use a directory based configuration, where each program has
344 its own configuration file. You can optionally use a single
345 <filename>/etc/pam.conf</filename> configuration file by using the
346 text from the files below, and supplying the program name as an
347 additional first field for each line.
348 </para>
349
350 <para>
351 As the <systemitem class="username">root</systemitem> user, replace
352 the following <application>Linux-PAM</application> configuration files
353 in the <filename class="directory">/etc/pam.d/</filename> directory
354 (or add the contents to the <filename>/etc/pam.conf</filename> file)
355 using the following commands:
356 </para>
357 </sect4>
358
359 <sect4>
360 <title>'system-account'</title>
361
362<screen role="root"><userinput>cat &gt; /etc/pam.d/system-account &lt;&lt; "EOF"
363<literal># Begin /etc/pam.d/system-account
364
365account required pam_unix.so
366
367# End /etc/pam.d/system-account</literal>
368EOF</userinput></screen>
369 </sect4>
370
371 <sect4>
372 <title>'system-auth'</title>
373
374<screen role="root"><userinput>cat &gt; /etc/pam.d/system-auth &lt;&lt; "EOF"
375<literal># Begin /etc/pam.d/system-auth
376
377auth required pam_unix.so
378
379# End /etc/pam.d/system-auth</literal>
380EOF</userinput></screen>
381 </sect4>
382
383 <sect4>
384 <title>'system-passwd' (with cracklib)</title>
385
386<screen role="root"><userinput>cat &gt; /etc/pam.d/system-password &lt;&lt; "EOF"
387<literal># Begin /etc/pam.d/system-password
388
389# check new passwords for strength (man pam_cracklib)
390password required pam_cracklib.so type=Linux retry=3 difok=5 \
391 difignore=23 minlen=9 dcredit=1 \
392 ucredit=1 lcredit=1 ocredit=1 \
393 dictpath=/lib/cracklib/pw_dict
394# use sha512 hash for encryption, use shadow, and use the
395# authentication token (chosen password) set by pam_cracklib
396# above (or any previous modules)
397password required pam_unix.so sha512 shadow use_authtok
398
399# End /etc/pam.d/system-password</literal>
400EOF</userinput></screen>
401
402 <note>
403 <para>
404 In its default configuration, owing to credits, pam_cracklib will
405 allow multiple case passwords as short as 6 characters, even with
406 the <parameter>minlen</parameter> value set to 11. You should review
407 the pam_cracklib(8) man page and determine if these default values
408 are acceptable for the security of your system.
409 </para>
410 </note>
411 </sect4>
412
413 <sect4>
414 <title>'system-passwd' (without cracklib)</title>
415
416<screen role="root"><userinput>cat &gt; /etc/pam.d/system-password &lt;&lt; "EOF"
417<literal># Begin /etc/pam.d/system-password
418
419# use sha512 hash for encryption, use shadow, and try to use any previously
420# defined authentication token (chosen password) set by any prior module
421password required pam_unix.so sha512 shadow try_first_pass
422
423# End /etc/pam.d/system-password</literal>
424EOF</userinput></screen>
425 </sect4>
426
427 <sect4>
428 <title>'system-session'</title>
429
430<screen role="root"><userinput>cat &gt; /etc/pam.d/system-session &lt;&lt; "EOF"
431<literal># Begin /etc/pam.d/system-session
432
433session required pam_unix.so
434
435# End /etc/pam.d/system-session</literal>
436EOF</userinput></screen>
437 </sect4>
438
439 <sect4>
440 <title>'login'</title>
441
442<screen role="root"><userinput>cat &gt; /etc/pam.d/login &lt;&lt; "EOF"
443<literal># Begin /etc/pam.d/login
444
445# Set failure delay before next prompt to 3 seconds
446auth optional pam_faildelay.so delay=3000000
447
448# Check to make sure that the user is allowed to login
449auth requisite pam_nologin.so
450
451# Check to make sure that root is allowed to login
452# Disabled by default. You will need to create /etc/securetty
453# file for this module to function. See man 5 securetty.
454#auth required pam_securetty.so
455
456# Additional group memberships - disabled by default
457#auth optional pam_group.so
458
459# include the default auth settings
460auth include system-auth
461
462# check access for the user
463account required pam_access.so
464
465# include the default account settings
466account include system-account
467
468# Set default environment variables for the user
469session required pam_env.so
470
471# Set resource limits for the user
472session required pam_limits.so
473
474# Display date of last login - Disabled by default
475#session optional pam_lastlog.so
476
477# Display the message of the day - Disabled by default
478#session optional pam_motd.so
479
480# Check user's mail - Disabled by default
481#session optional pam_mail.so standard quiet
482
483# include the default session and password settings
484session include system-session
485password include system-password
486
487# End /etc/pam.d/login</literal>
488EOF</userinput></screen>
489 </sect4>
490
491 <sect4>
492 <title>'passwd'</title>
493
494<screen role="root"><userinput>cat &gt; /etc/pam.d/passwd &lt;&lt; "EOF"
495<literal># Begin /etc/pam.d/passwd
496
497password include system-password
498
499# End /etc/pam.d/passwd</literal>
500EOF</userinput></screen>
501 </sect4>
502
503 <sect4>
504 <title>'su'</title>
505
506<screen role="root"><userinput>cat &gt; /etc/pam.d/su &lt;&lt; "EOF"
507<literal># Begin /etc/pam.d/su
508
509# always allow root
510auth sufficient pam_rootok.so
511auth include system-auth
512
513# include the default account settings
514account include system-account
515
516# Set default environment variables for the service user
517session required pam_env.so
518
519# include system session defaults
520session include system-session
521
522# End /etc/pam.d/su</literal>
523EOF</userinput></screen>
524 </sect4>
525
526 <sect4>
527 <title>'chage'</title>
528
529<screen role="root"><userinput>cat &gt; /etc/pam.d/chage &lt;&lt; "EOF"
530<literal>#Begin /etc/pam.d/chage
531
532# always allow root
533auth sufficient pam_rootok.so
534
535# include system defaults for auth account and session
536auth include system-auth
537account include system-account
538session include system-session
539
540# Always permit for authentication updates
541password required pam_permit.so
542
543# End /etc/pam.d/chage</literal>
544EOF</userinput></screen>
545 </sect4>
546
547 <sect4>
548 <title>'chfn', 'chgpasswd', 'chgpasswd', 'chsh', 'groupadd', 'groupdel',
549 'groupmems', 'groupmod', 'newusers', 'useradd', 'userdel' and
550 'usermod'</title>
551
552<screen role="root"><userinput>for PROGRAM in chfn chgpasswd chpasswd chsh groupadd groupdel \
553 groupmems groupmod newusers useradd userdel usermod
554do
555 install -v -m644 /etc/pam.d/chage /etc/pam.d/${PROGRAM}
556 sed -i "s/chage/$PROGRAM/" /etc/pam.d/${PROGRAM}
557done</userinput></screen>
558
559 <warning>
560 <para>
561 At this point, you should do a simple test to see if
562 <application>Shadow</application> is working as expected. Open
563 another terminal and log in as a user, then <command>su</command> to
564 <systemitem class="username">root</systemitem>. If you do not see
565 any errors, then all is well and you should proceed with the rest of
566 the configuration. If you did receive errors, stop now and double
567 check the above configuration files manually. You can also run the
568 test suite from the <application>Linux-PAM</application> package to
569 assist you in determining the problem. If you cannot find and fix
570 the error, you should recompile <application>Shadow</application>
571 adding the <option>--without-libpam</option> switch to the
572 <command>configure</command> command in the above instructions (also
573 move the <filename>/etc/login.defs.orig</filename> backup file to
574 <filename>/etc/login.defs</filename>). If you fail to do this and
575 the errors remain, you will be unable to log into your system.
576 </para>
577 </warning>
578 </sect4>
579
580 <sect4>
581 <title>Other</title>
582
583 <para>
584 Currently, <filename>/etc/pam.d/other</filename> is configured to
585 allow anyone with an account on the machine to use PAM-aware programs
586 without a configuration file for that program. After testing
587 <application>Linux-PAM</application> for proper configuration, install
588 a more restrictive <filename>other</filename> file so that
589 program-specific configuration files are required:
590 </para>
591
592<screen role="root"><userinput>cat &gt; /etc/pam.d/other &lt;&lt; "EOF"
593<literal># Begin /etc/pam.d/other
594
595auth required pam_warn.so
596auth required pam_deny.so
597account required pam_warn.so
598account required pam_deny.so
599password required pam_warn.so
600password required pam_deny.so
601session required pam_warn.so
602session required pam_deny.so
603
604# End /etc/pam.d/other</literal>
605EOF</userinput></screen>
606 </sect4>
607
608 <sect4 id="pam-access">
609 <title>Configuring Login Access</title>
610
611 <para>
612 Instead of using the <filename>/etc/login.access</filename> file for
613 controlling access to the system, <application>Linux-PAM</application>
614 uses the <filename class='libraryfile'>pam_access.so</filename> module
615 along with the <filename>/etc/security/access.conf</filename> file.
616 Rename the <filename>/etc/login.access</filename> file using the
617 following command:
618 </para>
619
620 <indexterm zone="shadow pam-access">
621 <primary sortas="e-etc-security-access.conf">/etc/security/access.conf</primary>
622 </indexterm>
623
624<screen role="root"><userinput>[ -f /etc/login.access ] &amp;&amp; mv -v /etc/login.access{,.NOUSE}</userinput></screen>
625 </sect4>
626
627 <sect4 id="pam-limits">
628 <title>Configuring Resource Limits</title>
629
630 <para>
631 Instead of using the <filename>/etc/limits</filename> file for
632 limiting usage of system resources,
633 <application>Linux-PAM</application> uses the
634 <filename class='libraryfile'>pam_limits.so</filename> module along
635 with the <filename>/etc/security/limits.conf</filename> file. Rename
636 the <filename>/etc/limits</filename> file using the following command:
637 </para>
638
639 <indexterm zone="shadow pam-limits">
640 <primary sortas="e-etc-security-limits.conf">/etc/security/limits.conf</primary>
641 </indexterm>
642
643<screen role="root"><userinput>[ -f /etc/limits ] &amp;&amp; mv -v /etc/limits{,.NOUSE}</userinput></screen>
644 </sect4>
645 </sect3>
646 </sect2>
647
648 <sect2 role="content">
649 <title>Contents</title>
650
651 <para>
652 A list of the installed files, along with their short descriptions can be
653 found at <ulink url="&lfs-root;/chapter06/shadow.html#contents-shadow"/>.
654 </para>
655 </sect2>
656</sect1>
Note: See TracBrowser for help on using the repository browser.