#
# segatex SELinux tool.
#
# Copyright (C) 2007-2009 Shintaro Fujiwara 
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

#!/bin/sh

NEXT_FUNC(){
	SETROUBLESHOOTD_IS_ALIVE=`ps -ef|grep setroubleshootd|grep python|awk '{ print $2 }'`
	echo "######################################################"
	echo "setroubleshootd's number " "$SETROUBLESHOOTD_IS_ALIVE"

	if [ "$SETROUBLESHOOTD_IS_ALIVE" != "" ];then
		echo "######################################################"
		ps -efZ
	else
		echo "setroubleshootd is not alive"
		echo "######################################################"
		ps -efZ
	fi
}

PERMISSIVE_SEGATEX_IS_ALIVE=`/usr/sbin/semodule -l|grep permissive|grep segatex`

if [ "$PERMISSIVE_SEGATEX_IS_ALIVE" != "" ];then
	NEXT_FUNC
else
	echo "######################################################"
	echo "Adding segatex to permissive domain."
	/usr/sbin/semanage permissive -a segatex_t
	NEXT_FUNC
fi
/usr/sbin/semanage permissive -d segatex_t
	
