source: postlfs/security/shadow.xml@ d0db416

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 8.1 8.2 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts lazarus lxqt perl-modules plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since d0db416 was 5987bf1, checked in by Bruce Dubbs <bdubbs@…>, 7 years ago

Update to shadow-4.5

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

  • Property mode set to 100644
File size: 19.9 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 "https://github.com/shadow-maint/shadow/releases/download/&shadow-version;/shadow-&shadow-version;.tar.xz">
8 <!ENTITY shadow-download-ftp " ">
9 <!ENTITY shadow-md5sum "c350da50c2120de6bb29177699d89fe3">
10 <!ENTITY shadow-size "1.6 MB">
11 <!ENTITY shadow-buildsize "31 MB">
12 <!ENTITY shadow-time "0.2 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>
33 <application>Shadow</application> was indeed installed in LFS and there is
34 no reason to reinstall it unless you installed
35 <application>CrackLib</application> or
36 <application>Linux-PAM</application> after your LFS system was completed.
37 If you have installed <application>CrackLib</application> after LFS, then
38 reinstalling <application>Shadow</application> will enable strong password
39 support. If you have installed <application>Linux-PAM</application>,
40 reinstalling <application>Shadow</application> will allow programs such as
41 <command>login</command> and <command>su</command> to utilize PAM.
42 </para>
43
44 &lfs80_checked;
45 &gcc7_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">Shadow Dependencies</bridgehead>
82
83 <bridgehead renderas="sect4">Required</bridgehead>
84 <para role="required">
85 <xref linkend="linux-pam"/> or
86 <xref linkend="cracklib"/>
87 </para>
88
89 <para condition="html" role="usernotes">
90 User Notes: <ulink url="&blfs-wiki;/shadow"/>
91 </para>
92 </sect2>
93
94 <sect2 role="installation">
95 <title>Installation of Shadow</title>
96
97 <important>
98 <para>
99 The installation commands shown below are for installations where
100 <application>Linux-PAM</application> has been installed (with or
101 without a <application>CrackLib</application> installation) and
102 <application>Shadow</application> is being reinstalled to support the
103 <application>Linux-PAM</application> installation.
104 </para>
105
106 <para>
107 If you are reinstalling <application>Shadow</application> to provide
108 strong password support using the <application>CrackLib</application>
109 library without using <application>Linux-PAM</application>, ensure you
110 add the <parameter>--with-libcrack</parameter> parameter to the
111 <command>configure</command> script below and also issue the following
112 command:
113 </para>
114
115<screen><userinput>sed -i 's@DICTPATH.*@DICTPATH\t/lib/cracklib/pw_dict@' etc/login.defs</userinput></screen>
116 </important>
117
118 <para>
119 Reinstall <application>Shadow</application> by running the following
120 commands:
121 </para>
122
123<screen><userinput>sed -i 's/groups$(EXEEXT) //' src/Makefile.in &amp;&amp;
124
125find man -name Makefile.in -exec sed -i 's/groups\.1 / /' {} \; &amp;&amp;
126find man -name Makefile.in -exec sed -i 's/getspnam\.3 / /' {} \; &amp;&amp;
127find man -name Makefile.in -exec sed -i 's/passwd\.5 / /' {} \; &amp;&amp;
128
129sed -i -e 's@#ENCRYPT_METHOD DES@ENCRYPT_METHOD SHA512@' \
130 -e 's@/var/spool/mail@/var/mail@' etc/login.defs &amp;&amp;
131
132sed -i 's/1000/999/' etc/useradd &amp;&amp;
133
134./configure --sysconfdir=/etc --with-group-name-max-length=32 &amp;&amp;
135make</userinput></screen>
136
137 <para>
138 This package does not come with a test suite.
139 </para>
140
141 <para>
142 Now, as the <systemitem class="username">root</systemitem> user:
143 </para>
144
145<screen role="root"><userinput>make install &amp;&amp;
146mv -v /usr/bin/passwd /bin</userinput></screen>
147 </sect2>
148
149 <sect2 role="commands">
150 <title>Command Explanations</title>
151
152 <para>
153 <command>sed -i 's/groups$(EXEEXT) //' src/Makefile.in</command>: This sed
154 is used to suppress the installation of the <command>groups</command>
155 program as the version from the <application>Coreutils</application>
156 package installed during LFS is preferred.
157 </para>
158
159 <para>
160 <command>find man -name Makefile.in -exec ... {} \;</command>: This
161 command is used to suppress the installation of the
162 <command>groups</command> man pages so the existing ones installed from
163 the <application>Coreutils</application> package are not replaced.
164 </para>
165
166 <para>
167 <command>sed -i -e 's@#ENCRYPT_METHOD DES@ENCRYPT_METHOD SHA512@' -e
168 's@/var/spool/mail@/var/mail@' etc/login.defs</command>: Instead of using
169 the default 'DES' method, this command modifies the installation to use
170 the more secure 'SHA512' method of hashing passwords, which also allows
171 passwords longer than eight characters. It also changes the obsolete
172 <filename class="directory">/var/spool/mail</filename> location for user
173 mailboxes that <application>Shadow</application> uses by default to the
174 <filename class="directory">/var/mail</filename> location.
175 </para>
176
177 <para>
178 <command>sed -i 's/1000/999/' etc/useradd</command>: Make a minor change
179 to make the default useradd consistent with the LFS groups file.
180 </para>
181
182 <para>
183 <parameter>--with-group-name-max-length=32</parameter>: The maximum
184 user name is 32 characters. Make the maximum group name the same.
185 </para>
186
187 <para>
188 <command>mv -v /usr/bin/passwd /bin</command>: The
189 <command>passwd</command> program may be needed during times when the
190 <filename class='directory'>/usr</filename> filesystem is not mounted so
191 it is moved into the root partition.
192 </para>
193 </sect2>
194
195 <sect2 role="configuration">
196 <title>Configuring Shadow</title>
197
198 <para>
199 <application>Shadow</application>'s stock configuration for the
200 <command>useradd</command> utility may not be desirable for your
201 installation. One default parameter causes <command>useradd</command> to
202 create a mailbox file for any newly created user.
203 <command>useradd</command> will make the group ownership of this file to
204 the <systemitem class="groupname">mail</systemitem> group with 0660
205 permissions. If you would prefer that these mailbox files are not created
206 by <command>useradd</command>, issue the following command as the
207 <systemitem class="username">root</systemitem> user:
208 </para>
209
210<screen role="root"><userinput>sed -i 's/yes/no/' /etc/default/useradd</userinput></screen>
211 </sect2>
212
213 <sect2 role="configuration">
214 <title>Configuring Linux-PAM to Work with Shadow</title>
215
216 <note>
217 <para>
218 The rest of this page is devoted to configuring
219 <application>Shadow</application> to work properly with
220 <application>Linux-PAM</application>. If you do not have
221 <application>Linux-PAM</application> installed, and you reinstalled
222 <application>Shadow</application> to support strong passwords via the
223 <application>CrackLib</application> library, no further configuration is
224 required.
225 </para>
226 </note>
227
228 <sect3 id="pam.d">
229 <title>Config Files</title>
230
231 <para>
232 <filename>/etc/pam.d/*</filename> or alternatively
233 <filename>/etc/pam.conf</filename>,
234 <filename>/etc/login.defs</filename> and
235 <filename>/etc/security/*</filename>
236 </para>
237
238 <indexterm zone="shadow pam.d">
239 <primary sortas="e-etc-pam.d">/etc/pam.d/*</primary>
240 </indexterm>
241
242 <indexterm zone="shadow pam.d">
243 <primary sortas="e-etc-pam.conf">/etc/pam.conf</primary>
244 </indexterm>
245
246 <indexterm zone="shadow pam.d">
247 <primary sortas="e-etc-login.defs">/etc/login.defs</primary>
248 </indexterm>
249
250 <indexterm zone="shadow pam.d">
251 <primary sortas="e-etc-security">/etc/security/*</primary>
252 </indexterm>
253 </sect3>
254
255 <sect3>
256 <title>Configuration Information</title>
257
258 <para>
259 Configuring your system to use <application>Linux-PAM</application> can
260 be a complex task. The information below will provide a basic setup so
261 that <application>Shadow</application>'s login and password
262 functionality will work effectively with
263 <application>Linux-PAM</application>. Review the information and links
264 on the <xref linkend="linux-pam"/> page for further configuration
265 information. For information specific to integrating
266 <application>Shadow</application>, <application>Linux-PAM</application>
267 and <application>CrackLib</application>, you can visit the following
268 link:
269 </para>
270
271 <itemizedlist spacing="compact">
272 <listitem>
273 <para>
274 <ulink url="http://www.deer-run.com/~hal/sysadmin/pam_cracklib.html"/>
275 </para>
276 </listitem>
277 </itemizedlist>
278
279 <sect4 id="pam-login-defs">
280 <title>Configuring /etc/login.defs</title>
281
282 <para>
283 The <command>login</command> program currently performs many functions
284 which <application>Linux-PAM</application> modules should now handle.
285 The following <command>sed</command> command will comment out the
286 appropriate lines in <filename>/etc/login.defs</filename>, and stop
287 <command>login</command> from performing these functions (a backup
288 file named <filename>/etc/login.defs.orig</filename> is also created
289 to preserve the original file's contents). Issue the following
290 commands as the <systemitem class="username">root</systemitem> user:
291 </para>
292
293 <indexterm zone="shadow pam-login-defs">
294 <primary sortas="e-etc-login.defs">/etc/login.defs</primary>
295 </indexterm>
296
297<screen role="root"><userinput>install -v -m644 /etc/login.defs /etc/login.defs.orig &amp;&amp;
298for FUNCTION in FAIL_DELAY \
299 FAILLOG_ENAB \
300 LASTLOG_ENAB \
301 MAIL_CHECK_ENAB \
302 OBSCURE_CHECKS_ENAB \
303 PORTTIME_CHECKS_ENAB \
304 QUOTAS_ENAB \
305 CONSOLE MOTD_FILE \
306 FTMP_FILE NOLOGINS_FILE \
307 ENV_HZ PASS_MIN_LEN \
308 SU_WHEEL_ONLY \
309 CRACKLIB_DICTPATH \
310 PASS_CHANGE_TRIES \
311 PASS_ALWAYS_WARN \
312 CHFN_AUTH ENCRYPT_METHOD \
313 ENVIRON_FILE
314do
315 sed -i "s/^${FUNCTION}/# &amp;/" /etc/login.defs
316done</userinput></screen>
317 </sect4>
318
319 <sect4>
320 <title>Configuring the /etc/pam.d/ Files</title>
321
322 <para>
323 As mentioned previously in the <application>Linux-PAM</application>
324 instructions, <application>Linux-PAM</application> has two supported
325 methods for configuration. The commands below assume that you've
326 chosen to use a directory based configuration, where each program has
327 its own configuration file. You can optionally use a single
328 <filename>/etc/pam.conf</filename> configuration file by using the
329 text from the files below, and supplying the program name as an
330 additional first field for each line.
331 </para>
332
333 <para>
334 As the <systemitem class="username">root</systemitem> user, replace
335 the following <application>Linux-PAM</application> configuration files
336 in the <filename class="directory">/etc/pam.d/</filename> directory
337 (or add the contents to the <filename>/etc/pam.conf</filename> file)
338 using the following commands:
339 </para>
340 </sect4>
341
342 <sect4>
343 <title>'login'</title>
344
345<screen role="root"><userinput>cat &gt; /etc/pam.d/login &lt;&lt; "EOF"
346<literal># Begin /etc/pam.d/login
347
348# Set failure delay before next prompt to 3 seconds
349auth optional pam_faildelay.so delay=3000000
350
351# Check to make sure that the user is allowed to login
352auth requisite pam_nologin.so
353
354# Check to make sure that root is allowed to login
355# Disabled by default. You will need to create /etc/securetty
356# file for this module to function. See man 5 securetty.
357#auth required pam_securetty.so
358
359# Additional group memberships - disabled by default
360#auth optional pam_group.so
361
362# include the default auth settings
363auth include system-auth
364
365# check access for the user
366account required pam_access.so
367
368# include the default account settings
369account include system-account
370
371# Set default environment variables for the user
372session required pam_env.so
373
374# Set resource limits for the user
375session required pam_limits.so
376
377# Display date of last login - Disabled by default
378#session optional pam_lastlog.so
379
380# Display the message of the day - Disabled by default
381#session optional pam_motd.so
382
383# Check user's mail - Disabled by default
384#session optional pam_mail.so standard quiet
385
386# include the default session and password settings
387session include system-session
388password include system-password
389
390# End /etc/pam.d/login</literal>
391EOF</userinput></screen>
392 </sect4>
393
394 <sect4>
395 <title>'passwd'</title>
396
397<screen role="root"><userinput>cat &gt; /etc/pam.d/passwd &lt;&lt; "EOF"
398<literal># Begin /etc/pam.d/passwd
399
400password include system-password
401
402# End /etc/pam.d/passwd</literal>
403EOF</userinput></screen>
404 </sect4>
405
406 <sect4>
407 <title>'su'</title>
408
409<screen role="root"><userinput>cat &gt; /etc/pam.d/su &lt;&lt; "EOF"
410<literal># Begin /etc/pam.d/su
411
412# always allow root
413auth sufficient pam_rootok.so
414auth include system-auth
415
416# include the default account settings
417account include system-account
418
419# Set default environment variables for the service user
420session required pam_env.so
421
422# include system session defaults
423session include system-session
424
425# End /etc/pam.d/su</literal>
426EOF</userinput></screen>
427 </sect4>
428
429 <sect4>
430 <title>'chage'</title>
431
432<screen role="root"><userinput>cat &gt; /etc/pam.d/chage &lt;&lt; "EOF"
433<literal># Begin /etc/pam.d/chage
434
435# always allow root
436auth sufficient pam_rootok.so
437
438# include system defaults for auth account and session
439auth include system-auth
440account include system-account
441session include system-session
442
443# Always permit for authentication updates
444password required pam_permit.so
445
446# End /etc/pam.d/chage</literal>
447EOF</userinput></screen>
448 </sect4>
449
450 <sect4>
451 <title>Other common programs</title>
452 <!--<title>'chfn', 'chgpasswd', 'chgpasswd', 'chsh', 'groupadd', 'groupdel',
453 'groupmems', 'groupmod', 'newusers', 'useradd', 'userdel' and
454 'usermod'</title>-->
455
456<screen role="root"><userinput>for PROGRAM in chfn chgpasswd chpasswd chsh groupadd groupdel \
457 groupmems groupmod newusers useradd userdel usermod
458do
459 install -v -m644 /etc/pam.d/chage /etc/pam.d/${PROGRAM}
460 sed -i "s/chage/$PROGRAM/" /etc/pam.d/${PROGRAM}
461done</userinput></screen>
462
463 <para revision="systemd">Because the installation of
464 <application>systemd</application> is not yet complete, you will need
465 to remove the <filename>/run/nologin</filename> file before testing the
466 installation. Execute the following command as the
467 <systemitem class="username">root</systemitem> user:</para>
468
469<screen role="root" revision="systemd"><userinput>rm -f /run/nologin</userinput></screen>
470
471 <warning>
472 <para>
473 At this point, you should do a simple test to see if
474 <application>Shadow</application> is working as expected. Open
475 another terminal and log in as a user, then <command>su</command> to
476 <systemitem class="username">root</systemitem>. If you do not see
477 any errors, then all is well and you should proceed with the rest of
478 the configuration. If you did receive errors, stop now and double
479 check the above configuration files manually. You can also run the
480 test suite from the <application>Linux-PAM</application> package to
481 assist you in determining the problem. If you cannot find and fix
482 the error, you should recompile <application>Shadow</application>
483 adding the <option>--without-libpam</option> switch to the
484 <command>configure</command> command in the above instructions (also
485 move the <filename>/etc/login.defs.orig</filename> backup file to
486 <filename>/etc/login.defs</filename>). If you fail to do this and
487 the errors remain, you will be unable to log into your system.
488 </para>
489 </warning>
490 </sect4>
491
492 <sect4 id="pam-access">
493 <title>Configuring Login Access</title>
494
495 <para>
496 Instead of using the <filename>/etc/login.access</filename> file for
497 controlling access to the system, <application>Linux-PAM</application>
498 uses the <filename class='libraryfile'>pam_access.so</filename> module
499 along with the <filename>/etc/security/access.conf</filename> file.
500 Rename the <filename>/etc/login.access</filename> file using the
501 following command:
502 </para>
503
504 <indexterm zone="shadow pam-access">
505 <primary sortas="e-etc-security-access.conf">/etc/security/access.conf</primary>
506 </indexterm>
507
508<screen role="root"><userinput>[ -f /etc/login.access ] &amp;&amp; mv -v /etc/login.access{,.NOUSE}</userinput></screen>
509 </sect4>
510
511 <sect4 id="pam-limits">
512 <title>Configuring Resource Limits</title>
513
514 <para>
515 Instead of using the <filename>/etc/limits</filename> file for
516 limiting usage of system resources,
517 <application>Linux-PAM</application> uses the
518 <filename class='libraryfile'>pam_limits.so</filename> module along
519 with the <filename>/etc/security/limits.conf</filename> file. Rename
520 the <filename>/etc/limits</filename> file using the following command:
521 </para>
522
523 <indexterm zone="shadow pam-limits">
524 <primary sortas="e-etc-security-limits.conf">/etc/security/limits.conf</primary>
525 </indexterm>
526
527<screen role="root"><userinput>[ -f /etc/limits ] &amp;&amp; mv -v /etc/limits{,.NOUSE}</userinput></screen>
528
529 <caution><para>Be sure to test the login capabilities of the system
530 before logging out. Errors in the configuration can cause a permanent
531 lockout requiring a boot from an external source to correct the
532 problem.</para></caution>
533
534 </sect4>
535 </sect3>
536
537 </sect2>
538
539 <sect2 role="content">
540 <title>Contents</title>
541
542 <para>
543 A list of the installed files, along with their short descriptions can be
544 found at
545 <phrase revision="sysv">
546 <ulink url="&lfs-root;/chapter06/shadow.html#contents-shadow"/></phrase>
547 <phrase revision="systemd">
548 <ulink url="&lfs-rootd;/chapter06/shadow.html#contents-shadow"/></phrase>.
549 </para>
550
551 </sect2>
552
553</sect1>
Note: See TracBrowser for help on using the repository browser.