53 lines
1.4 KiB
Bash
53 lines
1.4 KiB
Bash
|
#!/bin/sh -e
|
||
|
|
||
|
DIRNAME=`dirname $0`
|
||
|
cd $DIRNAME
|
||
|
USAGE="$0 [ --update ]"
|
||
|
if [ `id -u` != 0 ]; then
|
||
|
echo 'You must be root to run this script'
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
if [ $# -eq 1 ]; then
|
||
|
if [ "$1" = "--update" ] ; then
|
||
|
time=`ls -l --time-style="+%x %X" wings.te | awk '{ printf "%s %s", $6, $7 }'`
|
||
|
rules=`ausearch --start $time -m avc --raw -se wings`
|
||
|
if [ x"$rules" != "x" ] ; then
|
||
|
echo "Found avc's to update policy with"
|
||
|
echo -e "$rules" | audit2allow -R
|
||
|
echo "Do you want these changes added to policy [y/n]?"
|
||
|
read ANS
|
||
|
if [ "$ANS" = "y" -o "$ANS" = "Y" ] ; then
|
||
|
echo "Updating policy"
|
||
|
echo -e "$rules" | audit2allow -R >> wings.te
|
||
|
# Fall though and rebuild policy
|
||
|
else
|
||
|
exit 0
|
||
|
fi
|
||
|
else
|
||
|
echo "No new avcs found"
|
||
|
exit 0
|
||
|
fi
|
||
|
else
|
||
|
echo -e $USAGE
|
||
|
exit 1
|
||
|
fi
|
||
|
elif [ $# -ge 2 ] ; then
|
||
|
echo -e $USAGE
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
echo "Building and Loading Policy"
|
||
|
set -x
|
||
|
make -f /usr/share/selinux/devel/Makefile wings.pp || exit
|
||
|
/usr/sbin/semodule -i wings.pp
|
||
|
|
||
|
# Generate a man page off the installed module
|
||
|
sepolicy manpage -p . -d wings_t
|
||
|
# Fixing the file context on /usr/local/bin/wings
|
||
|
/sbin/restorecon -F -R -v /usr/local/bin/wings
|
||
|
# Generate a rpm package for the newly generated policy
|
||
|
|
||
|
pwd=$(pwd)
|
||
|
rpmbuild --define "_sourcedir ${pwd}" --define "_specdir ${pwd}" --define "_builddir ${pwd}" --define "_srcrpmdir ${pwd}" --define "_rpmdir ${pwd}" --define "_buildrootdir ${pwd}/.build" -ba wings_selinux.spec
|