source: chapter06/createfiles.xml@ 7406bec

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 7406bec was 7406bec, checked in by Bruce Dubbs <bdubbs@…>, 4 years ago

Add an unprivileged user, tester, at the
beginning of Chapter 6 for running some tests. This
user is then removed at the end of the chapter.

Update to zstd-1.4.5. Fixes
Update to util-linux-2.35.2. Fixes
Update to bison-3.6.2. Fixes
Update to linux-5.6.15. Fixes

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@11864 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 13.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
8<sect1 id="ch-system-createfiles">
9 <?dbhtml filename="createfiles.html"?>
10
11 <title>Creating Essential Files and Symlinks</title>
12
13 <indexterm zone="ch-system-createfiles">
14 <primary sortas="e-/etc/passwd">/etc/passwd</primary>
15 </indexterm>
16
17 <indexterm zone="ch-system-createfiles">
18 <primary sortas="e-/etc/group">/etc/group</primary>
19 </indexterm>
20
21 <indexterm zone="ch-system-createfiles">
22 <primary sortas="e-/var/run/utmp">/var/run/utmp</primary>
23 </indexterm>
24
25 <indexterm zone="ch-system-createfiles">
26 <primary sortas="e-/var/log/btmp">/var/log/btmp</primary>
27 </indexterm>
28
29 <indexterm zone="ch-system-createfiles">
30 <primary sortas="e-/var/log/lastlog">/var/log/lastlog</primary>
31 </indexterm>
32
33 <indexterm zone="ch-system-createfiles">
34 <primary sortas="e-/var/log/wtmp">/var/log/wtmp</primary>
35 </indexterm>
36
37 <para>Some programs use hard-wired paths to programs which do not exist yet.
38 In order to satisfy these programs, create a number of symbolic links which
39 will be replaced by real files throughout the course of this chapter after the
40 software has been installed:</para>
41
42<screen><userinput>ln -sv /tools/bin/{bash,cat,chmod,dd,echo,ln,mkdir,pwd,rm,stty,touch} /bin
43ln -sv /tools/bin/{env,install,perl,printf} /usr/bin
44ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
45ln -sv /tools/lib/libstdc++.{a,so{,.6}} /usr/lib
46ln -sv /tools/lib/libfl.so* /usr/lib
47
48ln -sv bash /bin/sh
49
50for lib in blkid mount uuid fdisk
51do
52 ln -sv /tools/lib/lib$lib.so* /usr/lib
53 sed 's|/tools|/usr|' /tools/lib/pkgconfig/${lib}.pc \
54 &gt; /usr/lib/pkgconfig/${lib}.pc
55done
56for incdir in blkid libmount uuid libfdisk
57do
58 ln -svf /tools/include/$incdir /usr/include
59done
60
61mkdir -pv /tools/lib/locale
62ln -sv /usr/lib/locale/locale-archive /tools/lib/locale</userinput></screen>
63
64 <variablelist>
65 <title>The purpose of each link:</title>
66
67 <varlistentry>
68 <term><parameter><filename>/bin/bash</filename></parameter></term>
69 <listitem>
70 <para>Many <command>bash</command> scripts specify
71 <filename>/bin/bash</filename>.</para>
72 </listitem>
73 </varlistentry>
74
75 <varlistentry>
76 <term><parameter><filename>/bin/cat</filename></parameter></term>
77 <listitem>
78 <para>This pathname is hard-coded into Glibc's configure script.</para>
79 </listitem>
80 </varlistentry>
81
82 <varlistentry>
83 <term><parameter><filename>/bin/dd</filename></parameter></term>
84 <listitem>
85 <para>The path to <filename>dd</filename> will be hard-coded into the
86 <filename>/usr/bin/libtool</filename> utility.</para>
87 </listitem>
88 </varlistentry>
89
90 <varlistentry>
91 <term><parameter><filename>/bin/echo</filename></parameter></term>
92 <listitem>
93 <para>This is to satisfy one of the tests in Glibc's test suite, which
94 expects <filename>/bin/echo</filename>.</para>
95 </listitem>
96 </varlistentry>
97
98 <varlistentry>
99 <term><parameter><filename>/usr/bin/env</filename></parameter></term>
100 <listitem>
101 <para>This pathname is hard-coded into some packages build procedures.
102 <!-- systemd This may not be needed if we move sysd to the end--></para>
103 </listitem>
104 </varlistentry>
105
106 <varlistentry>
107 <term><parameter><filename>/usr/bin/install</filename></parameter></term>
108 <listitem>
109 <para>The path to <filename>install</filename> will be hard-coded into
110 the <filename>/usr/lib/bash/Makefile.inc</filename> file.</para>
111 </listitem>
112 </varlistentry>
113
114 <varlistentry>
115 <term><parameter><filename>/bin/ln</filename></parameter></term>
116 <listitem>
117 <para>The path to <filename>ln</filename> will be hard-coded into the
118 <filename>/usr/lib/perl5/&perl-version;/&lt;target-triplet&gt;/Config_heavy.pl</filename>
119 file.</para>
120 </listitem>
121 </varlistentry>
122
123 <varlistentry>
124 <term><parameter><filename>/bin/pwd</filename></parameter></term>
125 <listitem>
126 <para>Some <command>configure</command> scripts, particularly Glibc's,
127 have this pathname hard-coded.</para>
128 </listitem>
129 </varlistentry>
130
131 <varlistentry>
132 <term><parameter><filename>/bin/rm</filename></parameter></term>
133 <listitem>
134 <para>The path to <filename>rm</filename> will be hard-coded into the
135 <filename>/usr/lib/perl5/&perl-version;/&lt;target-triplet&gt;/Config_heavy.pl</filename>
136 file.</para>
137 </listitem>
138 </varlistentry>
139
140 <varlistentry>
141 <term><parameter><filename>/bin/stty</filename></parameter></term>
142 <listitem>
143 <para>This pathname is hard-coded into Expect, therefore it is needed
144 for Binutils and GCC test suites to pass.</para>
145 </listitem>
146 </varlistentry>
147
148 <varlistentry>
149 <term><parameter><filename>/usr/bin/perl</filename></parameter></term>
150 <listitem>
151 <para>Many Perl scripts hard-code this path to the
152 <command>perl</command> program.</para>
153 </listitem>
154 </varlistentry>
155
156 <varlistentry>
157 <term><parameter><filename>/usr/lib/libgcc_s.so{,.1}</filename></parameter></term>
158 <listitem>
159 <para>Glibc needs this for the pthreads library to work.</para>
160 </listitem>
161 </varlistentry>
162
163 <varlistentry>
164 <term><parameter><filename>/usr/lib/libstdc++{,.6}</filename></parameter></term>
165 <listitem>
166 <para>This is needed by several tests in Glibc's test suite, as well as
167 for C++ support in GMP.</para>
168 </listitem>
169 </varlistentry>
170
171 <varlistentry>
172 <term><parameter><filename>/bin/sh</filename></parameter></term>
173 <listitem>
174 <para>Many shell scripts hard-code <filename>/bin/sh</filename>.</para>
175 </listitem>
176 </varlistentry>
177
178 <varlistentry>
179 <term>
180 <parameter><filename>/usr/lib/libfl.so*</filename></parameter>
181 </term>
182 <listitem>
183 <para>This link allows binutils to find the flex library, and to
184 build enhanced versions of ar and ranlib.</para>
185 </listitem>
186 </varlistentry>
187
188 <varlistentry>
189 <term>
190 <parameter>
191 <filename>/usr/lib/lib{blkid,fdisk,mount,uuid}.so*</filename>,
192 <filename>/usr/include/{blkid,libfdisk,libmount,uuid}</filename>,
193 <filename>/usr/lib/pkgconfig/{blkid,fdisk,mount,uuid}.pc</filename>
194 </parameter>
195 </term>
196 <listitem>
197 <para>These links and files allow
198 <phrase revision="sysv">eudev</phrase>
199 <phrase revision="systemd">systemd</phrase> to find the
200 util-linux libraries installed in chapter 5, without creating
201 wrong references to /tools. The uuid library is also needed for
202 building a python module.</para>
203 </listitem>
204 </varlistentry>
205
206 <varlistentry>
207 <term>
208 <parameter>
209 <filename>/tools/lib/locale/locale-archive</filename>
210 </parameter>
211 </term>
212 <listitem>
213 <para>Some programs built in chapter 5 look for installed
214 locale descriptions in this file. The locale descriptions will be
215 installed in <filename>/usr/lib/locale/locale-archive</filename>
216 after building the final glibc. The symlink allows those programs
217 to use the installed locales.</para>
218 </listitem>
219 </varlistentry>
220
221 </variablelist>
222
223 <para>Historically, Linux maintains a list of the mounted file systems in the
224 file <filename>/etc/mtab</filename>. Modern kernels maintain this list
225 internally and exposes it to the user via the <filename
226 class="directory">/proc</filename> filesystem. To satisfy utilities that
227 expect the presence of <filename>/etc/mtab</filename>, create the following
228 symbolic link:</para>
229
230<screen><userinput>ln -sv /proc/self/mounts /etc/mtab</userinput></screen>
231
232 <para>In order for user <systemitem class="username">root</systemitem> to be
233 able to login and for the name <quote>root</quote> to be recognized, there
234 must be relevant entries in the <filename>/etc/passwd</filename> and
235 <filename>/etc/group</filename> files.</para>
236
237 <para>Create the <filename>/etc/passwd</filename> file by running the following
238 command:</para>
239
240<screen revision="sysv"><userinput>cat &gt; /etc/passwd &lt;&lt; "EOF"
241<literal>root:x:0:0:root:/root:/bin/bash
242bin:x:1:1:bin:/dev/null:/bin/false
243daemon:x:6:6:Daemon User:/dev/null:/bin/false
244messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
245nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>
246EOF</userinput></screen>
247
248<screen revision="systemd"><userinput>cat &gt; /etc/passwd &lt;&lt; "EOF"
249<literal>root:x:0:0:root:/root:/bin/bash
250bin:x:1:1:bin:/dev/null:/bin/false
251daemon:x:6:6:Daemon User:/dev/null:/bin/false
252messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
253systemd-bus-proxy:x:72:72:systemd Bus Proxy:/:/bin/false
254systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/bin/false
255systemd-journal-remote:x:74:74:systemd Journal Remote:/:/bin/false
256systemd-journal-upload:x:75:75:systemd Journal Upload:/:/bin/false
257systemd-network:x:76:76:systemd Network Management:/:/bin/false
258systemd-resolve:x:77:77:systemd Resolver:/:/bin/false
259systemd-timesync:x:78:78:systemd Time Synchronization:/:/bin/false
260systemd-coredump:x:79:79:systemd Core Dumper:/:/bin/false
261nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>
262EOF</userinput></screen>
263
264 <para>The actual password for <systemitem class="username">root</systemitem>
265 (the <quote>x</quote> used here is just a placeholder) will be set later.</para>
266
267 <para>Create the <filename>/etc/group</filename> file by running the following
268 command:</para>
269
270<screen revision="sysv"><userinput>cat &gt; /etc/group &lt;&lt; "EOF"
271<literal>root:x:0:
272bin:x:1:daemon
273sys:x:2:
274kmem:x:3:
275tape:x:4:
276tty:x:5:
277daemon:x:6:
278floppy:x:7:
279disk:x:8:
280lp:x:9:
281dialout:x:10:
282audio:x:11:
283video:x:12:
284utmp:x:13:
285usb:x:14:
286cdrom:x:15:
287adm:x:16:
288messagebus:x:18:
289input:x:24:
290mail:x:34:
291kvm:x:61:
292wheel:x:97:
293nogroup:x:99:
294users:x:999:</literal>
295EOF</userinput></screen>
296
297<screen revision="systemd"><userinput>cat &gt; /etc/group &lt;&lt; "EOF"
298<literal>root:x:0:
299bin:x:1:daemon
300sys:x:2:
301kmem:x:3:
302tape:x:4:
303tty:x:5:
304daemon:x:6:
305floppy:x:7:
306disk:x:8:
307lp:x:9:
308dialout:x:10:
309audio:x:11:
310video:x:12:
311utmp:x:13:
312usb:x:14:
313cdrom:x:15:
314adm:x:16:
315messagebus:x:18:
316systemd-journal:x:23:
317input:x:24:
318mail:x:34:
319kvm:x:61:
320systemd-bus-proxy:x:72:
321systemd-journal-gateway:x:73:
322systemd-journal-remote:x:74:
323systemd-journal-upload:x:75:
324systemd-network:x:76:
325systemd-resolve:x:77:
326systemd-timesync:x:78:
327systemd-coredump:x:79:
328wheel:x:97:
329nogroup:x:99:
330users:x:999:</literal>
331EOF</userinput></screen>
332
333 <para>The created groups are not part of any standard&mdash;they are groups
334 decided on in part by the requirements of the Udev configuration in this
335 chapter, and in part by common convention employed by a number of existing
336 Linux distributions. In addition, some test suites rely on specific users
337 or groups. The Linux Standard Base (LSB, available at <ulink
338 url="http://www.linuxbase.org"/>) recommends only that, besides the group
339 <systemitem class="groupname">root</systemitem> with a Group ID (GID) of 0,
340 a group <systemitem class="groupname">bin</systemitem> with a GID of 1 be
341 present. All other group names and GIDs can be chosen freely by the system
342 administrator since well-written programs do not depend on GID numbers, but
343 rather use the group's name.</para>
344
345 <para>Some tests later in the chapter need a regular user. We add this
346 user here and delete this account at the end of the chapter.</para>
347
348<screen><userinput>echo "tester:x:101:101::/tmp:/bin/bash" &gt;&gt; /etc/passwd
349echo "tester:x:101:dummy" &gt;&gt; /etc/group</userinput></screen>
350
351 <para>To remove the <quote>I have no name!</quote> prompt, start a new
352 shell. Since a full Glibc was installed in <xref
353 linkend="chapter-temporary-tools"/> and the
354 <filename>/etc/passwd</filename> and <filename>/etc/group</filename>
355 files have been created, user name and group name resolution will now
356 work:</para>
357
358<screen role="nodump"><userinput>exec /tools/bin/bash --login +h</userinput></screen>
359
360 <para>Note the use of the <parameter>+h</parameter> directive. This tells
361 <command>bash</command> not to use its internal path hashing. Without this
362 directive, <command>bash</command> would remember the paths to binaries it has
363 executed. To ensure the use of the newly compiled binaries as soon as they are
364 installed, the <parameter>+h</parameter> directive will be used for the duration
365 of this chapter.</para>
366
367 <para>The <command>login</command>, <command>agetty</command>, and
368 <command>init</command> programs (and others) use a number of log
369 files to record information such as who was logged into the system and
370 when. However, these programs will not write to the log files if they
371 do not already exist. Initialize the log files and give them
372 proper permissions:</para>
373
374<screen><userinput>touch /var/log/{btmp,lastlog,faillog,wtmp}
375chgrp -v utmp /var/log/lastlog
376chmod -v 664 /var/log/lastlog
377chmod -v 600 /var/log/btmp</userinput></screen>
378
379 <para>The <filename>/var/log/wtmp</filename> file records all logins and
380 logouts. The <filename>/var/log/lastlog</filename> file records when each
381 user last logged in. The <filename>/var/log/faillog</filename> file records
382 failed login attempts. The <filename>/var/log/btmp</filename> file records
383 the bad login attempts.</para>
384
385 <note><para>The <filename>/run/utmp</filename> file records the users that
386 are currently logged in. This file is created dynamically in the boot
387 scripts.</para></note>
388
389</sect1>
Note: See TracBrowser for help on using the repository browser.