xref: /freebsd/libexec/rc/rc.d/ldconfig (revision f99f0ee14e3af81c23150a6a340259ca8a33d01a)
10696600cSBjoern A. Zeeb#!/bin/sh
20696600cSBjoern A. Zeeb#
30696600cSBjoern A. Zeeb#
40696600cSBjoern A. Zeeb
50696600cSBjoern A. Zeeb# PROVIDE: ldconfig
60696600cSBjoern A. Zeeb# REQUIRE: FILESYSTEMS
70696600cSBjoern A. Zeeb# BEFORE:  DAEMON
80696600cSBjoern A. Zeeb
90696600cSBjoern A. Zeeb. /etc/rc.subr
100696600cSBjoern A. Zeeb
110696600cSBjoern A. Zeebname="ldconfig"
120696600cSBjoern A. Zeebdesc="Configure the shared library cache"
130696600cSBjoern A. Zeebldconfig_command="/sbin/ldconfig"
140696600cSBjoern A. Zeebstart_cmd="ldconfig_start"
150696600cSBjoern A. Zeebstop_cmd=":"
160696600cSBjoern A. Zeeb
17e6e38bc5SKonrad Witaszczykldconfig_paths()
18e6e38bc5SKonrad Witaszczyk{
19e6e38bc5SKonrad Witaszczyk	local _dirs _files _ii _ldpaths _paths
20e6e38bc5SKonrad Witaszczyk
21e6e38bc5SKonrad Witaszczyk	_dirs="${1}"
22e6e38bc5SKonrad Witaszczyk	_paths="${2}"
23e6e38bc5SKonrad Witaszczyk	_ldpaths="${3}"
24e6e38bc5SKonrad Witaszczyk
25e6e38bc5SKonrad Witaszczyk	for _ii in ${_dirs}; do
26e6e38bc5SKonrad Witaszczyk		if [ -d "${_ii}" ]; then
27e6e38bc5SKonrad Witaszczyk			_files=`find ${_ii} -type f`
28e6e38bc5SKonrad Witaszczyk			if [ -n "${_files}" ]; then
29e6e38bc5SKonrad Witaszczyk				_paths="${_paths} `cat ${_files} | sort -u`"
30e6e38bc5SKonrad Witaszczyk			fi
31e6e38bc5SKonrad Witaszczyk		fi
32e6e38bc5SKonrad Witaszczyk	done
33e6e38bc5SKonrad Witaszczyk	for _ii in ${_paths}; do
34e6e38bc5SKonrad Witaszczyk		if [ -r "${_ii}" ]; then
35e6e38bc5SKonrad Witaszczyk			_ldpaths="${_ldpaths} ${_ii}"
36e6e38bc5SKonrad Witaszczyk		fi
37e6e38bc5SKonrad Witaszczyk	done
38e6e38bc5SKonrad Witaszczyk
39e6e38bc5SKonrad Witaszczyk	echo "${_ldpaths}"
40e6e38bc5SKonrad Witaszczyk}
41e6e38bc5SKonrad Witaszczyk
420696600cSBjoern A. Zeebldconfig_start()
430696600cSBjoern A. Zeeb{
440696600cSBjoern A. Zeeb	local _files _ins
450696600cSBjoern A. Zeeb
460696600cSBjoern A. Zeeb	_ins=
470696600cSBjoern A. Zeeb	ldconfig=${ldconfig_command}
480696600cSBjoern A. Zeeb	checkyesno ldconfig_insecure && _ins="-i"
490696600cSBjoern A. Zeeb	if [ -x "${ldconfig_command}" ]; then
5099132dafSJohn W. O'Brien		_LDC=$(/libexec/ld-elf.so.1 -v | sed -n -e '/^Default lib path /s///p' | tr : ' ')
51e6e38bc5SKonrad Witaszczyk		_LDC=$(ldconfig_paths "${ldconfig_local_dirs}" \
52e6e38bc5SKonrad Witaszczyk		    "${ldconfig_paths} /etc/ld-elf.so.conf" "$_LDC")
53325ebf37SJose Luis Duran		startmsg 'ELF ldconfig path:' ${_LDC}
540696600cSBjoern A. Zeeb		${ldconfig} -elf ${_ins} ${_LDC}
550696600cSBjoern A. Zeeb
5673902ed8SKonstantin Belousov		if check_kern_features compat_freebsd32; then
570696600cSBjoern A. Zeeb			_LDC=""
5899132dafSJohn W. O'Brien			if [ -x /libexec/ld-elf32.so.1 ]; then
59806e4e32SKonstantin Belousov				for x in $(/libexec/ld-elf32.so.1 -v | sed -n -e '/^Default lib path /s///p' | tr : ' '); do
60806e4e32SKonstantin Belousov					if [ -d "${x}" ]; then
61806e4e32SKonstantin Belousov						_LDC="${_LDC} ${x}"
62806e4e32SKonstantin Belousov					fi
63806e4e32SKonstantin Belousov				done
6499132dafSJohn W. O'Brien			fi
65e6e38bc5SKonrad Witaszczyk			_LDC=$(ldconfig_paths "${ldconfig_local32_dirs}" \
66e6e38bc5SKonrad Witaszczyk			    "${ldconfig32_paths}" "$_LDC")
67325ebf37SJose Luis Duran			startmsg '32-bit compatibility ldconfig path:' ${_LDC}
680696600cSBjoern A. Zeeb			${ldconfig} -32 ${_ins} ${_LDC}
6973902ed8SKonstantin Belousov		fi
700696600cSBjoern A. Zeeb
710696600cSBjoern A. Zeeb	fi
720696600cSBjoern A. Zeeb}
730696600cSBjoern A. Zeeb
740696600cSBjoern A. Zeebload_rc_config $name
75*f99f0ee1SAlexander Leidinger
76*f99f0ee1SAlexander Leidinger# doesn't make sense to run in a svcj: config setting
77*f99f0ee1SAlexander Leidingerldconfig_svcj="NO"
78*f99f0ee1SAlexander Leidinger
790696600cSBjoern A. Zeebrun_rc_command "$1"
80