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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
6bddb93e
Commit
6bddb93e
authored
Oct 17, 2013
by
Vicențiu Ciorbaru
Committed by
Sergei Golubchik
Oct 17, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented half of handle_roles_mappings_table.
The function now handles user updates/deletions correctly.
parent
13a1f6fd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
1 deletion
+69
-1
sql/sql_acl.cc
sql/sql_acl.cc
+69
-1
No files found.
sql/sql_acl.cc
View file @
6bddb93e
...
...
@@ -6230,11 +6230,79 @@ static int modify_grant_table(TABLE *table, Field *host_field,
DBUG_RETURN
(
error
);
}
/*
Handle the roles_mappings privilege table
*/
static
int
handle_roles_mappings_table
(
TABLE
*
table
,
bool
drop
,
LEX_USER
*
user_from
,
LEX_USER
*
user_to
)
{
/*
First we need to find out if the user_from represents a user, or a role.
If the user_from has a hostname different than '' it can not be a user.
If the user_from has an empty hostname, it _could_ be a role, but it is
not mandatory.
In this case perform a quick lookup in acl_roles to see if
it is already there. If it is not found, than the user fields are updated,
otherwise the role field gets updated.
*/
DBUG_ENTER
(
"handle_roles_mappings_table"
);
int
error
;
int
result
=
0
;
bool
is_role
=
FALSE
;
THD
*
thd
=
current_thd
;
char
*
host
,
*
user
;
Field
*
host_field
=
table
->
field
[
0
];
Field
*
user_field
=
table
->
field
[
1
];
Field
*
role_field
=
table
->
field
[
2
];
if
(
!
user_from
->
host
.
length
&&
find_acl_role
(
user_from
->
user
.
str
))
{
is_role
=
TRUE
;
}
table
->
use_all_columns
();
if
(
!
is_role
)
{
if
((
error
=
table
->
file
->
ha_rnd_init
(
1
)))
{
table
->
file
->
print_error
(
error
,
MYF
(
0
));
result
=
-
1
;
}
else
{
while
((
error
=
table
->
file
->
ha_rnd_next
(
table
->
record
[
0
]))
!=
HA_ERR_END_OF_FILE
)
{
if
(
error
)
{
DBUG_PRINT
(
"info"
,
(
"scan error: %d"
,
error
));
continue
;
}
if
(
!
(
host
=
get_field
(
thd
->
mem_root
,
host_field
)))
host
=
""
;
if
(
!
(
user
=
get_field
(
thd
->
mem_root
,
user_field
)))
user
=
""
;
if
(
strcmp
(
user_from
->
user
.
str
,
user
)
||
my_strcasecmp
(
system_charset_info
,
user_from
->
host
.
str
,
host
))
continue
;
result
=
((
drop
||
user_to
)
&&
modify_grant_table
(
table
,
host_field
,
user_field
,
user_to
))
?
-
1
:
result
?
result
:
1
;
/* Error or keep result or found. */
}
table
->
file
->
ha_rnd_end
();
}
}
/* TODO */
return
0
;
DBUG_RETURN
(
result
)
;
}
/*
Handle a privilege table.
...
...
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