aboutsummaryrefslogtreecommitdiff
path: root/contrib/scripts/gnunet-suidfix
blob: bcd9eb899a7a008d069ad1bbc0b87198ad6d0d81 (plain) (blame)
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
#!/bin/sh
#
# "suidfix" - fix permissions and sticky bits for the binaries
# installed by GNUnet.
# Takes GNUNET_PREFIX from the environment.
#
# Taken from dangole's LEDE/OpenWRT config.. thx!

suid_root_helpers="exit nat-server nat-client transport-bluetooth transport-wlan vpn"
libexec="${GNUNET_PREFIX}/lib/gnunet/libexec"

chmodown_execbin() {
        if [ -x $1 ]; then
                if [ "$3" ]; then
                        chown $3 $1 2>/dev/null && chmod $2 $1
                else
                        chmod $2 $1
                fi
		ls -l $1
	else
		echo "Missing: $1"
        fi
}

for helper in $suid_root_helpers; do
	chmodown_execbin ${libexec}/gnunet-helper-$helper u+s
done
chmodown_execbin ${libexec}/gnunet-helper-dns 4750 root:gnunetdns
chmodown_execbin ${libexec}/gnunet-service-dns 2750 gnunet:gnunetdns