Subversion Repositories ALCASAR

Rev

Rev 519 | 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 520 2011-03-27 20:55:05Z 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"
1 root 11
 
393 franck 12
usage="Usage: alcasar-nf.sh {--on or -on} | {--off | -off} "
1 root 13
nb_args=$#
14
args=$1
15
if [ $nb_args -eq 0 ]
16
then
17
	nb_args=1
18
	args="-h"
19
fi
20
case $args in
21
	-\? | -h* | --h*)
22
		echo "$usage"
23
		exit 0
24
		;;
393 franck 25
	-on|-on)	
1 root 26
		# activation du filtrage réseau
520 richard 27
		$SED "s?^PROTO_FILTERING.*?PROTO_FILTERING=\"yes\"?g" /usr/local/bin/alcasar-iptables.sh
1 root 28
		# tri du fichier de services
323 richard 29
		$SED "/^$/d" $FIC_SERVICES # suppression lignes vides
1 root 30
		sort -k2n $FIC_SERVICES > /tmp/alcasar-services-sort
31
		mv -f /tmp/alcasar-services-sort $FIC_SERVICES
32
		chown root:apache $FIC_SERVICES
33
		chmod 660 $FIC_SERVICES
25 richard 34
		# vérification de présence du fichier d'exception
35
		[ -e $FIC_EXCEPTIONS ] || touch $FIC_EXCEPTIONS
36
		chown root:apache $FIC_EXCEPTIONS
37
		chmod 664 $FIC_EXCEPTIONS
1 root 38
		/usr/local/bin/alcasar-iptables.sh
39
		;;
393 franck 40
	--off|-off)
1 root 41
		# désactivation du filtrage réseau
520 richard 42
		$SED "s?^PROTO_FILTERING.*?PROTO_FILTERING=\"no\"?g" /usr/local/bin/alcasar-iptables.sh
1 root 43
		/usr/local/bin/alcasar-iptables.sh
44
		;;
45
	*)
46
		echo "Argument inconnu :$1";
47
		echo "$usage"
48
		exit 1
49
		;;
50
esac
51