Subversion Repositories ALCASAR

Rev

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

Rev 2692 Rev 2712
Line 1... Line 1...
1
#!/bin/sh
1
#!/bin/sh
2
#
2
#
3
# $Id: alcasar-condown.sh 2692 2019-01-25 23:18:50Z tom.houdayer $
3
# $Id: alcasar-condown.sh 2712 2019-03-10 23:28:36Z tom.houdayer $
4
#
4
#
5
# alcasar-condown.sh
5
# alcasar-condown.sh
6
# by Rexy
6
# by Rexy
7
# This script is distributed under the Gnu General Public License (GPL)
7
# This script is distributed under the Gnu General Public License (GPL)
8
 
8
 
Line 14... Line 14...
14
if [ -z $FRAMED_IP_ADDRESS ]; then
14
if [ -z $FRAMED_IP_ADDRESS ]; then
15
	exit 1
15
	exit 1
16
fi
16
fi
17
 
17
 
18
# Remove user from his IPSET
18
# Remove user from his IPSET
19
 
-
 
-
 
19
db_query_additionalGroups=''
-
 
20
[ -n "$FILTER_ID" ] && db_query_additionalGroups="( SELECT attribute, value FROM radgroupreply WHERE groupname = '$FILTER_ID' AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter')) ) UNION "
-
 
21
db_query="SELECT attribute, value FROM ( \
-
 
22
	( SELECT attribute, value FROM radreply      WHERE username  = '$USER_NAME' AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter')) ) UNION \
20
db_query="SELECT attribute, value FROM (( SELECT attribute, value FROM radreply WHERE (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter')) AND username='$USER_NAME') UNION ( SELECT attribute, value FROM radgroupreply gr LEFT JOIN radusergroup ug ON gr.groupname = ug.groupname WHERE (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter')) AND username = '$USER_NAME' ORDER BY ug.priority) UNION (SELECT attribute, value FROM radgroupreply WHERE groupname = 'ldap' AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter')))) attrs GROUP BY attribute;"
23
	( SELECT attribute, value FROM radgroupreply gr LEFT JOIN radusergroup ug ON gr.groupname = ug.groupname WHERE username = '$USER_NAME' AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter')) ORDER BY ug.priority ) UNION \
-
 
24
	$db_query_additionalGroups \
-
 
25
	( SELECT attribute, value FROM radgroupreply WHERE groupname = 'default'    AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter')) ) \
-
 
26
) attrs GROUP BY attribute;"
21
db_res=$(mysql -u root -p$(cat $PASSWD_FILE | grep ^db_root= | cut -d'=' -f2-) -D radius -e "$db_query" -Ns)
27
db_res=$(mysql -u root -p$(cat $PASSWD_FILE | grep ^db_root= | cut -d'=' -f2-) -D radius -e "$db_query" -Ns)
22
 
28
 
23
filter=$(echo "$db_res"             | awk '$1 == "Alcasar-Filter"           { print $2 }')
29
filter=$(echo "$db_res"      | awk '$1 == "Alcasar-Filter"           { print $2 }')
24
filterProto=$(echo "$db_res"        | awk '$1 == "Alcasar-Protocols-Filter" { print $2 }')
30
filterProto=$(echo "$db_res" | awk '$1 == "Alcasar-Protocols-Filter" { print $2 }')
25
 
31
 
26
if [ "$filter" == '4' ]; then	# HAVP_WL
32
if [ "$filter" == '4' ]; then	# HAVP_WL
27
	set_filter="havp_wl"
33
	set_filter="havp_wl"
28
elif [ "$filter" == '3' ]; then	# HAVP_BL
34
elif [ "$filter" == '3' ]; then	# HAVP_BL
29
	set_filter="havp_bl"
35
	set_filter="havp_bl"