summaryrefslogtreecommitdiff
path: root/build-aux/setcap-setuid.sh
blob: 01f167d03c78ef659433ca3b790f93e1e1cf9502 (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
#!/bin/sh
#
# Meson install script to setcap or setuid to an executable.

exec_path="$1/$2"
perm_type="$3"
setcap="$4"

if [ -n "${DESTDIR}" ]; then
	exec_path="${DESTDIR%/}/${exec_path}"
fi

case "$perm_type" in
	'none')
		# Gentoo needs build system to back off.
		# https://github.com/iputils/iputils/issues/175
		;;
	'caps')
		echo "$0: calling: $setcap cap_net_raw+p $exec_path"
		"$setcap" 'cap_net_raw+ep' "$exec_path" || true
	;;
	'setuid')
		echo "$0: changing $exec_path to be setuid root executable"
		chown root "$exec_path" || true
		chmod u+s "$exec_path" || true
	;;
	*)
		echo "$0: unexpected argument: $perm_type"
		exit 1
	;;
esac

exit 0