xref: /freebsd/libexec/rc/rc.d/ldconfig (revision 99132daf6f70cb0cc969c555d3612547fa3cf1db)
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
25*99132dafSJohn 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
429da3dfffSMateusz Guzik		machine_arch=$(sysctl -n hw.machine_arch)
439da3dfffSMateusz Guzik
449da3dfffSMateusz Guzik		case ${machine_arch} in
456f15b7e1SMike Karels		aarch64|amd64|powerpc64)
460696600cSBjoern A. Zeeb			for i in ${ldconfig_local32_dirs}; do
470696600cSBjoern A. Zeeb				if [ -d "${i}" ]; then
480696600cSBjoern A. Zeeb					_files=`find ${i} -type f`
490696600cSBjoern A. Zeeb					if [ -n "${_files}" ]; then
500696600cSBjoern A. Zeeb						ldconfig32_paths="${ldconfig32_paths} `cat ${_files} | sort -u`"
510696600cSBjoern A. Zeeb					fi
520696600cSBjoern A. Zeeb				fi
530696600cSBjoern A. Zeeb			done
540696600cSBjoern A. Zeeb			_LDC=""
55*99132dafSJohn W. O'Brien			if [ -x /libexec/ld-elf32.so.1 ]; then
56*99132dafSJohn W. O'Brien				_LDC=$(/libexec/ld-elf32.so.1 -v | sed -n -e '/^Default lib path /s///p' | tr : ' ')
57*99132dafSJohn W. O'Brien			fi
580696600cSBjoern A. Zeeb			for i in ${ldconfig32_paths}; do
590696600cSBjoern A. Zeeb				if [ -r "${i}" ]; then
600696600cSBjoern A. Zeeb					_LDC="${_LDC} ${i}"
610696600cSBjoern A. Zeeb				fi
620696600cSBjoern A. Zeeb			done
63325ebf37SJose Luis Duran			startmsg '32-bit compatibility ldconfig path:' ${_LDC}
640696600cSBjoern A. Zeeb			${ldconfig} -32 ${_ins} ${_LDC}
650696600cSBjoern A. Zeeb			;;
660696600cSBjoern A. Zeeb		esac
670696600cSBjoern A. Zeeb
680696600cSBjoern A. Zeeb	fi
690696600cSBjoern A. Zeeb}
700696600cSBjoern A. Zeeb
710696600cSBjoern A. Zeebload_rc_config $name
720696600cSBjoern A. Zeebrun_rc_command "$1"
73