source: postlfs/security/shadow.xml@ 3f2db3a6

11.3 12.0 12.1 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts lazarus lxqt plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk xry111/llvm18 xry111/xf86-video-removal
Last change on this file since 3f2db3a6 was 3f2db3a6, checked in by Pierre Labastie <pierre.labastie@…>, 17 months ago

Remove sect1info tags

They only contain a date tag that is nowhere used.

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