source: postlfs/security/shadow.xml@ 5443006d

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 5443006d was 5443006d, checked in by Krejzi <krejzi@…>, 12 years ago

shadow 4.1.5

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

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