Subversion Repositories ALCASAR

Rev

Rev 2262 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2262 Rev 2274
1
#!/bin/sh
1
#!/bin/sh
2
#
2
#
3
# $Id: alcasar-macdown.sh 2262 2017-05-29 20:19:03Z tom.houdayer $
3
# $Id: alcasar-macdown.sh 2274 2017-06-06 06:12:50Z richard $
4
#
4
#
5
# Le script 'macdown' est appelé par coovachilli pendant le DHCP down (release)
5
# Le script 'macdown' est appelé par coovachilli pendant le DHCP down (release)
6
# Depuis la version 3.1 de ALCASAR, le système d'interception a changé.
-
 
7
# Pour une adresse mac authorisée pour laquelle coovachilli effectue un DHCP release, l'@IP sera retiré de l'ipset 'not_filtered'
6
# Pour une adresse mac authorisée pour laquelle coovachilli effectue un DHCP release, l'@IP sera retiré de l'ipset 'not_filtered'
8
 
7
 
9
if [ -z $CALLING_STATION_ID ]; then
8
if [ -z $CALLING_STATION_ID ]; then
10
	exit 1
9
	exit 1
11
fi
10
fi
12
 
11
 
13
chilli_current_mac=$(chilli_query list | grep $CALLING_STATION_ID)
12
chilli_current_mac=$(chilli_query list | grep $CALLING_STATION_ID)
14
is_connected=$(echo $chilli_current_mac | cut -d' ' -f5)
13
is_connected=$(echo $chilli_current_mac | cut -d' ' -f5)
15
current_mac=$(echo $chilli_current_mac | cut -d' ' -f1)
14
current_mac=$(echo $chilli_current_mac | cut -d' ' -f1)
16
current_name=$(echo $chilli_current_mac | cut -d' ' -f6)
15
current_name=$(echo $chilli_current_mac | cut -d' ' -f6)
17
current_ip=$(echo $chilli_current_mac | cut -d' ' -f2)
16
current_ip=$(echo $chilli_current_mac | cut -d' ' -f2)
18
 
17
 
19
 
18
 
20
if [ $is_connected == "1" ] && [ $current_mac == $current_name ]; then
19
if [ $is_connected == "1" ] && [ $current_mac == $current_name ]; then   # only for authenticated MAC
21
	#Lecture du Filter-Id de l'équipement authentifié afin de le retirer de son ipset
20
	#Lecture du Filter-Id de l'équipement authentifié afin de le retirer de son ipset
22
	PASSWD_FILE="/root/ALCASAR-passwords.txt"
21
	PASSWD_FILE="/root/ALCASAR-passwords.txt"
23
	QUERY="SELECT value FROM radreply WHERE attribute='Filter-Id' AND username='$current_mac';"
22
	QUERY="SELECT value FROM radreply WHERE attribute='Filter-Id' AND username='$current_mac';"
24
	FILTER_ID=$(mysql -D radius -u root -p$(cat $PASSWD_FILE | grep "root /" | rev | cut -d' ' -f1 | rev) -e "$QUERY" -Ns)
23
	FILTER_ID=$(mysql -D radius -u root -p$(cat $PASSWD_FILE | grep "root /" | rev | cut -d' ' -f1 | rev) -e "$QUERY" -Ns)
25
 
24
 
26
	# FilterID Byte N°0 to 7
25
	# FilterID Byte N°0 to 7
27
	#  0: profile_1 (WEB)
26
	#  0: profile_1 (WEB)
28
	#  1: profile_2 (WEB + Mail + Remote access)
27
	#  1: profile_2 (WEB + Mail + Remote access)
29
	#  2: profile_3 (Custom)
28
	#  2: profile_3 (Custom)
30
	#  3: warn_user (if imputability report has been generated)
29
	#  3: warn_user (if imputability report has been generated)
31
	#  5: WL
30
	#  5: WL
32
	#  6: BL
31
	#  6: BL
33
	#  7: HAVP
32
	#  7: HAVP
34
 
33
 
35
	if [ ${FILTER_ID:5:1} == '1' ]; then	# HAVP_WL
34
	if [ ${FILTER_ID:5:1} == '1' ]; then	# HAVP_WL
36
		set_filter="havp_wl"
35
		set_filter="havp_wl"
37
	elif [ ${FILTER_ID:6:1} == '1' ]; then	# HAVP_BL
36
	elif [ ${FILTER_ID:6:1} == '1' ]; then	# HAVP_BL
38
		set_filter="havp_bl"
37
		set_filter="havp_bl"
39
	elif [ ${FILTER_ID:7:1} == '1' ]; then	# HAVP
38
	elif [ ${FILTER_ID:7:1} == '1' ]; then	# HAVP
40
		set_filter="havp"
39
		set_filter="havp"
41
	else					# NOT_FILTERED
40
	else					# NOT_FILTERED
42
		set_filter="not_filtered"
41
		set_filter="not_filtered"
43
	fi
42
	fi
44
 
43
 
45
	if [ ${FILTER_ID:2:1} == '1' ]; then	# PROFILE 3 (Custom)
44
	if [ ${FILTER_ID:2:1} == '1' ]; then	# PROFILE 3 (Custom)
46
		set_proto="proto_3";
45
		set_proto="proto_3";
47
	elif [ ${FILTER_ID:1:1} == '1' ]; then	# PROFILE 2 (WEB + Mail + Remote access)
46
	elif [ ${FILTER_ID:1:1} == '1' ]; then	# PROFILE 2 (WEB + Mail + Remote access)
48
		set_proto="proto_2";
47
		set_proto="proto_2";
49
	elif [ ${FILTER_ID:0:1} == '1' ]; then	# PROFILE 1 (WEB)
48
	elif [ ${FILTER_ID:0:1} == '1' ]; then	# PROFILE 1 (WEB)
50
		set_proto="proto_1";
49
		set_proto="proto_1";
51
	else					# PROFILE 0 (Not filtered)
50
	else					# PROFILE 0 (Not filtered)
52
		set_proto="proto_0";
51
		set_proto="proto_0";
53
	fi
52
	fi
54
 
53
 
55
	ipset del $set_filter $current_ip
54
	ipset del $set_filter $current_ip
56
	ipset del $set_proto $current_ip
55
	ipset del $set_proto $current_ip
57
fi
56
fi
58
 
57