xref: /freebsd/sbin/ldconfig/ldconfig.8 (revision dd41de95a84d979615a2ef11df6850622bf6184e)
1.\"
2.\" Copyright (c) 1993 Paul Kranenburg
3.\" All rights reserved.
4.\" Copyright (c) 2021 The FreeBSD Foundation, Inc.
5.\"
6.\" Portions of this documentation were written by
7.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
8.\" from the FreeBSD Foundation.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\"    notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\"    notice, this list of conditions and the following disclaimer in the
17.\"    documentation and/or other materials provided with the distribution.
18.\" 3. All advertising materials mentioning features or use of this software
19.\"    must display the following acknowledgement:
20.\"      This product includes software developed by Paul Kranenburg.
21.\" 3. The name of the author may not be used to endorse or promote products
22.\"    derived from this software without specific prior written permission
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34.\"
35.\" $FreeBSD$
36.\"
37.Dd May 15, 2021
38.Dt LDCONFIG 8
39.Os
40.Sh NAME
41.Nm ldconfig
42.Nd configure the dynamic linker search path for shared libraries
43.Sh SYNOPSIS
44.Nm
45.Op Fl 32
46.Op Fl Rimrsv
47.Op Fl f Ar hints_file
48.Op Ar directory | Ar
49.Sh DESCRIPTION
50.Nm
51utility is used to configure the set of paths used by the dynamic linker
52.Xr ld-elf.so.1 1
53when searching for shared libraries.
54The dynamic linker looks for libraries in a set of built-in system directories
55and any directories specified in the hints file.
56This obviates the need for storing search paths within the executable,
57see the
58.Fl rpath
59option for the static linker
60.Xr ld 1 .
61.Pp
62The hints file is maintained by
63.Nm .
64The
65.Ar directories
66list to be stored in the hints file is supplied on the command line.
67.Pp
68Alternatively to the
69.Ar directories
70list on the command line,
71.Ar files
72may be specified; these are expected to contain directories
73to scan for shared libraries.
74Each directory's pathname must start on a new
75line.
76Blank lines and lines starting with the comment character
77.Ql \&#
78are ignored.
79.Pp
80For security reasons, directories which are world or group-writable or which
81are not owned by root produce warning messages and are skipped, unless
82the
83.Fl i
84option is present.
85.Pp
86The
87.Ev LD_LIBRARY_PATH
88environment variable can be used to specify additional
89shared library search directories.
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 following options are recognized by
103.Nm :
104.Bl -tag -width indent
105.It Fl 32
106Generate the hints for 32-bit ABI shared libraries
107on 64-bit systems that support running 32-bit binaries.
108.It Fl elf
109Ignored for backwards compatibility.
110.It Fl R
111Appends pathnames on the command line to the directory list from
112the hints file.
113.Pp
114This is the default action when no options are given.
115.It Fl f Ar hints_file
116Read and/or update the specified hints file, instead of the standard file.
117This option is provided primarily for testing.
118.It Fl i
119Run in insecure mode.
120The security checks will not be performed.
121.It Fl m
122Instead of replacing the list of the directories to search with the
123directories specified on the command line, merge existing list
124with the specified directories, and write the result to the hints file.
125.It Fl r
126List the current list of the directories from the hints file
127on the standard output.
128The hints file is not modified.
129.Pp
130Scan and print all libraries found on the directories list.
131.It Fl s
132Do not scan the built-in system directory
133.Pq Dq /usr/lib
134for shared libraries.
135.It Fl v
136Switch on verbose mode.
137.El
138.Sh SECURITY
139Special care must be taken when loading shared libraries into the address
140space of
141.Ev set-user-Id
142programs.
143Whenever such a program is run by any user except the owner of the program,
144the dynamic linker will only load shared libraries from paths found in
145the hints file.
146In particular, the
147.Ev LD_LIBRARY_PATH
148is not used to search for libraries.
149Thus,
150.Nm
151serves to specify the trusted collection of directories from which
152shared objects can be safely loaded.
153.Sh FILES
154.Bl -tag -width /var/run/ld-elf.so.hintsxxx -compact
155.It Pa /var/run/ld-elf.so.hints
156Standard hints file for the ELF dynamic linker.
157.It Pa /etc/ld-elf.so.conf
158Conventional configuration file containing directory names for
159invocations with
160.Fl elf .
161.It Pa /var/run/ld-elf32.so.hints
162Conventional configuration files containing directory names for
163invocations with
164.Fl 32 .
165.El
166.Sh SEE ALSO
167.Xr ld 1 ,
168.Xr ld-elf.so.1 ,
169.Xr link 5
170.Sh HISTORY
171A
172.Nm
173utility first appeared in SunOS 4.0, it appeared in its current form
174in
175.Fx 1.1 .
176.Pp
177The name 'hints file' is historic from the times when the file also contained
178hints to the dynamic linker.
179This functionality is not provided for ELF.
180