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
f8d944a6
Commit
f8d944a6
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
Added a init_role_mapping function to be used for later
parent
573c7322
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
sql/sql_acl.cc
sql/sql_acl.cc
+38
-0
No files found.
sql/sql_acl.cc
View file @
f8d944a6
...
...
@@ -549,6 +549,44 @@ static uchar* acl_role_map_get_key(ROLE_GRANT_PAIR *entry, size_t *length,
return
(
uchar
*
)
entry
->
hashkey
.
str
;
}
static
void
init_role_grant_pair
(
MEM_ROOT
*
mem
,
ROLE_GRANT_PAIR
*
entry
,
char
*
username
,
char
*
hostname
,
char
*
rolename
)
{
size_t
len
[
3
]
=
{
username
?
strlen
(
username
)
:
0
,
hostname
?
strlen
(
hostname
)
:
0
,
rolename
?
strlen
(
rolename
)
:
0
};
/*
Create a buffer that holds all 3 NULL terminated strings in succession
To save memory space, the same buffer is used as the hashkey
*/
size_t
bufflen
=
len
[
0
]
+
len
[
1
]
+
len
[
2
]
+
3
;
//add the '\0' aswell
char
*
buff
=
(
char
*
)
alloc_root
(
mem
,
bufflen
);
/*
Offsets in the buffer for all 3 strings
*/
char
*
username_pos
=
buff
;
char
*
hostname_pos
=
buff
+
len
[
0
]
+
1
;
char
*
rolename_pos
=
buff
+
len
[
0
]
+
len
[
1
]
+
2
;
if
(
username
)
memcpy
(
username_pos
,
username
,
len
[
0
]);
username_pos
[
len
[
0
]]
=
'\0'
;
//#1 string terminator
entry
->
u_uname
=
username_pos
;
if
(
hostname
)
memcpy
(
hostname_pos
,
hostname
,
len
[
1
]);
hostname_pos
[
len
[
1
]]
=
'\0'
;
//#2 string terminator
entry
->
u_hname
=
hostname_pos
;
if
(
rolename
)
memcpy
(
rolename_pos
,
rolename
,
len
[
2
]);
rolename_pos
[
len
[
2
]]
=
'\0'
;
//#3 string terminator
entry
->
r_uname
=
rolename_pos
;
entry
->
hashkey
.
str
=
buff
;
entry
->
hashkey
.
length
=
bufflen
;
}
#define IP_ADDR_STRLEN (3 + 1 + 3 + 1 + 3 + 1 + 3)
#define ACL_KEY_LENGTH (IP_ADDR_STRLEN + 1 + NAME_LEN + \
1 + USERNAME_LENGTH + 1)
...
...
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