Subversion Repositories ALCASAR

Rev

Rev 2885 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2885 Rev 2886
Line 2... Line 2...
2
PASSWD_FILE="/root/ALCASAR-passwords.txt"
2
PASSWD_FILE="/root/ALCASAR-passwords.txt"
3
USER_NAME="test"
3
USER_NAME="test"
4
DB_USER=`cat $PASSWD_FILE|grep ^db_user=|cut -d'=' -f2`
4
DB_USER=`cat $PASSWD_FILE|grep ^db_user=|cut -d'=' -f2`
5
DB_PASSWORD=`cat $PASSWD_FILE|grep ^db_password=|cut -d'=' -f2`
5
DB_PASSWORD=`cat $PASSWD_FILE|grep ^db_password=|cut -d'=' -f2`
6
 
6
 
7
# Retrieve alcasar special radius attributes 
7
# Retrieve 3 ALCASAR special radius attributes (search order : default group, then user's group, then user)
8
db_query="SELECT attribute, value FROM ( \
8
db_query="SELECT attribute, value FROM ( \
9
 	( SELECT attribute, value FROM radreply WHERE username = '$USER_NAME' AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter', 'Alcasar-Status-Page-Must-Stay-Open')) ) UNION \
9
 	( SELECT attribute, value FROM radreply WHERE username = '$USER_NAME' AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter', 'Alcasar-Status-Page-Must-Stay-Open')) ) UNION \
10
	( 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 \
10
	( 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 \
11
	( SELECT attribute, value FROM radgroupreply WHERE groupname = 'default' AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter', 'Alcasar-Status-Page-Must-Stay-Open')) ) \
11
	( SELECT attribute, value FROM radgroupreply WHERE groupname = 'default' AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter', 'Alcasar-Status-Page-Must-Stay-Open')) ) \
12
) attrs GROUP BY attribute;"
12
) attrs GROUP BY attribute;"
Line 16... Line 16...
16
filterProto=$(echo "$db_radreply_res"        | awk '$1 == "Alcasar-Protocols-Filter"           { print $2 }')
16
filterProto=$(echo "$db_radreply_res"        | awk '$1 == "Alcasar-Protocols-Filter"           { print $2 }')
17
statusOpenRequired=$(echo "$db_radreply_res" | awk '$1 == "Alcasar-Status-Page-Must-Stay-Open" { print $2 }')
17
statusOpenRequired=$(echo "$db_radreply_res" | awk '$1 == "Alcasar-Status-Page-Must-Stay-Open" { print $2 }')
18
echo "USER_NAME = $USER_NAME; filter = $filter; filterproto = $filterProto; statusOpenRequired = $statusOpenRequired";
18
echo "USER_NAME = $USER_NAME; filter = $filter; filterproto = $filterProto; statusOpenRequired = $statusOpenRequired";
19
 
19
 
20
# If status page isn't required :
20
# If status page isn't required :
21
#	-add user_IP with flag PERM in /tmp/current_users.txt
21
#	-add user_IP with the flag 'PERM' in /tmp/current_users.txt
22
#	-add user_@MAC as an authenticated user (until "expiration_date") 
22
#	-add user_@MAC as an authenticated (with the same user's attributes)
23
if [ "$statusOpenRequired" == '2' ]; then	# Status page is not required
23
if [ "$statusOpenRequired" == '2' ]; then	# Status page is not required
24
	echo ""
24
	echo ""
25
db_query="SELECT attribute, value FROM ( \
25
db_query="SELECT attribute, value FROM ( \
26
 	( SELECT attribute, value FROM radcheck WHERE username = '$USER_NAME' AND attribute = 'Expiration' ) UNION \
26
 	( SELECT attribute, value FROM radcheck WHERE username = '$USER_NAME' AND attribute = 'Expiration' ) UNION \
27
	( SELECT attribute, value FROM radgroupcheck gr LEFT JOIN radusergroup ug ON gr.groupname = ug.groupname WHERE username = '$USER_NAME' AND attribute = 'Expiration' ORDER BY ug.priority ) UNION \
27
	( SELECT attribute, value FROM radgroupcheck gr LEFT JOIN radusergroup ug ON gr.groupname = ug.groupname WHERE username = '$USER_NAME' AND attribute = 'Expiration' ORDER BY ug.priority ) UNION \