Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
d14c4c78
Commit
d14c4c78
authored
Jan 24, 2016
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: move all password validation logic into one function
parent
d5b1b1ac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
31 deletions
+33
-31
sql/sql_acl.cc
sql/sql_acl.cc
+33
-31
No files found.
sql/sql_acl.cc
View file @
d14c4c78
...
...
@@ -874,6 +874,17 @@ static void free_acl_role(ACL_ROLE *role)
delete_dynamic
(
&
(
role
->
parent_grantee
));
}
static
my_bool
check_if_exists
(
THD
*
,
plugin_ref
,
void
*
)
{
return
TRUE
;
}
static
bool
has_validation_plugins
()
{
return
plugin_foreach
(
NULL
,
check_if_exists
,
MariaDB_PASSWORD_VALIDATION_PLUGIN
,
NULL
);
}
struct
validation_data
{
LEX_STRING
*
user
,
*
password
;
};
static
my_bool
do_validate
(
THD
*
,
plugin_ref
plugin
,
void
*
arg
)
...
...
@@ -885,22 +896,27 @@ static my_bool do_validate(THD *, plugin_ref plugin, void *arg)
}
static
bool
validate_password
(
LEX_
STRING
*
user
,
LEX_STRING
*
password
)
static
bool
validate_password
(
LEX_
USER
*
user
)
{
struct
validation_data
data
=
{
user
,
password
};
return
plugin_foreach
(
NULL
,
do_validate
,
MariaDB_PASSWORD_VALIDATION_PLUGIN
,
&
data
);
}
static
my_bool
check_if_exists
(
THD
*
,
plugin_ref
,
void
*
)
{
return
TRUE
;
}
static
bool
has_validation_plugins
()
{
return
plugin_foreach
(
NULL
,
check_if_exists
,
MariaDB_PASSWORD_VALIDATION_PLUGIN
,
NULL
);
if
(
user
->
pwtext
.
length
||
!
user
->
pwhash
.
length
)
{
struct
validation_data
data
=
{
&
user
->
user
,
&
user
->
pwtext
};
if
(
plugin_foreach
(
NULL
,
do_validate
,
MariaDB_PASSWORD_VALIDATION_PLUGIN
,
&
data
))
{
my_error
(
ER_NOT_VALID_PASSWORD
,
MYF
(
0
));
return
true
;
}
}
else
{
if
(
strict_password_validation
&&
has_validation_plugins
())
{
my_error
(
ER_OPTION_PREVENTS_STATEMENT
,
MYF
(
0
),
"--strict-password-validation"
);
return
true
;
}
}
return
false
;
}
/**
...
...
@@ -1034,22 +1050,8 @@ static bool fix_lex_user(THD *thd, LEX_USER *user)
return
true
;
}
if
(
user
->
pwtext
.
length
||
!
user
->
pwhash
.
length
)
{
if
(
validate_password
(
&
user
->
user
,
&
user
->
pwtext
))
{
my_error
(
ER_NOT_VALID_PASSWORD
,
MYF
(
0
));
return
true
;
}
}
else
{
if
(
strict_password_validation
&&
has_validation_plugins
())
{
my_error
(
ER_OPTION_PREVENTS_STATEMENT
,
MYF
(
0
),
"--strict-password-validation"
);
return
true
;
}
}
if
(
validate_password
(
user
))
return
true
;
if
(
user
->
pwtext
.
length
&&
!
user
->
pwhash
.
length
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment