File: try-all

package info (click to toggle)
android-platform-external-libselinux 10.0.0%2Br36-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 34,176 kB
  • sloc: ansic: 147,112; python: 25,790; makefile: 1,930; yacc: 1,389; sh: 1,206; lex: 452; xml: 180
file content (64 lines) | stat: -rw-r--r-- 1,761 bytes parent folder | download | duplicates (11)
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
#!/bin/bash

shopt -s nullglob

fail() {
  echo $1
  exit 1
}

[ `id -u` = 0 ] || fail "must run as root"

for d in /usr/share/mcstrans/examples/*; do
	echo $d

	rm -rf /etc/selinux/mls/setrans.conf.bak /etc/selinux/mls/secolor.conf.bak /etc/selinux/mls/setrans.d.bak
	[ $? -eq 0 ] || fail "preclean failed"

	if [ -e $d/setrans.conf ]; then
		mv /etc/selinux/mls/setrans.conf /etc/selinux/mls/setrans.conf.bak
		[ $? -eq 0 ] || fail "setrans.conf backup failed"
	fi

	if [ -e /etc/selinux/mls/secolor.conf ]; then
		mv /etc/selinux/mls/secolor.conf /etc/selinux/mls/secolor.conf.bak
		[ $? -eq 0 ] || fail "secolor.conf backup failed"
	fi

	mv /etc/selinux/mls/setrans.d /etc/selinux/mls/setrans.d.bak
	[ $? -eq 0 ] || fail "setrans.d backup failed"

	if [ -e $d/setrans.conf ]; then
		cp -L $d/setrans.conf /etc/selinux/mls/setrans.conf
	fi
	if [ -e $d/secolor.conf ]; then
		cp -L $d/secolor.conf /etc/selinux/mls
	fi
	if [ -d $d/setrans.d ]; then
		cp -Lr $d/setrans.d /etc/selinux/mls
	fi

	runcon `cat /etc/selinux/mls/contexts/initrc_context` /etc/init.d/mcstrans restart
	for t in $d/*.test; do
		/usr/share/mcstrans/util/mlstrans-test $t
	done
	for c in $d/*.color; do
		/usr/share/mcstrans/util/mlscolor-test $c
	done

	if [ -e /etc/selinux/mls/setrans.conf.bak ]; then
		mv /etc/selinux/mls/setrans.conf.bak /etc/selinux/mls/setrans.conf
	fi
	if [ -e /etc/selinux/mls/secolor.conf.bak ]; then
		mv /etc/selinux/mls/secolor.conf.bak /etc/selinux/mls/secolor.conf
	fi
	rm -rf /etc/selinux/mls/setrans.d
	mv /etc/selinux/mls/setrans.d.bak    /etc/selinux/mls/setrans.d

	restorecon -rv /etc/selinux/mls/setrans.conf /etc/selinux/mls/setrans.d >/dev/null
	runcon `cat /etc/selinux/mls/contexts/initrc_context` /etc/init.d/mcstrans restart
done
exit 0