xref: /freebsd/libexec/rc/rc.d/ldconfig (revision 73902ed85ab73d455d4be8c77336c88a07512230)
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
170696600cSBjoern A. Zeebldconfig_start()
180696600cSBjoern A. Zeeb{
190696600cSBjoern A. Zeeb	local _files _ins
200696600cSBjoern A. Zeeb
210696600cSBjoern A. Zeeb	_ins=
220696600cSBjoern A. Zeeb	ldconfig=${ldconfig_command}
230696600cSBjoern A. Zeeb	checkyesno ldconfig_insecure && _ins="-i"
240696600cSBjoern A. Zeeb	if [ -x "${ldconfig_command}" ]; then
2599132dafSJohn W. O'Brien		_LDC=$(/libexec/ld-elf.so.1 -v | sed -n -e '/^Default lib path /s///p' | tr : ' ')
260696600cSBjoern A. Zeeb		for i in ${ldconfig_local_dirs}; do
270696600cSBjoern A. Zeeb			if [ -d "${i}" ]; then
280696600cSBjoern A. Zeeb				_files=`find ${i} -type f`
290696600cSBjoern A. Zeeb				if [ -n "${_files}" ]; then
300696600cSBjoern A. Zeeb					ldconfig_paths="${ldconfig_paths} `cat ${_files} | sort -u`"
310696600cSBjoern A. Zeeb				fi
320696600cSBjoern A. Zeeb			fi
330696600cSBjoern A. Zeeb		done
340696600cSBjoern A. Zeeb		for i in ${ldconfig_paths} /etc/ld-elf.so.conf; do
350696600cSBjoern A. Zeeb			if [ -r "${i}" ]; then
360696600cSBjoern A. Zeeb				_LDC="${_LDC} ${i}"
370696600cSBjoern A. Zeeb			fi
380696600cSBjoern A. Zeeb		done
39325ebf37SJose Luis Duran		startmsg 'ELF ldconfig path:' ${_LDC}
400696600cSBjoern A. Zeeb		${ldconfig} -elf ${_ins} ${_LDC}
410696600cSBjoern A. Zeeb
42*73902ed8SKonstantin Belousov		if check_kern_features compat_freebsd32; then
430696600cSBjoern A. Zeeb			for i in ${ldconfig_local32_dirs}; do
440696600cSBjoern A. Zeeb				if [ -d "${i}" ]; then
450696600cSBjoern A. Zeeb					_files=`find ${i} -type f`
460696600cSBjoern A. Zeeb					if [ -n "${_files}" ]; then
470696600cSBjoern A. Zeeb						ldconfig32_paths="${ldconfig32_paths} `cat ${_files} | sort -u`"
480696600cSBjoern A. Zeeb					fi
490696600cSBjoern A. Zeeb				fi
500696600cSBjoern A. Zeeb			done
510696600cSBjoern A. Zeeb			_LDC=""
5299132dafSJohn W. O'Brien			if [ -x /libexec/ld-elf32.so.1 ]; then
53806e4e32SKonstantin Belousov				for x in $(/libexec/ld-elf32.so.1 -v | sed -n -e '/^Default lib path /s///p' | tr : ' '); do
54806e4e32SKonstantin Belousov					if [ -d "${x}" ]; then
55806e4e32SKonstantin Belousov						_LDC="${_LDC} ${x}"
56806e4e32SKonstantin Belousov					fi
57806e4e32SKonstantin Belousov				done
5899132dafSJohn W. O'Brien			fi
590696600cSBjoern A. Zeeb			for i in ${ldconfig32_paths}; do
600696600cSBjoern A. Zeeb				if [ -r "${i}" ]; then
610696600cSBjoern A. Zeeb					_LDC="${_LDC} ${i}"
620696600cSBjoern A. Zeeb				fi
630696600cSBjoern A. Zeeb			done
64325ebf37SJose Luis Duran			startmsg '32-bit compatibility ldconfig path:' ${_LDC}
650696600cSBjoern A. Zeeb			${ldconfig} -32 ${_ins} ${_LDC}
660696600cSBjoern A. Zeeb			;;
67*73902ed8SKonstantin Belousov		fi
680696600cSBjoern A. Zeeb
690696600cSBjoern A. Zeeb	fi
700696600cSBjoern A. Zeeb}
710696600cSBjoern A. Zeeb
720696600cSBjoern A. Zeebload_rc_config $name
730696600cSBjoern A. Zeebrun_rc_command "$1"
74