lfs-uefi: fix efivar-37 FTBFS
[linux_from_scratch_hints.git] / nss_db.txt
blobcbb15b349e9c7cf852524352c585fb8c93c18928
1 AUTHOR:   Randy McMurchy <randy_at_linuxfromscratch.org>
3 DATE:     2005-10-27
5 LICENSE:  Creative Commons Attribution-NonCommercial-ShareAlike License
6           http://creativecommons.org/licenses/by-nc-sa/1.0/
8 SYNOPSIS: Installing the nss_db library and creating the NSS db files
10 DESCRIPTION:
12 This hint will guide you through the installation of the nss_db package and
13 population of the NSS db files. Additionally, the hint covers making the
14 necessary changes to /etc/nsswitch.conf as well as providing another way to
15 populate some of the db files.
17 ATTACHMENTS:
19 http://www.linuxfromscratch.org/patches/downloads/nss_db/nss_db-2.2-update-2.patch
21 PREREQUISITES:
23 An LFS system using Glibc-2.3.x.
25 HINT:
27 =========
28 CONTENTS:
29 =========
31         1. Introduction
32         2. Package Dependencies
33         3. Package Installation
34             Download the package
35             Patch the package
36             Update the autotool programs
37             Configure the build
38             Build the package
39             Checking the build
40             Install the package
41             Stripping the binaries
42             Installation modifications
43             Update /etc/ld.so.cache
44         4. Creating the DB Files
45         5. Configuring /etc/nsswitch.conf
46         6. Testing the Installation
47         7. Alternate Method to Populate Files
48         8. Issues, Gotchas and Other Sundry Items
49         9. To Do List
50        10. Closing
52 ================
53 1. INTRODUCTION:
54 ================
56 Up until version 2.2.0 of Glibc, the nss_db library, as well as Berkeley DB,
57 were included with the Glibc package. Beginning with Glibc-2.2.0, nss_db and
58 DB were removed from Glibc as the maintainers could not control the version
59 of DB installed on the system. If DB was upgraded on the system, it could 
60 render nss_db unusable. So, at this point the decision was made to make
61 nss_db a separate package.
63 As official Glibc releases were made public, nss_db was left behind. There's
64 been no official updates to the nss_db package since Glibc-2.2.0. Some of the
65 mainstream Linux distro's have been keeping nss_db alive during this time.
66 This hint brings nss_db back to LFS users.
68 The following files are duplicated as db files and may be used as primary or
69 alternate nameservice files using the nss_db library.
71 1) /etc/passwd
72 2) /etc/group
73 3) /etc/shadow
74 4) /etc/services
75 5) /etc/protocols
76 6) /etc/rpc
78 There are many good uses for nss_db as a nameservice resolver on your system.
80 1) On a stand-alone Linux system, nss_db can be used to provide a backup
81 mechanism for the nameservice /etc/flatfiles. There are reports that if your
82 Linux system has very large /etc/flatfiles, using nss_db to resolve the 
83 nameservice information is faster than using the /etc/flatfiles.
85 2) In a networked environment, the administrator can create db files to 
86 supplement the /etc/flatfiles. These db files could be placed on an NFS
87 partition which is locally mounted by other systems, giving the administrator
88 a central location for updating nameservice information.
90 3) In a network environment where usernames are resolved over the network
91 (LDAP, WINS, etc.), copies of the username login authentication files
92 can be stored locally, eliminating the need to fetch this information from
93 the network. This is especially important for laptop users who may connect
94 to the network while on premises, but need to authenticate when not attached
95 to the physical network.
97 ========================
98 2. PACKAGE DEPENDENCIES:
99 ========================
101 Berkeley DB-4.x 
103 Instructions for installing the DB package can be found at:
105 Stable release:
106 http://www.linuxfromscratch.org/blfs/view/stable/server/databases.html#db
108 Development release:
109 http://www.linuxfromscratch.org/blfs/view/svn/server/databases.html#db
111 ========================
112 3. PACKAGE INSTALLATION:
113 ========================
115 ---------------------
116 Download the package:
117 ---------------------
119 The last available "official" release of nss_db is nss_db-2.2 and can be
120 downloaded using the following URL's:
122 Anonymous FTP:
123 ftp://ftp.gnu.org/gnu/glibc/nss_db-2.2.tar.gz
125 HTTP:
126 http://ftp.gnu.org/gnu/glibc/nss_db-2.2.tar.gz
128 ------------------
129 Patch the package:
130 ------------------
132 You must first download and install the patch. The patch is included as an
133 attachment to this hint. See the Attachments section at the beginning of the
134 hint for download locations.
136 First unpack the nss_db tarball and change into the newly created source
137 directory. Patch the package by running the following command:
139 patch -Np1 -i ../nss_db-2.2-update-2.patch
141 The patch does many things.
143 1) Allows building against Glibc-2.3.x.
144 2) Changes DB calls to use DB-4.x
145 3) Fixes a problem with a db-open routine.
146 4) Adds the necessary pthread LDFLAGS to the Makefile.
147 5) Allows a user-specified db directory using --localstatedir as a switch to
148    the configure script.
149 6) Modifies the Makefile used to create the db files to reflect the directory
150    used to store the files, then copies the Makefile into this db directory.
152 -----------------------------
153 Update the autotool programs:
154 -----------------------------
156 Run the following commands to create the proper autotool programs and
157 scripts:
159 aclocal
160 automake -a
161 libtoolize -f
162 autoconf
164 You may receive warnings when running the "aclocal", "automake" and
165 "autoconf" programs. You can safely ignore these warnings.
167 --------------------
168 Configure the Build:
169 --------------------
171 ./configure --prefix=/usr --localstatedir=/var/lib/nss_db
173 Command explanations:
175 --prefix=/usr: installs the library in /lib, the .so symlink to the library
176 in /usr/lib and the makedb program in /usr/bin
178 --localstatedir=/var/lib/nss_db: points to the location of the actual db files
179 created by the makedb program. The default location is /var/db, however there
180 is no mention of this directory in the FHS guidelines. You may choose any
181 directory you wish. If you desire the Glibc default of /var/db, simply leave
182 off the --localstatedir switch altogether.
184 ------------------
185 Build the Package:
186 ------------------
188 Simply running the "make" command will build the package.
190 -------------------
191 Checking the Build:
192 -------------------
194 There are no "check" rules in the various subdirectory makefiles, so there's
195 nothing to check. Running the "make check" command is pointless.
197 --------------------
198 Install the Package:
199 --------------------
201 ****************************************************************************
202 *****                                                                  *****
203 *****  The remainder of this hint must be performed by the root user   *****
204 *****                                                                  *****
205 ****************************************************************************
207 Simply issue a "make install" command to install the package. If desired,
208 create a /usr/share/doc/nss_db-2.2 directory and copy the README, INSTALL
209 and this hint file into the directory. This will serve as the installed
210 documentation for nss_db.
212 Additionally, you may wish to remove the /lib/libnss_db.so file, as it was
213 also installed into /usr/lib (where it belongs). Lastly, you can move the
214 /lib/libnss_db.la file into /usr/lib, as this is the proper location for the
215 file.
217 -----------------------
218 Stripping the Binaries:
219 -----------------------
221 If desired, strip the unnecessary symbols from the installed binaries by
222 issuing the following commands:
224 strip --strip-all /usr/bin/makedb
225 strip --strip-debug /lib/libnss_db.so.2.0.0
227 ---------------------------
228 Installation Modifications:
229 ---------------------------
231 If your system's /usr directory is not part of the root partition and is not
232 mounted when in single-user mode, you may wish to copy the DB libraries to /lib
233 so that the nss_db library can find them during times when /usr is not mounted.
235 The following commands move libraries created by Berkeley DB-4.3.28. If you
236 have installed a different version of DB, you may need to change the following
237 commands to reflect the actual names of the DB libraries.
239 Use the following commands to move the DB libraries and create symlinks in
240 /usr/lib pointing back to /lib so that programs looking for DB in /usr/lib
241 won't break.
243 mv /usr/lib/libdb-4.3.so /lib
244 mv /usr/lib/libdb-4.so /lib
245 ln -s ../../lib/libdb-4.3.so /usr/lib
246 ln -s ../../lib/libdb-4.so /usr/lib
248 ------------------------
249 Update /etc/ld.so.cache:
250 ------------------------
252 Update the linker's library cache file by issuing the "ldconfig" command:
254 ldconfig -v
256 =========================
257 4. CREATING THE DB FILES:
258 =========================
260 To create the db files, simply run the following command:
262 make -f /var/lib/nss_db/Makefile
264 You should substitute the correct path to the Makefile if you omitted or used
265 a different path on the --localstatedir switch to the configure command
266 during installation of the package.
268 After creating the initial db files, if you modify any of the /etc/flatfiles
269 and want to update the db files, simply run the command again. The
270 appropriate db files will be updated to reflect the changes in the /etc
271 files.
273 =================================
274 5. CONFIGURING /etc/nsswitch.conf
275 =================================
277 So that Glibc can use the db files, you'll need to make appropriate changes
278 to the /etc/nsswitch.conf file. I won't insult you by recommending any
279 necessary changes. If you're installing the nss_db package, you should know
280 how to use it! If you need a refresher, start by looking at the man page for
281 nsswitch.conf. This reference doesn't explicitly cover the use of db files,
282 though you should be able to get the drift from the example files given.
284 The actual files used by nss_db that can be referenced in the nsswitch.conf
285 file are listed in the Introduction section of this hint. 
287 ============================
288 6. TESTING THE INSTALLATION:
289 ============================
291 Testing the installation is simple. Modify any of the /etc/flatfiles and
292 run the make script to update the db files. Then remove the modifications
293 from the /etc files and test. You can test by logging into the system as
294 a user identified only in the db files, or by using a service only identified
295 in the services.db or protocol.db file.
297 You can also test using the id and getent programs. The id program has a
298 man page and getent --help will show you how to use getent.
300 Alternately, if you've already created the db files and don't wish to add
301 anything to them, make backup copies and remove a user from /etc/passwd
302 or an entry in /etc/services, or any other file you've identified in the
303 /etc/nsswitch.conf file to resolve using nss_db and test.
305 ======================================
306 7. ALTERNATE METHOD TO POPULATE FILES:
307 ======================================
309 The procedures up to this point provide a way to duplicate the information
310 in /etc/flatfiles. You can also use nss_db to resolve information from other
311 sources. This section deals with using sources other than /etc for the passwd
312 and group files. 
314 If your system resolves user and group names using sources other than
315 /etc/passwd and /etc/group, you can create db files using another method.
316 This method requires the use of the nss_updatedb package provided by PADL
317 software.
319 The instructions for downloading and installing the nss_updatedb package can
320 be found in my ldap_nameservice.txt hint, right now located at:
321 http://www.mcmurchy.com/lfs/ldap-nameservice.txt
323 Note: If you specified a custom directory (other than /var/db) using the
324 --localstatedir switch to the configure script when you built the nss_db
325 package, you'll need to install the patch I created for the nss_updatedb
326 package. By default, the nss_updatedb package creates/updates files in the
327 /var/db directory. Instructions for downloading and installing the patch are
328 included in the ldap_nameservice.txt hint.
330 See the README file included with the nss_updatedb package for instructions
331 on using the package to create/update the passwd and group db files.
333 ==========================================
334 8. ISSUES, GOTCHAS AND OTHER SUNDRY ITEMS:
335 ==========================================
337 None noted.
339 ========
340 9. TODO:
341 ========
343 1) Test nss_db using nss_updatedb to create passwd and group files based on
344    WINS data.
346 ============
347 10. CLOSING:
348 ============
350 During the testing and experimenting with an installation using LDAP and
351 Kerberos is where my idea of resurrecting nss_db came about. I wanted a way
352 to have local access to the LDAP user/group information. Because PADL
353 software already had the nss_updatedb package, all there was for me to do was
354 figure out how my LFS system could use nss_db. Thanks to the help of the 
355 folks mentioned below and a little perseverance on my part, nss_db is now
356 available to LFS users. Enjoy!
358 ACKNOWLEDGEMENTS:
360 Luke Howard <lukeh_at_padl_dot_com> for a fix to an nss_db db-open bug
361 DJ Lucas <dj_at_lucasit_dot_com> for the research and assistance
362 The folks at Red Hat for continuing to maintain nss_db from where
363 many of the patches have been acquired.
365 CHANGELOG:
367 [2004-06-08]
368     * Original draft
370 [2005-10-27]
371     * Updates to fix issues using newer versions of Glibc and Berkeley DB