Subversion Repositories ALCASAR

Rev

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

Rev 2094 Rev 2234
Line 1... Line 1...
1
#!/bin/sh
1
#!/bin/sh
-
 
2
#
-
 
3
# $Id$
-
 
4
#
-
 
5
# Le script 'macup' est appelé par coovachilli lorsqu'il attribut une @IP à une @MAC.
-
 
6
# Depuis la version 3.1 de ALCASAR, le système d'interception a changé. On doit traiter les authorisations par adresse MAC en amont
-
 
7
# Pour une adresse mac authorisée, nous stockons sont @IP dans l'ipset 'not_filtered'
2
 
8
 
3
#Le script 'macup' est appelé par coovachilli lorsqu'il attribut une @IP à une @MAC.
9
if [ -z $CALLING_STATION_ID ]; then
4
#Depuis la version 3.1 de ALCASAR, le système d'interception a changé. On doit traiter les authorisations par adresse MAC en amont
-
 
5
#Pour une adresse mac authorisée, nous stockons sont @IP dans l'ipset 'not_filtered'
-
 
-
 
10
	exit 1
-
 
11
fi
6
 
12
 
7
chilli_current_mac=$(chilli_query list | grep $CALLING_STATION_ID)
13
chilli_current_mac=$(chilli_query list | grep $CALLING_STATION_ID)
8
is_connected=$(echo $chilli_current_mac | cut -d' ' -f5)
14
is_connected=$(echo $chilli_current_mac | cut -d' ' -f5)
9
current_mac=$(echo $chilli_current_mac | cut -d' ' -f1)
15
current_mac=$(echo $chilli_current_mac | cut -d' ' -f1)
10
current_name=$(echo $chilli_current_mac | cut -d' ' -f6)
16
current_name=$(echo $chilli_current_mac | cut -d' ' -f6)
11
current_ip=$(echo $chilli_current_mac | cut -d' ' -f2)
17
current_ip=$(echo $chilli_current_mac | cut -d' ' -f2)
12
 
18
 
13
 
19
 
14
 
-
 
15
if [ $is_connected == "1" ] && [ $current_mac == $current_name ]; then
20
if [ $is_connected == "1" ] && [ $current_mac == $current_name ]; then
16
	#Lecture du filter-id dans la DB radius afin de placer l'équipement réseau dans le bon ipset
21
	#Lecture du filter-id dans la DB radius afin de placer l'équipement réseau dans le bon ipset
17
	#Un équipement autorisé "à chaud" sera placé dans l'ipset 'not_filtered' + pas de filtrage de protocole (proto_0)
22
	#Un équipement autorisé "à chaud" sera placé dans l'ipset 'not_filtered' + pas de filtrage de protocole (proto_0)
18
	PASSWD_FILE="/root/ALCASAR-passwords.txt"
23
	PASSWD_FILE="/root/ALCASAR-passwords.txt"
19
	QUERY="SELECT value from radreply where username='$current_mac'"
24
	QUERY="SELECT value FROM radreply WHERE attribute='Filter-Id' AND username='$current_mac';"
20
	FILTER_ID=$(mysql -D radius -u root -p$(cat $PASSWD_FILE | grep "root /" | rev | cut -d' '  -f1 | rev)<<<"$QUERY" | tail -1)
25
	FILTER_ID=$(mysql -D radius -u root -p$(cat $PASSWD_FILE | grep "root /" | rev | cut -d' ' -f1 | rev) -e "$QUERY" -Ns)
21
 
26
 
22
	#Suppression de l'utilisateur de l'ipset not_auth_yet (au cas où)	
-
 
23
	ipset del not_auth_yet $current_ip
-
 
24
 
-
 
25
	#Valeur de FILTER-ID : 12345678
27
	# FilterID Byte N°0 to 7
26
	#1-> profile1
28
	#  0: profile_1 (WEB)
27
	#2-> profile2
29
	#  1: profile_2 (WEB + Mail + Remote access)
28
	#3-> profile3
30
	#  2: profile_3 (Custom)
29
	#4-> warn_user (if imputability report has been generated)
31
	#  3: warn_user (if imputability report has been generated)
30
	#6-> WL + HAVP
32
	#  5: WL
31
	#7-> BL + HAVP
33
	#  6: BL
32
	#8-> HAVP
34
	#  7: HAVP
33
 
35
 
34
	
-
 
35
	if [ ${FILTER_ID:7:1} -eq '1' ] #HAVP
36
	if [ ${FILTER_ID:7:1} == '1' ]; then	# HAVP
36
	then 
-
 
37
		set="havp"
37
		set_filter="havp"
38
		if [ ${FILTER_ID:0:1} -eq '1' ]
38
	elif [ ${FILTER_ID:6:1} == '1' ]; then	# HAVP_BL
39
		then 
-
 
40
			set_proto="proto_1";
39
		set_filter="havp_bl"
41
		fi
-
 
42
 
-
 
43
		if [ ${FILTER_ID:1:1} -eq '1' ]
40
	elif [ ${FILTER_ID:5:1} == '1' ]; then	# HAVP_WL
44
		then 
-
 
45
			set_proto="proto_2";
41
		set_filter="havp_wl"
46
		fi
-
 
47
	
-
 
48
		if [ ${FILTER_ID:2:1} -eq '1' ]
-
 
49
		then 
-
 
50
			set_proto="proto_3";
42
	else					# NOT_FILTERED
51
		fi
-
 
52
 
-
 
53
		if [ -z "$set_proto"  ]
-
 
54
		then 
-
 
55
			set_proto="proto_0";
43
		set_filter="not_filtered"
56
		fi
-
 
57
	fi
44
	fi
58
 
45
 
59
 
-
 
60
	if [ ${FILTER_ID:6:1} -eq '1' ] #HAVP_BL
46
	if [ ${FILTER_ID:0:1} == '1' ]; then	# PROFILE 1 (WEB)
61
	then 
-
 
62
		set="havp_bl"
-
 
63
		if [ ${FILTER_ID:0:1} -eq '1' ]
-
 
64
		then 
-
 
65
			set_proto="proto_1";
47
		set_proto="proto_1";
66
		fi
-
 
67
 
-
 
68
		if [ ${FILTER_ID:1:1} -eq '1' ]
48
	elif [ ${FILTER_ID:1:1} == '1' ]; then	# PROFILE 2 (WEB + Mail + Remote access)
69
		then 
-
 
70
			set_proto="proto_2";
49
		set_proto="proto_2";
71
		fi
-
 
72
	
-
 
73
		if [ ${FILTER_ID:2:1} -eq '1' ]
50
	elif [ ${FILTER_ID:2:1} == '1' ]; then	# PROFILE 3 (Custom)
74
		then 
-
 
75
			set_proto="proto_3";
51
		set_proto="proto_3";
76
		fi
-
 
77
 
-
 
78
		if [ -z "$set_proto"  ]
52
	else					# PROFILE 0 (Not filtered)
79
		then 
-
 
80
			set_proto="proto_0";
53
		set_proto="proto_0";
81
		fi
-
 
82
	fi
54
	fi
83
 
55
 
84
	if [ ${FILTER_ID:5:1} -eq '1' ] #HAVP_WL
-
 
85
	then 
-
 
86
		set="havp_wl"
-
 
87
		if [ ${FILTER_ID:0:1} -eq '1' ]
-
 
88
		then 
-
 
89
			set_proto="proto_1";
-
 
90
		fi
-
 
91
 
-
 
92
		if [ ${FILTER_ID:1:1} -eq '1' ]
-
 
93
		then 
-
 
94
			set_proto="proto_2";
-
 
95
		fi
-
 
96
	
-
 
97
		if [ ${FILTER_ID:2:1} -eq '1' ]
-
 
98
		then 
-
 
99
			set_proto="proto_3";
-
 
100
		fi
-
 
101
 
-
 
102
		if [ -z "$set_proto"  ]
-
 
103
		then 
-
 
104
			set_proto="proto_0";
-
 
105
		fi
-
 
106
	fi
-
 
107
 
-
 
108
 
-
 
109
 
-
 
110
	if [ -z "$set"  ] #NOT_FILTERED
-
 
111
	then 
-
 
112
		set="not_filtered"
-
 
113
		if [ ${FILTER_ID:0:1} -eq '1' ]
-
 
114
		then 
-
 
115
			set_proto="proto_1";
-
 
116
		fi
-
 
117
 
-
 
118
		if [ ${FILTER_ID:1:1} -eq '1' ]
-
 
119
		then 
-
 
120
			set_proto="proto_2";
-
 
121
		fi
-
 
122
	
-
 
123
		if [ ${FILTER_ID:2:1} -eq '1' ]
-
 
124
		then 
-
 
125
			set_proto="proto_3";
-
 
126
		fi
-
 
127
 
-
 
128
		if [ -z "$set_proto"  ]
-
 
129
		then 
-
 
130
			set_proto="proto_0";
-
 
131
		fi
-
 
132
	fi
-
 
133
 
-
 
134
 
-
 
135
	ipset add $set $current_ip
56
	ipset add $set_filter $current_ip
136
	ipset add $set_proto $current_ip
57
	ipset add $set_proto $current_ip
137
 
-
 
138
fi
58
fi
139
 
-