summaryrefslogtreecommitdiffstats
path: root/etc/rc.d/ldconfig
blob: 2dbb5b41f063f2e32d083a5782ee170cb153a03f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE: ldconfig
# REQUIRE: mountcritremote FILESYSTEMS
# BEFORE:  DAEMON

. /etc/rc.subr

name="ldconfig"
ldconfig_command="/sbin/ldconfig"
start_cmd="ldconfig_start"
stop_cmd=":"

ldconfig_start()
{
	local _files _ins

	_ins=
	ldconfig=${ldconfig_command}
	checkyesno ldconfig_insecure && _ins="-i"
	if [ -x "${ldconfig_command}" ]; then
		_LDC="/lib /usr/lib"
		for i in ${ldconfig_local_dirs}; do
			if [ -d "${i}" ]; then
				_files=`find ${i} -type f`
				if [ -n "${_files}" ]; then
					ldconfig_paths="${ldconfig_paths} `cat ${_files} | sort -u`"
				fi
			fi
		done
		for i in ${ldconfig_paths} /etc/ld-elf.so.conf; do
			if [ -r "${i}" ]; then
				_LDC="${_LDC} ${i}"
			fi
		done
		check_startmsgs && echo 'ELF ldconfig path:' ${_LDC}
		${ldconfig} -elf ${_ins} ${_LDC}

		case `sysctl -n hw.machine_arch` in
		amd64)
			for i in ${ldconfig_local32_dirs}; do
				if [ -d "${i}" ]; then
					_files=`find ${i} -type f`
					if [ -n "${_files}" ]; then
						ldconfig32_paths="${ldconfig32_paths} `cat ${_files} | sort -u`"
					fi
				fi
			done
			_LDC=""
			for i in ${ldconfig32_paths}; do
				if [ -r "${i}" ]; then
					_LDC="${_LDC} ${i}"
				fi
			done
			check_startmsgs &&
			    echo '32-bit compatibility ldconfig path:' ${_LDC}
			${ldconfig} -32 -m ${_ins} ${_LDC}
			;;
		esac

		# Legacy aout support for i386 only
		case `sysctl -n hw.machine_arch` in
		i386)
			# Default the a.out ldconfig path.
			: ${ldconfig_paths_aout=${ldconfig_paths}}
			_LDC=""
			for i in /usr/lib/aout ${ldconfig_paths_aout} /etc/ld.so.conf; do
				if [ -r "${i}" ]; then
					_LDC="${_LDC} ${i}"
				fi
			done
			check_startmsgs && echo 'a.out ldconfig path:' ${_LDC}
			${ldconfig} -aout ${_ins} ${_LDC}
			;;
		esac
	fi
}

load_rc_config $name
run_rc_command "$1"
OpenPOWER on IntegriCloud