1.\" $NetBSD: ldconfig.8,v 1.12 2000/10/08 09:53:00 bjh21 Exp $ 2.\" 3.\" Copyright (c) 1998 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Paul Kranenburg. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the NetBSD 20.\" Foundation, Inc. and its contributors. 21.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22.\" contributors may be used to endorse or promote products derived 23.\" from this software without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35.\" POSSIBILITY OF SUCH DAMAGE. 36.\" 37.Dd October 8, 2000 38.Dt LDCONFIG 8 39.Os 40.Sh NAME 41.Nm ldconfig 42.Nd configure the a.out shared library cache 43.Sh SYNOPSIS 44.Nm ldconfig 45.Op Fl cmrsSv 46.Op Ar directory Ar ... 47.Sh DESCRIPTION 48.Nm 49is used to prepare a set of 50.Dq hints 51for use by the a.out run-time linker 52.Nm ld.so 53to facilitate quick lookup of shared libraries available in multiple 54directories. 55.Nm 56is only available on systems that use the 57.Dq a.out 58format for executables and libraries \(en on ELF systems, all the work 59is done by 60.Nm ld.elf_so . 61.Pp 62By default, it scans a set of built-in system directories, 63directories listed in 64.Pa /etc/ld.so.conf , 65and any 66.Ar directories 67specified on the command line (in the given order) looking for shared 68libraries and stores the results in the file 69.Pa /var/run/ld.so.hints 70to forestall the overhead that would otherwise result from the 71directory search operations 72.Nm ld.so 73would have to perform to load required shared libraries. 74.Pp 75The shared libraries so found will be automatically available for loading 76if needed by the program being prepared for execution. This obviates the need 77for storing search paths within the executable. 78.Pp 79The 80.Ev LD_LIBRARY_PATH 81environment variable can be used to override the use of 82directories (or the order thereof) from the cache or to specify additional 83directories where shared libraries might be found. 84.Ev LD_LIBRARY_PATH 85is a 86.Sq \: 87separated list of directory paths that are searched by 88.Nm ld.so 89when it needs to load a shared library. It can be viewed as the run-time 90equivalent of the 91.Fl L 92switch of 93.Nm ld . 94.Pp 95.Nm 96is typically run as part of the boot sequence. 97.Pp 98The following options are recognized by 99.Nm ldconfig : 100.Bl -tag -width indent 101.It Fl c 102Do not scan directories listed in 103.Pa /etc/ld.so.conf 104for shared libraries. 105.It Fl m 106Merge the result of the scan of the directories given as arguments into 107the existing hints file. The default action is to build the hints file afresh. 108.It Fl r 109Lists the current contents of 110.Pa ld.so.hints 111on the standard output. The hints file will not be modified. 112.It Fl s 113Do not scan the built-in system directory 114.Pq Pa /usr/lib , 115nor any directories listed in 116.Pa /etc/ld.so.conf 117for shared libraries. 118.It Fl S 119Do not scan the built-in system directory 120.Pq Pa /usr/lib , 121for shared libraries. (Directories listed in 122.Pa /etc/ld.so.conf 123are still scanned.) 124.It Fl v 125Switch on verbose mode. 126.El 127.Sh SECURITY 128Special care must be taken when loading shared libraries into the address 129space of 130.Em set-user-ID 131programs. Whenever such a program is run, 132.Nm ld.so 133will only load shared libraries from the 134.Pa ld.so.hints 135file. In particular, the 136.Ev LD_LIBRARY_PATH 137and 138.Ev LD_PRELOAD 139is not used to search for libraries. Thus, the role of ldconfig is dual. In 140addition to building a set of hints for quick lookup, it also serves to 141specify the trusted collection of directories from which shared objects can 142be safely loaded. It is presumed that the set of directories specified to 143.Nm 144is under control of the system's administrator. 145.Nm ld.so 146further assists set-user-ID programs by erasing the 147.Ev LD_LIBRARY_PATH 148and 149.Ev LD_PRELOAD 150from the environment. 151.Sh FILES 152.Pa /var/run/ld.so.hints , 153.Pa /etc/ld.so.conf 154.Sh SEE ALSO 155.Xr ld 1 , 156.Xr ld.so 1 , 157.Xr ld.so.conf 5 , 158.Xr link 5 159.Sh HISTORY 160A 161.Nm 162utility first appeared in SunOS 4.0, it appeared in its current form 163in 164.Nx 0.9a . 165