source: postlfs/security/shadow.xml@ 14891a90

12.0 12.1 kea ken/TL2024 ken/tuningfonts lazarus lxqt plabs/newcss python3.11 rahul/power-profiles-daemon renodr/vulkan-addition trunk xry111/llvm18 xry111/xf86-video-removal
Last change on this file since 14891a90 was 14891a90, checked in by Xi Ruoyao <xry111@…>, 10 months ago

treewide: More "User Notes" clean up

Remove links to pages w/o real contents.

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