xref: /freebsd/sbin/ldconfig/ldconfig.8 (revision 2ed3236082a4473c1da8f72c1ebc071a7b54321f)
1.\"
2.\" Copyright (c) 1993 Paul Kranenburg
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\" 3. All advertising materials mentioning features or use of this software
14.\"    must display the following acknowledgement:
15.\"      This product includes software developed by Paul Kranenburg.
16.\" 3. The name of the author may not be used to endorse or promote products
17.\"    derived from this software without specific prior written permission
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29.\"
30.\" $FreeBSD$
31.\"
32.Dd March 17, 2020
33.Dt LDCONFIG 8
34.Os
35.Sh NAME
36.Nm ldconfig
37.Nd configure the shared library cache
38.Sh SYNOPSIS
39.Nm
40.Op Fl 32
41.Op Fl aout | Fl elf
42.Op Fl Rimrsv
43.Op Fl f Ar hints_file
44.Op Ar directory | Ar
45.Sh DESCRIPTION
46The
47.Nm
48utility is used to prepare a set of
49.Dq hints
50for use by the dynamic linker
51to facilitate quick lookup of shared libraries available in multiple
52directories.
53It scans a set of built-in system directories and any
54.Ar directories
55specified on the command line (in the given order) looking for
56shared libraries and stores the results in a system file to forestall
57the overhead that would otherwise result from the directory search
58operations the dynamic linker would have to perform to load the
59required shared libraries.
60.Pp
61Alternatively,
62.Ar files
63may be specified; these are expected to contain directories
64to scan for shared libraries.
65Each directory's pathname must start on a new
66line.
67Blank lines and lines starting with the comment character
68.Ql \&#
69are ignored.
70Filenames must conform to the
71.Pa lib*.so.[0-9]
72pattern in order to be added to the hints file.
73.Pp
74For security reasons, directories which are world or group-writable or which
75are not owned by root produce warning messages and are skipped, unless
76the
77.Fl i
78option is present.
79.Pp
80The shared libraries which are found will be automatically available for loading
81if needed by the program being prepared for execution.
82This obviates the need
83for storing search paths within the executable.
84.Pp
85The
86.Ev LD_LIBRARY_PATH
87environment variable can be used to override the use of
88directories (or the order thereof) from the cache or to specify additional
89directories where shared libraries might be found.
90.Ev LD_LIBRARY_PATH
91is a
92.Sq \&:
93separated list of directory paths which are searched by
94the dynamic linker
95when it needs to load a shared library.
96It can be viewed as the run-time
97equivalent of the
98.Fl L
99switch of
100.Xr ld 1 .
101.Pp
102The
103.Nm
104utility is typically run as part of the boot sequence.
105.Pp
106The following options are recognized by
107.Nm :
108.Bl -tag -width indent
109.It Fl 32
110Generate the hints for 32-bit ABI shared libraries
111on 64-bit systems that support running 32-bit binaries.
112.It Fl aout
113Generate the hints for a.out format shared libraries.
114This option is deprecated and is not present in
115.Fx 13 .
116.It Fl elf
117Generate the hints for ELF format shared libraries.
118.It Fl R
119Rescan the previously configured directories.
120This opens the previous hints
121file and fetches the directory list from the header.
122Any additional pathnames
123on the command line are also processed.
124This is the default action when no parameters are given.
125.It Fl f Ar hints_file
126Read and/or update the specified hints file, instead of the standard file.
127This option is provided primarily for testing.
128.It Fl i
129Run in insecure mode.
130The security checks will not be performed.
131.It Fl m
132Instead of replacing the contents of the hints file
133with those found in the directories specified,
134.Dq merge
135in new entries.
136Directories recorded in the hints file by previous runs of
137.Nm
138are also rescanned for new shared libraries.
139.It Fl r
140List the current contents of the hints file
141on the standard output.
142The hints file is not modified.
143The list of
144directories stored in the hints file is included.
145.It Fl s
146Do not scan the built-in system directory
147.Pq Dq /usr/lib
148for shared libraries.
149.It Fl v
150Switch on verbose mode.
151.El
152.Sh SECURITY
153Special care must be taken when loading shared libraries into the address
154space of
155.Ev set-user-Id
156programs.
157Whenever such a program is run by any user except the owner of the program,
158the dynamic linker
159will only load shared libraries from the hints
160file.
161In particular, the
162.Ev LD_LIBRARY_PATH
163is not used to search for libraries.
164Thus, the role of
165.Nm
166is dual.
167In addition to building a set of hints for quick lookup, it also serves to
168specify the trusted collection of directories from which shared objects can
169be safely loaded.
170.Sh FILES
171.Bl -tag -width /var/run/ld-elf.so.hintsxxx -compact
172.It Pa /var/run/ld.so.hints
173Standard hints file for the a.out dynamic linker.
174.It Pa /var/run/ld-elf.so.hints
175Standard hints file for the ELF dynamic linker.
176.It Pa /etc/ld.so.conf
177Conventional configuration file containing directory names for
178invocations with
179.Fl aout .
180.It Pa /etc/ld-elf.so.conf
181Conventional configuration file containing directory names for
182invocations with
183.Fl elf .
184.It Pa /var/run/ld-elf32.so.hints
185.It Pa /var/run/ld32.so.hints
186Conventional configuration files containing directory names for
187invocations with
188.Fl 32 .
189.El
190.Sh SEE ALSO
191.Xr ld 1 ,
192.Xr link 5
193.Sh HISTORY
194A
195.Nm
196utility first appeared in SunOS 4.0, it appeared in its current form
197in
198.Fx 1.1 .
199.Sh BUGS
200Some security checks (for example, verifying root ownership of
201added directories) are not performed when
202.Fl aout
203is specified.
204