Subversion Repositories ALCASAR

Rev

Rev 618 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
1 root 1
#/bin/sh
63 franck 2
# $Id: alcasar-nf.sh 634 2011-06-13 17:23:46Z richard $
3
 
520 richard 4
# active ou desactive le filtrage de protocoles réseau
5
# enable or disable the network protocols filter
1 root 6
# by rexy
520 richard 7
 
1 root 8
SED="/bin/sed -i"
9
FIC_SERVICES="/usr/local/etc/alcasar-services"
28 richard 10
FIC_EXCEPTIONS="/usr/local/etc/alcasar-filter-exceptions"
612 richard 11
FIC_CONF="/usr/local/etc/alcasar.conf"
1 root 12
 
634 richard 13
usage="Usage: alcasar-nf.sh {--on | -on} | {--off | -off}"
1 root 14
nb_args=$#
15
args=$1
16
if [ $nb_args -eq 0 ]
17
then
634 richard 18
	/usr/local/bin/alcasar-iptables.sh
19
	exit 1
1 root 20
fi
21
case $args in
22
	-\? | -h* | --h*)
23
		echo "$usage"
24
		exit 0
25
		;;
615 richard 26
	-on|-on) # enable protocols filter
27
		# sort service file
28
		$SED "/^$/d" $FIC_SERVICES # delete empty lines
1 root 29
		sort -k2n $FIC_SERVICES > /tmp/alcasar-services-sort
30
		mv -f /tmp/alcasar-services-sort $FIC_SERVICES
31
		chown root:apache $FIC_SERVICES
32
		chmod 660 $FIC_SERVICES
615 richard 33
		# vérify exception file 
25 richard 34
		[ -e $FIC_EXCEPTIONS ] || touch $FIC_EXCEPTIONS
35
		chown root:apache $FIC_EXCEPTIONS
36
		chmod 664 $FIC_EXCEPTIONS
615 richard 37
		$SED "s?^PROTOCOLS_FILTERING.*?PROTOCOLS_FILTERING=on?g" $FIC_CONF
1 root 38
		/usr/local/bin/alcasar-iptables.sh
39
		;;
615 richard 40
	--off|-off) # disable protocols filter
612 richard 41
		$SED "s?^PROTOCOLS_FILTERING.*?PROTOCOLS_FILTERING=off?g" $FIC_CONF
1 root 42
		/usr/local/bin/alcasar-iptables.sh
43
		;;
44
	*)
45
		echo "Argument inconnu :$1";
46
		echo "$usage"
47
		exit 1
48
		;;
49
esac
50