Skip to content

Instantly share code, notes, and snippets.

@kaorimatz
Created August 18, 2013 04:43
Show Gist options
  • Save kaorimatz/6259925 to your computer and use it in GitHub Desktop.
Save kaorimatz/6259925 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
DBUS_WATCH_EXPR="\
type='signal',\
sender='org.fedoraproject.Setroubleshootd',\
interface='org.fedoraproject.SetroubleshootdIface',\
member='alert'\
"
dbus-monitor --system --monitor "$DBUS_WATCH_EXPR" | while read LINE
do
case $LINE in
*Setroubleshootd*)
read _TYPE ALERT_LEVEL
read _TYPE LOCAL_ID
if test "$ALERT_LEVEL" = '"red"'
then
URGENCY_LEVEL='critical'
else
URGENCY_LEVEL='normal'
fi
LOCAL_ID=`echo $LOCAL_ID | sed -e 's/^"//' -e 's/"$//'`
ALERT_MSG=`sealert -l $LOCAL_ID | head -n 1`
notify-send 'SELinux security alert' "$ALERT_MSG" --urgency=$URGENCY_LEVEL
;;
*)
continue
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment