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-conup.sh 2692 2019-01-25 23:18:50Z tom.houdayer $
3
# $Id: alcasar-conup.sh 2712 2019-03-10 23:28:36Z tom.houdayer $
4
#
4
#
5
# alcasar-conup.sh
5
# alcasar-conup.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 15... Line 15...
15
	exit 1
15
	exit 1
16
fi
16
fi
17
 
17
 
18
# Add user to his IPSET
18
# Add user to his IPSET
19
 
19
 
-
 
20
db_query_additionalGroups=''
-
 
21
[ -n "$FILTER_ID" ] && db_query_additionalGroups="( SELECT attribute, value FROM radgroupreply WHERE groupname = '$FILTER_ID' AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter', 'Alcasar-Status-Page-Must-Stay-Open')) ) UNION "
-
 
22
db_query="SELECT attribute, value FROM ( \
-
 
23
	( SELECT attribute, value FROM radreply      WHERE username  = '$USER_NAME' AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter', 'Alcasar-Status-Page-Must-Stay-Open')) ) UNION \
20
db_query="SELECT attribute, value FROM (( SELECT attribute, value FROM radreply WHERE (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter', 'Alcasar-Status-Page-Must-Stay-Open')) 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', 'Alcasar-Status-Page-Must-Stay-Open')) 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', 'Alcasar-Status-Page-Must-Stay-Open')))) attrs GROUP BY attribute;"
24
	( 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', 'Alcasar-Status-Page-Must-Stay-Open')) ORDER BY ug.priority ) UNION \
-
 
25
	$db_query_additionalGroups \
-
 
26
	( SELECT attribute, value FROM radgroupreply WHERE groupname = 'default'    AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter', 'Alcasar-Status-Page-Must-Stay-Open')) ) \
-
 
27
) 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)
28
db_res=$(mysql -u root -p$(cat $PASSWD_FILE | grep ^db_root= | cut -d'=' -f2-) -D radius -e "$db_query" -Ns)
22
 
29
 
23
filter=$(echo "$db_res"             | awk '$1 == "Alcasar-Filter"                     { print $2 }')
30
filter=$(echo "$db_res"             | awk '$1 == "Alcasar-Filter"                     { print $2 }')
24
filterProto=$(echo "$db_res"        | awk '$1 == "Alcasar-Protocols-Filter"           { print $2 }')
31
filterProto=$(echo "$db_res"        | awk '$1 == "Alcasar-Protocols-Filter"           { print $2 }')
25
statusOpenRequired=$(echo "$db_res" | awk '$1 == "Alcasar-Status-Page-Must-Stay-Open" { print $2 }')
32
statusOpenRequired=$(echo "$db_res" | awk '$1 == "Alcasar-Status-Page-Must-Stay-Open" { print $2 }')