-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththeo_agent.sh
executable file
·51 lines (46 loc) · 1.31 KB
/
theo_agent.sh
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
#!/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" theo_agent.te | awk '{ printf "%s %s", $6, $7 }'`
rules=`ausearch --start $time -m avc --raw -se theo_agent`
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 >> theo_agent.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 theo_agent.pp || exit
/usr/sbin/semodule -i theo_agent.pp
# Generate a man page off the installed module
sepolicy manpage -p . -d theo_agent_t
# Fixing the file context on theo-agent files and dirs
/sbin/restorecon -F -v ${THEO_AGENT_EXEC:-/usr/sbin/theo-agent}
/sbin/restorecon -R -v ${THEO_AGENT_CONFIG:-/etc/theo-agent}
/sbin/restorecon -R -v ${THEO_AGENT_CACHE:-/var/cache/theo-agent}