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
5b5e3285
Commit
5b5e3285
authored
16 years ago
by
Nigel Kukard
Browse files
Options
Downloads
Patches
Plain Diff
* Use same block of code to find a user for certain packet types
parent
150ff324
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smradiusd
+62
-42
62 additions, 42 deletions
smradiusd
with
62 additions
and
42 deletions
smradiusd
+
62
−
42
View file @
5b5e3285
...
...
@@ -482,18 +482,79 @@ sub process_request {
# check attribs
# Main user hash with everything in
my
$user
;
# UserDB module if we using/need it
my
$userdb
;
# Common stuff for multiple codes....
if
(
$pkt
->
code
eq
"
Accounting-Request
"
||
$pkt
->
code
eq
"
Access-Request
")
{
# Set username
$user
->
{'
Username
'}
=
$pkt
->
attr
('
User-Name
');
#
# FIND USER
#
# Loop with modules to try find user
foreach
my
$module
(
@
{
$self
->
{'
plugins
'}})
{
# Try find user
if
(
$module
->
{'
User_find
'})
{
$self
->
log
(
LOG_INFO
,"
[SMRADIUS] FIND: Trying plugin '
"
.
$module
->
{'
Name
'}
.
"
' for username '
"
.
$user
->
{'
Username
'}
.
"
'
");
my
$res
=
$module
->
{'
User_find
'}(
$self
,
$user
,
$pkt
);
# Check result
if
(
!
defined
(
$res
))
{
$self
->
log
(
LOG_DEBUG
,"
[SMRADIUS] FIND: Error with plugin '
"
.
$module
->
{'
Name
'}
.
"
'
");
# Check if we skipping this plugin
}
elsif
(
$res
==
MOD_RES_SKIP
)
{
$self
->
log
(
LOG_DEBUG
,"
[SMRADIUS] FIND: Skipping '
"
.
$module
->
{'
Name
'}
.
"
'
");
# Check if we got a positive result back
}
elsif
(
$res
==
MOD_RES_ACK
)
{
$self
->
log
(
LOG_NOTICE
,"
[SMRADIUS] FIND: Username found with '
"
.
$module
->
{'
Name
'}
.
"
'
");
$userdb
=
$module
;
last
;
# Or a negative result
}
elsif
(
$res
==
MOD_RES_NACK
)
{
$self
->
log
(
LOG_NOTICE
,"
[SMRADIUS] FIND: Username not found with '
"
.
$module
->
{'
Name
'}
.
"
'
");
last
;
}
}
}
}
# Is this an accounting request
if
(
$pkt
->
code
eq
"
Accounting-Request
")
{
$self
->
log
(
LOG_DEBUG
,"
[SMRADIUS] Accounting Request Packet
");
#
# GET USER
#
# Get user data
my
$user
;
if
(
defined
(
$userdb
)
&&
defined
(
$userdb
->
{'
User_get
'}))
{
my
$res
=
$userdb
->
{'
User_get
'}(
$self
,
$user
);
# Check result
if
(
defined
(
$res
)
&&
ref
(
$res
)
eq
"
HASH
")
{
# We're only after the attributes here
$user
->
{'
Attributes
'}
=
$res
->
{'
Attributes
'};
}
}
# Loop with modules to try something that handles accounting
foreach
my
$module
(
@
{
$self
->
{'
plugins
'}})
{
# Try find user
if
(
$module
->
{'
Accounting_log
'})
{
$self
->
log
(
LOG_INFO
,"
[SMRADIUS] ACCOUNTING: Trying plugin '
"
.
$module
->
{'
Name
'}
.
"
'
");
my
$res
=
$module
->
{'
Accounting_log
'}(
$self
,
$pkt
);
my
$res
=
$module
->
{'
Accounting_log
'}(
$self
,
$
user
,
$
pkt
);
# Check result
if
(
!
defined
(
$res
))
{
...
...
@@ -529,13 +590,6 @@ sub process_request {
$self
->
log
(
LOG_DEBUG
,"
[SMRADIUS] Access Request Packet
");
$self
->
log
(
LOG_DEBUG
,"
[SMRADIUS] Packet:
"
.
$pkt
->
dump
);
# Main user hash with everything in
my
$user
=
{
'
Username
'
=>
$pkt
->
attr
('
User-Name
')
};
# UserDB variables
my
$userdb
;
# This is the module that ACK or NACK the user
# Authentication variables
my
$authenticated
=
0
;
my
$mechanism
;
...
...
@@ -543,40 +597,6 @@ sub process_request {
my
$authorized
=
0
;
#
# FIND USER
#
# Loop with modules to try find user
foreach
my
$module
(
@
{
$self
->
{'
plugins
'}})
{
# Try find user
if
(
$module
->
{'
User_find
'})
{
$self
->
log
(
LOG_INFO
,"
[SMRADIUS] FIND: Trying plugin '
"
.
$module
->
{'
Name
'}
.
"
' for username '
"
.
$user
->
{'
Username
'}
.
"
'
");
my
$res
=
$module
->
{'
User_find
'}(
$self
,
$user
,
$pkt
);
# Check result
if
(
!
defined
(
$res
))
{
$self
->
log
(
LOG_DEBUG
,"
[SMRADIUS] FIND: Error with plugin '
"
.
$module
->
{'
Name
'}
.
"
'
");
# Check if we skipping this plugin
}
elsif
(
$res
==
MOD_RES_SKIP
)
{
$self
->
log
(
LOG_DEBUG
,"
[SMRADIUS] FIND: Skipping '
"
.
$module
->
{'
Name
'}
.
"
'
");
# Check if we got a positive result back
}
elsif
(
$res
==
MOD_RES_ACK
)
{
$self
->
log
(
LOG_NOTICE
,"
[SMRADIUS] FIND: Username found with '
"
.
$module
->
{'
Name
'}
.
"
'
");
$userdb
=
$module
;
last
;
# Or a negative result
}
elsif
(
$res
==
MOD_RES_NACK
)
{
$self
->
log
(
LOG_NOTICE
,"
[SMRADIUS] FIND: Username not found with '
"
.
$module
->
{'
Name
'}
.
"
'
");
last
;
}
}
}
# If no user is found, bork out ...
if
(
!
defined
(
$userdb
))
{
$self
->
log
(
LOG_INFO
,"
[SMRADIUS] FIND: No plugin found for username '
"
.
$user
->
{'
Username
'}
.
"
'
");
...
...
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