Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
smradius
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
shail
smradius
Commits
b2a96e2b
Commit
b2a96e2b
authored
15 years ago
by
Robert Anderson
Browse files
Options
Downloads
Patches
Plain Diff
Reject connection if no realms are found
parent
c8bdc576
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smradius/modules/system/mod_config_sql.pm
+34
-30
34 additions, 30 deletions
smradius/modules/system/mod_config_sql.pm
with
34 additions
and
30 deletions
smradius/modules/system/mod_config_sql.pm
+
34
−
30
View file @
b2a96e2b
...
@@ -161,15 +161,16 @@ sub getConfig
...
@@ -161,15 +161,16 @@ sub getConfig
# Default realm...
# Default realm...
my
$realmName
=
'
<DEFAULT>
';
my
$realmName
=
'
<DEFAULT>
';
my
$realmID
;
# Get default realm ID
# Get default realm ID
my
$sth
=
DBSelect
(
$config
->
{'
get_config_realm_id_query
'},
$realmName
);
my
$sth
=
DBSelect
(
$config
->
{'
get_config_realm_id_query
'},
$realmName
);
if
(
!
$sth
)
{
if
(
!
$sth
)
{
$server
->
log
(
LOG_ERR
,"
Failed to get default
config attributes
:
"
.
awitpt::db::dblayer::
Error
());
$server
->
log
(
LOG_ERR
,"
Failed to get default
realm ID
:
"
.
awitpt::db::dblayer::
Error
());
return
MOD_RES_NACK
;
return
MOD_RES_NACK
;
}
}
# Set realm ID
# Set realm ID
my
(
$row
,
$realmID
)
;
my
$row
;
if
(
$sth
->
rows
==
1
)
{
if
(
$sth
->
rows
==
1
)
{
$row
=
hashifyLCtoMC
(
$sth
->
fetchrow_hashref
(),
qw(ID)
);
$row
=
hashifyLCtoMC
(
$sth
->
fetchrow_hashref
(),
qw(ID)
);
$realmID
=
$row
->
{'
ID
'};
$realmID
=
$row
->
{'
ID
'};
...
@@ -180,7 +181,7 @@ sub getConfig
...
@@ -180,7 +181,7 @@ sub getConfig
if
(
defined
(
$realmID
))
{
if
(
defined
(
$realmID
))
{
$sth
=
DBSelect
(
$config
->
{'
get_config_realm_attributes_query
'},
$realmID
);
$sth
=
DBSelect
(
$config
->
{'
get_config_realm_attributes_query
'},
$realmID
);
if
(
!
$sth
)
{
if
(
!
$sth
)
{
$server
->
log
(
LOG_ERR
,"
Failed to get default config attributes:
"
.
awitpt::db::dblayer::
Error
());
$server
->
log
(
LOG_ERR
,"
Failed to get default
realm
config attributes:
"
.
awitpt::db::dblayer::
Error
());
return
MOD_RES_NACK
;
return
MOD_RES_NACK
;
}
}
# Add any default realm attributes to config attributes
# Add any default realm attributes to config attributes
...
@@ -191,7 +192,6 @@ sub getConfig
...
@@ -191,7 +192,6 @@ sub getConfig
}
}
# Extract realm from username
# Extract realm from username
my
$userRealmID
;
if
(
defined
(
$user
->
{'
Username
'})
&&
$user
->
{'
Username
'}
=~
/^\S+@(\S+)$/
)
{
if
(
defined
(
$user
->
{'
Username
'})
&&
$user
->
{'
Username
'}
=~
/^\S+@(\S+)$/
)
{
$realmName
=
$
1
;
$realmName
=
$
1
;
...
@@ -203,11 +203,11 @@ sub getConfig
...
@@ -203,11 +203,11 @@ sub getConfig
# Fetch realm ID
# Fetch realm ID
if
(
$sth
->
rows
==
1
)
{
if
(
$sth
->
rows
==
1
)
{
$row
=
hashifyLCtoMC
(
$sth
->
fetchrow_hashref
(),
qw(ID)
);
$row
=
hashifyLCtoMC
(
$sth
->
fetchrow_hashref
(),
qw(ID)
);
$
userR
ealmID
=
$row
->
{'
ID
'};
$
r
ealmID
=
$row
->
{'
ID
'};
DBFreeRes
(
$sth
);
DBFreeRes
(
$sth
);
# User realm attributes
# User realm attributes
$sth
=
DBSelect
(
$config
->
{'
get_config_realm_attributes_query
'},
$
userR
ealmID
);
$sth
=
DBSelect
(
$config
->
{'
get_config_realm_attributes_query
'},
$
r
ealmID
);
if
(
!
$sth
)
{
if
(
!
$sth
)
{
$server
->
log
(
LOG_ERR
,"
Failed to get user realm config attributes:
"
.
awitpt::db::dblayer::
Error
());
$server
->
log
(
LOG_ERR
,"
Failed to get user realm config attributes:
"
.
awitpt::db::dblayer::
Error
());
return
MOD_RES_NACK
;
return
MOD_RES_NACK
;
...
@@ -220,34 +220,38 @@ sub getConfig
...
@@ -220,34 +220,38 @@ sub getConfig
}
}
}
}
# Reject if there is no realm
if
(
!
defined
(
$realmID
))
{
$server
->
log
(
LOG_DEBUG
,"
No realm found, rejecting
");
return
MOD_RES_NACK
;
}
# Get client name
# Get client name
my
(
$clientID
,
$res
);
my
(
$clientID
,
$res
);
if
(
defined
(
$userRealmID
))
{
$sth
=
DBSelect
(
$config
->
{'
get_config_accesslist_query
'},
$realmID
);
$sth
=
DBSelect
(
$config
->
{'
get_config_accesslist_query
'},
$userRealmID
);
if
(
!
$sth
)
{
if
(
!
$sth
)
{
$server
->
log
(
LOG_ERR
,"
Failed to get config attributes:
"
.
awitpt::db::dblayer::
Error
());
$server
->
log
(
LOG_ERR
,"
Failed to get config attributes:
"
.
awitpt::db::dblayer::
Error
());
return
MOD_RES_NACK
;
return
MOD_RES_NACK
;
}
}
# Check if we know this client
# Check if we know this client
my
@accessList
;
my
@accessList
;
while
(
my
$row
=
$sth
->
fetchrow_hashref
())
{
while
(
my
$row
=
$sth
->
fetchrow_hashref
())
{
$res
=
hashifyLCtoMC
(
$row
,
qw(AccessList ID)
);
$res
=
hashifyLCtoMC
(
$row
,
qw(AccessList ID)
);
# Split off allowed sources, comma separated
# Split off allowed sources, comma separated
@accessList
=
();
@accessList
=
();
@accessList
=
split
('
,
',
$res
->
{'
AccessList
'});
@accessList
=
split
('
,
',
$res
->
{'
AccessList
'});
# Loop with what we get and check if we have match
# Loop with what we get and check if we have match
foreach
my
$ip
(
@accessList
)
{
foreach
my
$ip
(
@accessList
)
{
if
(
$server
->
{'
server
'}{'
peeraddr
'}
eq
$ip
)
{
if
(
$server
->
{'
server
'}{'
peeraddr
'}
eq
$ip
)
{
$clientID
=
$res
->
{'
ID
'};
$clientID
=
$res
->
{'
ID
'};
last
;
last
;
}
}
}
}
}
DBFreeRes
(
$sth
);
}
if
(
!
defined
(
$clientID
))
{
DBFreeRes
(
$sth
);
$server
->
log
(
LOG_ERR
,"
Peer Address '
"
.
$server
->
{'
server
'}{'
peeraddr
'}
.
"
' not found in access list
");
if
(
!
defined
(
$clientID
))
{
return
MOD_RES_NACK
;
$server
->
log
(
LOG_ERR
,"
Peer Address '
"
.
$server
->
{'
server
'}{'
peeraddr
'}
.
"
' not found in access list
")
;
}
return
MOD_RES_NACK
;
}
}
# Get client attributes
# Get client attributes
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment