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
962f64a8
Commit
962f64a8
authored
16 years ago
by
Robert Anderson
Browse files
Options
Downloads
Patches
Plain Diff
Initial support for user database
parent
1ec9786c
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
smradius/modules/userdb/mod_userdb_sql.pm
+43
-4
43 additions, 4 deletions
smradius/modules/userdb/mod_userdb_sql.pm
with
43 additions
and
4 deletions
smradius/modules/userdb/mod_userdb_sql.pm
+
43
−
4
View file @
962f64a8
...
@@ -24,7 +24,8 @@ use warnings;
...
@@ -24,7 +24,8 @@ use warnings;
# Modules we need
# Modules we need
use
smradius::
constants
;
use
smradius::
constants
;
use
smradius::
logging
;
use
smradius::
logging
;
use
smradius::
dblayer
;
use
smradius::
util
;
# Exporter stuff
# Exporter stuff
require
Exporter
;
require
Exporter
;
...
@@ -47,14 +48,15 @@ our $pluginInfo = {
...
@@ -47,14 +48,15 @@ our $pluginInfo = {
User_get
=>
\
&get
,
User_get
=>
\
&get
,
};
};
# Module config
my
$config
;
## @internal
## @internal
# Initialize module
# Initialize module
sub
init
sub
init
{
{
my
$server
=
shift
;
my
$server
=
shift
;
my
$
confi
g
=
$server
->
{'
config
'};
my
$
scf
g
=
$server
->
{'
inifile
'};
# Enable support for database
# Enable support for database
...
@@ -62,9 +64,28 @@ sub init
...
@@ -62,9 +64,28 @@ sub init
$server
->
log
(
LOG_NOTICE
,"
[MOD_USERDB_SQL] Enabling database support.
");
$server
->
log
(
LOG_NOTICE
,"
[MOD_USERDB_SQL] Enabling database support.
");
$server
->
{'
smradius
'}
->
{'
database
'}
->
{'
enabled
'}
=
1
;
$server
->
{'
smradius
'}
->
{'
database
'}
->
{'
enabled
'}
=
1
;
}
}
}
#Default configs...
$config
->
{'
userdb_select_query
'}
=
'
SELECT
ID
FROM
@TP@users
WHERE
UserName = %{authentication.User-Name}
';
# Setup SQL queries
if
(
defined
(
$scfg
->
{'
mod_userdb_sql
'}))
{
# Pull in queries
if
(
defined
(
$scfg
->
{'
mod_userdb_sql
'}
->
{'
userdb_select_query
'})
&&
$scfg
->
{'
mod_userdb_sql
'}
->
{'
userdb_select_query
'}
ne
"")
{
$config
->
{'
userdb_select_query
'}
=
$scfg
->
{'
mod_userdb_sql
'}
->
{'
userdb_select_query
'};
}
}
}
## @find
## @find
# Try find a user
# Try find a user
...
@@ -78,6 +99,24 @@ sub find
...
@@ -78,6 +99,24 @@ sub find
{
{
my
(
$server
,
$user
,
$packet
)
=
@_
;
my
(
$server
,
$user
,
$packet
)
=
@_
;
# Build template
my
$template
;
$server
->
log
(
LOG_DEBUG
,"
[MOD_USERDB_SQL] Find function called
");
foreach
my
$attr
(
$packet
->
attributes
)
{
$template
->
{'
authentication
'}
->
{
$attr
}
=
$packet
->
rawattr
(
$attr
)
}
$template
->
{'
user
'}
=
$user
;
# Replace template entries
my
@dbDoParams
=
templateReplace
(
$config
->
{'
userdb_select_query
'},
$template
);
my
$sth
=
DBSelect
(
@dbDoParams
);
if
(
!
$sth
)
{
$server
->
log
(
LOG_ERR
,"
Failed to find user data:
"
.
smradius::dblayer::
Error
());
return
-
1
;
}
$server
->
log
(
LOG_NOTICE
,"
Number of rows :
"
.
$sth
->
rows
());
# TODO: Query database and see if this user exists
# TODO: Query database and see if this user exists
...
...
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