1#!/bin/sh 2# 3# 4 5# PROVIDE: ldconfig 6# REQUIRE: FILESYSTEMS 7# BEFORE: DAEMON 8 9. /etc/rc.subr 10 11name="ldconfig" 12desc="Configure the shared library cache" 13ldconfig_command="/sbin/ldconfig" 14start_cmd="ldconfig_start" 15stop_cmd=":" 16 17ldconfig_start() 18{ 19 local _files _ins 20 21 _ins= 22 ldconfig=${ldconfig_command} 23 checkyesno ldconfig_insecure && _ins="-i" 24 if [ -x "${ldconfig_command}" ]; then 25 _LDC=$(/libexec/ld-elf.so.1 -v | sed -n -e '/^Default lib path /s///p' | tr : ' ') 26 for i in ${ldconfig_local_dirs}; do 27 if [ -d "${i}" ]; then 28 _files=`find ${i} -type f` 29 if [ -n "${_files}" ]; then 30 ldconfig_paths="${ldconfig_paths} `cat ${_files} | sort -u`" 31 fi 32 fi 33 done 34 for i in ${ldconfig_paths} /etc/ld-elf.so.conf; do 35 if [ -r "${i}" ]; then 36 _LDC="${_LDC} ${i}" 37 fi 38 done 39 startmsg 'ELF ldconfig path:' ${_LDC} 40 ${ldconfig} -elf ${_ins} ${_LDC} 41 42 machine_arch=$(sysctl -n hw.machine_arch) 43 44 case ${machine_arch} in 45 aarch64|amd64|powerpc64) 46 for i in ${ldconfig_local32_dirs}; do 47 if [ -d "${i}" ]; then 48 _files=`find ${i} -type f` 49 if [ -n "${_files}" ]; then 50 ldconfig32_paths="${ldconfig32_paths} `cat ${_files} | sort -u`" 51 fi 52 fi 53 done 54 _LDC="" 55 if [ -x /libexec/ld-elf32.so.1 ]; then 56 for x in $(/libexec/ld-elf32.so.1 -v | sed -n -e '/^Default lib path /s///p' | tr : ' '); do 57 if [ -d "${x}" ]; then 58 _LDC="${_LDC} ${x}" 59 fi 60 done 61 fi 62 for i in ${ldconfig32_paths}; do 63 if [ -r "${i}" ]; then 64 _LDC="${_LDC} ${i}" 65 fi 66 done 67 startmsg '32-bit compatibility ldconfig path:' ${_LDC} 68 ${ldconfig} -32 ${_ins} ${_LDC} 69 ;; 70 esac 71 72 fi 73} 74 75load_rc_config $name 76run_rc_command "$1" 77