Subversion Repositories ALCASAR

Rev

Rev 612 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

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