Home | History | Annotate | Download | only in util
      1 #!/bin/bash
      2 
      3 shopt -s nullglob
      4 
      5 fail() {
      6   echo $1
      7   exit 1
      8 }
      9 
     10 [ `id -u` = 0 ] || fail "must run as root"
     11 
     12 for d in /usr/share/mcstrans/examples/*; do
     13 	echo $d
     14 
     15 	rm -rf /etc/selinux/mls/setrans.conf.bak /etc/selinux/mls/secolor.conf.bak /etc/selinux/mls/setrans.d.bak
     16 	[ $? -eq 0 ] || fail "preclean failed"
     17 
     18 	if [ -e $d/setrans.conf ]; then
     19 		mv /etc/selinux/mls/setrans.conf /etc/selinux/mls/setrans.conf.bak
     20 		[ $? -eq 0 ] || fail "setrans.conf backup failed"
     21 	fi
     22 
     23 	if [ -e /etc/selinux/mls/secolor.conf ]; then
     24 		mv /etc/selinux/mls/secolor.conf /etc/selinux/mls/secolor.conf.bak
     25 		[ $? -eq 0 ] || fail "secolor.conf backup failed"
     26 	fi
     27 
     28 	mv /etc/selinux/mls/setrans.d /etc/selinux/mls/setrans.d.bak
     29 	[ $? -eq 0 ] || fail "setrans.d backup failed"
     30 
     31 	if [ -e $d/setrans.conf ]; then
     32 		cp -L $d/setrans.conf /etc/selinux/mls/setrans.conf
     33 	fi
     34 	if [ -e $d/secolor.conf ]; then
     35 		cp -L $d/secolor.conf /etc/selinux/mls
     36 	fi
     37 	if [ -d $d/setrans.d ]; then
     38 		cp -Lr $d/setrans.d /etc/selinux/mls
     39 	fi
     40 
     41 	runcon `cat /etc/selinux/mls/contexts/initrc_context` /etc/init.d/mcstrans restart
     42 	for t in $d/*.test; do
     43 		/usr/share/mcstrans/util/mlstrans-test $t
     44 	done
     45 	for c in $d/*.color; do
     46 		/usr/share/mcstrans/util/mlscolor-test $c
     47 	done
     48 
     49 	if [ -e /etc/selinux/mls/setrans.conf.bak ]; then
     50 		mv /etc/selinux/mls/setrans.conf.bak /etc/selinux/mls/setrans.conf
     51 	fi
     52 	if [ -e /etc/selinux/mls/secolor.conf.bak ]; then
     53 		mv /etc/selinux/mls/secolor.conf.bak /etc/selinux/mls/secolor.conf
     54 	fi
     55 	rm -rf /etc/selinux/mls/setrans.d
     56 	mv /etc/selinux/mls/setrans.d.bak    /etc/selinux/mls/setrans.d
     57 
     58 	restorecon -rv /etc/selinux/mls/setrans.conf /etc/selinux/mls/setrans.d >/dev/null
     59 	runcon `cat /etc/selinux/mls/contexts/initrc_context` /etc/init.d/mcstrans restart
     60 done
     61 exit 0
     62 
     63 
     64 
     65