Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sbin / ldconfig / ldconfig.8
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: src/sbin/ldconfig/ldconfig.8,v 1.19.2.10 2003/05/13 19:25:19 trhodes Exp $
31 .\"
32 .Dd October 3, 1993
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 aout | Fl elf
41 .Op Fl Rimrsv
42 .Op Fl f Ar hints_file
43 .Op Ar directory | Ar
44 .Sh DESCRIPTION
45 The
46 .Nm
47 utility is used to prepare a set of
48 .Dq hints
49 for use by the dynamic linker
50 to facilitate quick lookup of shared libraries available in multiple
51 directories.  It scans a set of built-in system directories and any
52 .Ar directories
53 specified on the command line (in the given order) looking for
54 shared libraries and stores the results in a system file to forestall
55 the overhead that would otherwise result from the directory search
56 operations the dynamic linker would have to perform to load the
57 required shared libraries.
58 .Pp
59 Files named on the command line are expected to contain directories
60 to scan for shared libraries.  Each directory's pathname must start on a new
61 line.  Blank lines and lines starting with the comment character
62 .Ql \&#
63 are ignored.
64 Filenames must conform to the
65 .Pa lib*.so.[0-9]
66 pattern in order to be added to the hints file.
67 .Pp
68 For security reasons, directories which are world or group-writable or which
69 are not owned by root produce warning messages and are skipped, unless
70 the
71 .Fl i
72 option is present.
73 .Pp
74 The shared libraries which are found will be automatically available for loading
75 if needed by the program being prepared for execution.
76 This obviates the need
77 for storing search paths within the executable.
78 .Pp
79 The
80 .Ev LD_LIBRARY_PATH
81 environment variable can be used to override the use of
82 directories (or the order thereof) from the cache or to specify additional
83 directories where shared libraries might be found.
84 .Ev LD_LIBRARY_PATH
85 is a
86 .Sq \&:
87 separated list of directory paths which are searched by
88 the dynamic linker
89 when it needs to load a shared library.
90 It can be viewed as the run-time
91 equivalent of the
92 .Fl L
93 switch of
94 .Xr ld 1 .
95 .Pp
96 The
97 .Nm
98 utility is typically run as part of the boot sequence.
99 .Pp
100 The following options are recognized by
101 .Nm :
102 .Bl -tag -width indent
103 .It Fl aout
104 Generate the hints for a.out format shared libraries.
105 .It Fl elf
106 Generate the hints for ELF format shared libraries.
107 .It Fl R
108 Rescan the previously configured directories.  This opens the previous hints
109 file and fetches the directory list from the header.  Any additional pathnames
110 on the command line are also processed.
111 This is the default action when no parameters are given.
112 .It Fl f Ar hints_file
113 Read and/or update the specified hints file, instead of the standard file.
114 This option is provided primarily for testing.
115 .It Fl i
116 Run in insecure mode. The security checks will not be performed.
117 .It Fl m
118 Instead of replacing the contents of the hints file
119 with those found in the directories specified,
120 .Dq merge
121 in new entries.
122 Directories recorded in the hints file by previous runs of
123 .Nm
124 are also rescanned for new shared libraries.
125 .It Fl r
126 List the current contents of the hints file
127 on the standard output.
128 The hints file is not modified.  The list of
129 directories stored in the hints file is included.
130 .It Fl s
131 Do not scan the built-in system directory
132 .Pq Dq /usr/lib
133 for shared libraries.
134 .It Fl v
135 Switch on verbose mode.
136 .El
137 .Sh SECURITY
138 Special care must be taken when loading shared libraries into the address
139 space of
140 .Ev set-user-Id
141 programs.
142 Whenever such a program is run by any user except the owner of the program,
143 the dynamic linker
144 will only load shared libraries from the hints
145 file.
146 In particular, the
147 .Ev LD_LIBRARY_PATH
148 is not used to search for libraries.
149 Thus, the role of ldconfig is dual.
150 In
151 addition to building a set of hints for quick lookup, it also serves to
152 specify the trusted collection of directories from which shared objects can
153 be safely loaded.
154 .Sh ENVIRONMENT
155 .Bl -tag -width OBJFORMATxxx -compact
156 .It Ev OBJFORMAT
157 Overrides
158 .Pa /etc/objformat
159 (see below) to determine whether
160 .Fl aout
161 or
162 .Fl elf
163 is the default.  If set, its value should be either
164 .Ql aout
165 or
166 .Ql elf .
167 .El
168 .Sh FILES
169 .Bl -tag -width /var/run/ld-elf.so.hintsxxx -compact
170 .It Pa /var/run/ld.so.hints
171 Standard hints file for the a.out dynamic linker.
172 .It Pa /var/run/ld-elf.so.hints
173 Standard hints file for the ELF dynamic linker.
174 .It Pa /etc/ld.so.conf
175 Conventional configuration file containing directory names for
176 invocations with
177 .Fl aout .
178 .It Pa /etc/ld-elf.so.conf
179 Conventional configuration file containing directory names for
180 invocations with
181 .Fl elf .
182 .It Pa /etc/objformat
183 Determines whether
184 .Fl aout
185 or
186 .Fl elf
187 is the default.  If present, it must consist of a single line
188 containing either
189 .Ql OBJFORMAT=aout
190 or
191 .Ql OBJFORMAT=elf .
192 .El
193 .Sh SEE ALSO
194 .Xr ld 1 ,
195 .Xr link 5
196 .Sh HISTORY
197 A
198 .Nm
199 utility first appeared in SunOS 4.0, it appeared in its current form
200 in
201 .Fx 1.1 .
202 .Sh BUGS
203 Some security checks (for example, verifying root ownership of
204 added directories) are not performed when
205 .Fl aout
206 is specified.