Subversion Repositories ALCASAR

Rev

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

Rev 672 Rev 771
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-watchdog.sh 672 2011-07-08 15:34:22Z richard $
2
# $Id: alcasar-watchdog.sh 771 2011-11-16 21:20:42Z richard $
3
 
3
 
4
# alcasar-watchdog.sh
4
# alcasar-watchdog.sh
5
# by Richard REY
5
# by Richard REY
6
# This script is distributed under the Gnu General Public License (GPL)
6
# This script is distributed under the Gnu General Public License (GPL)
7
 
7
 
Line 92... Line 92...
92
		noresponse_ip=`echo $noresponse | cut -d" " -f1`
92
		noresponse_ip=`echo $noresponse | cut -d" " -f1`
93
		noresponse_mac=`echo $noresponse | cut -d" " -f2`
93
		noresponse_mac=`echo $noresponse | cut -d" " -f2`
94
		arp_reply=`/usr/sbin/arping -b -I$INTIF -s$PRIVATE_IP -c1 -w4 $noresponse_ip|grep response|cut -d" " -f2`
94
		arp_reply=`/usr/sbin/arping -b -I$INTIF -s$PRIVATE_IP -c1 -w4 $noresponse_ip|grep response|cut -d" " -f2`
95
		if [[ $(expr $arp_reply) -eq 0 ]]
95
		if [[ $(expr $arp_reply) -eq 0 ]]
96
	       	then
96
	       	then
97
			logger "alcasar-watchdog $noresponse_ip ($noresponse_mac) reste muette. On déconnecte."
97
			logger "alcasar-watchdog $noresponse_ip ($noresponse_mac) can't be contact. Alcasar disconnects the user."
98
			/usr/sbin/chilli_query logout $noresponse_mac
98
			/usr/sbin/chilli_query logout $noresponse_mac
99
		fi
99
		fi
100
	done
100
	done
101
	rm $tmp_file
101
	rm $tmp_file
102
fi
102
fi
Line 107... Line 107...
107
	active_session=`echo $system |cut -d" " -f5`
107
	active_session=`echo $system |cut -d" " -f5`
108
	active_mac=`echo $system | cut -d" " -f1`
108
	active_mac=`echo $system | cut -d" " -f1`
109
# on ne traite que les équipements exploitées par un usager authentifié (test de 2 réponses en 4 secondes)
109
# on ne traite que les équipements exploitées par un usager authentifié (test de 2 réponses en 4 secondes)
110
if [[ $(expr $active_session) -eq 1 ]]
110
if [[ $(expr $active_session) -eq 1 ]]
111
	then
111
	then
112
	arp_reply=`/usr/sbin/arping -b -I$INTIF -s$PRIVATE_IP -c2 -w4 $active_ip|grep response|cut -d" " -f2`
112
	arp_reply=`/usr/sbin/arping -b -I$INTIF -s$PRIVATE_IP -c2 -w4 $active_ip|grep "Unicast reply"|wc -l`
113
# on stocke les adresses IP des stations muettes
113
# on stocke les adresses IP des stations muettes
114
	if [[ $(expr $arp_reply) -eq 0 ]]
114
	if [[ $(expr $arp_reply) -eq 0 ]]
115
	       	then
115
	       	then
116
			echo "$active_ip $active_mac" >> $tmp_file
116
			echo "$active_ip $active_mac" >> $tmp_file
117
	fi
117
	fi
118
# on deconnecte l'usager d'une stations usurpée (@MAC)
118
# on deconnecte l'usager d'une stations usurpée (@MAC)
119
	if [[ $(expr $arp_reply) -gt 2 ]]
119
	if [[ $(expr $arp_reply) -gt 2 ]]
120
	       	then
120
	       	then
121
			logger "alcasar-watchdog : $active_ip est usurpée ($active_mac). On déconnecte."
121
			logger "alcasar-watchdog : $active_ip is usurped ($active_mac). Alcasar disconnect the user."
122
			/usr/sbin/chilli_query logout $active_mac
122
			/usr/sbin/chilli_query logout $active_mac
123
	fi
123
	fi
124
fi
124
fi
125
done
125
done
126
IFS=$OLDIFS
126
IFS=$OLDIFS