source: postlfs/security/shadow.xml@ e3f6e6a5

12.1 ken/TL2024 ken/tuningfonts lazarus plabs/newcss python3.11 rahul/power-profiles-daemon renodr/vulkan-addition trunk xry111/llvm18
Last change on this file since e3f6e6a5 was e3f6e6a5, checked in by Bruce Dubbs <bdubbs@…>, 6 months ago

Add a warning when updating shadow.
The shadow installation procedure overwrites many files in /etc/pam.d/
which will render system login and su commands (among others) inoperative.

This update adds a warning at the beginning of the build instructions
so it will be hard to miss.

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