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
834e9b12
Commit
834e9b12
authored
Nov 26, 2021
by
Vicențiu Ciorbaru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: move computation of acl_cache key to separate function
parent
dcbe9976
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
13 deletions
+26
-13
sql/sql_acl.cc
sql/sql_acl.cc
+26
-13
No files found.
sql/sql_acl.cc
View file @
834e9b12
...
@@ -4424,6 +4424,29 @@ static void acl_insert_db(const char *user, const char *host, const char *db,
...
@@ -4424,6 +4424,29 @@ static void acl_insert_db(const char *user, const char *host, const char *db,
}
}
static
bool
compute_acl_cache_key
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
db
,
char
*
key
,
size_t
max_key_length
,
size_t
*
key_length
)
{
char
*
end
,
*
tmp_db
;
tmp_db
=
strmov
(
strmov
(
key
,
safe_str
(
ip
))
+
1
,
user
)
+
1
;
end
=
strnmov
(
tmp_db
,
db
,
key
+
max_key_length
-
tmp_db
);
if
(
end
>=
key
+
max_key_length
)
// db name was truncated
return
true
;
if
(
lower_case_table_names
)
{
my_casedn_str
(
files_charset_info
,
tmp_db
);
db
=
tmp_db
;
}
*
key_length
=
(
size_t
)
(
end
-
key
);
return
false
;
}
/*
/*
Get privilege for a host, user and db combination
Get privilege for a host, user and db combination
...
@@ -4437,22 +4460,12 @@ privilege_t acl_get(const char *host, const char *ip,
...
@@ -4437,22 +4460,12 @@ privilege_t acl_get(const char *host, const char *ip,
privilege_t
host_access
(
ALL_KNOWN_ACL
),
db_access
(
NO_ACL
);
privilege_t
host_access
(
ALL_KNOWN_ACL
),
db_access
(
NO_ACL
);
uint
i
;
uint
i
;
size_t
key_length
;
size_t
key_length
;
char
key
[
ACL_KEY_LENGTH
]
,
*
tmp_db
,
*
end
;
char
key
[
ACL_KEY_LENGTH
];
acl_entry
*
entry
;
acl_entry
*
entry
;
DBUG_ENTER
(
"acl_get"
);
DBUG_ENTER
(
"acl_get"
);
tmp_db
=
strmov
(
strmov
(
key
,
safe_str
(
ip
))
+
1
,
user
)
+
1
;
if
(
compute_acl_cache_key
(
ip
,
user
,
db
,
key
,
sizeof
(
key
),
&
key_length
))
end
=
strnmov
(
tmp_db
,
db
,
key
+
sizeof
(
key
)
-
tmp_db
);
DBUG_RETURN
(
NO_ACL
);
// No rights for invalid db name.
if
(
end
>=
key
+
sizeof
(
key
))
// db name was truncated
DBUG_RETURN
(
NO_ACL
);
// no privileges for an invalid db name
if
(
lower_case_table_names
)
{
my_casedn_str
(
files_charset_info
,
tmp_db
);
db
=
tmp_db
;
}
key_length
=
(
size_t
)
(
end
-
key
);
mysql_mutex_lock
(
&
acl_cache
->
lock
);
mysql_mutex_lock
(
&
acl_cache
->
lock
);
if
(
!
db_is_pattern
&&
(
entry
=
acl_cache
->
search
((
uchar
*
)
key
,
key_length
)))
if
(
!
db_is_pattern
&&
(
entry
=
acl_cache
->
search
((
uchar
*
)
key
,
key_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