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
bcd1520a
Commit
bcd1520a
authored
Jan 06, 2022
by
Vicențiu Ciorbaru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: check_grant_db doesn't need THD as parameter, only Security_ctx
parent
d6370cb5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
15 deletions
+12
-15
sql/sql_acl.cc
sql/sql_acl.cc
+7
-10
sql/sql_acl.h
sql/sql_acl.h
+1
-1
sql/sql_db.cc
sql/sql_db.cc
+1
-1
sql/sql_show.cc
sql/sql_show.cc
+3
-3
No files found.
sql/sql_acl.cc
View file @
bcd1520a
...
...
@@ -3347,7 +3347,7 @@ static bool check_show_access(THD *thd, TABLE_LIST *table)
&
thd
->
col_access
,
NULL
,
FALSE
,
FALSE
))
return
TRUE
;
if
(
!
thd
->
col_access
&&
check_grant_db
(
thd
,
dst_db_name
))
if
(
!
thd
->
col_access
&&
check_grant_db
(
thd
->
security_ctx
,
dst_db_name
))
{
status_var_increment
(
thd
->
status_var
.
access_denied_errors
);
my_error
(
ER_DBACCESS_DENIED_ERROR
,
MYF
(
0
),
...
...
@@ -9561,10 +9561,8 @@ bool check_grant_all_columns(THD *thd, privilege_t want_access_arg,
}
static
bool
check_grant_db_routine
(
THD
*
thd
,
const
char
*
db
,
HASH
*
hash
)
static
bool
check_grant_db_routine
(
Security_context
*
sctx
,
const
char
*
db
,
HASH
*
hash
)
{
Security_context
*
sctx
=
thd
->
security_ctx
;
for
(
uint
idx
=
0
;
idx
<
hash
->
records
;
++
idx
)
{
GRANT_NAME
*
item
=
(
GRANT_NAME
*
)
my_hash_element
(
hash
,
idx
);
...
...
@@ -9593,9 +9591,8 @@ static bool check_grant_db_routine(THD *thd, const char *db, HASH *hash)
Return 1 if access is denied
*/
bool
check_grant_db
(
THD
*
thd
,
const
char
*
db
)
bool
check_grant_db
(
Security_context
*
sctx
,
const
char
*
db
)
{
Security_context
*
sctx
=
thd
->
security_ctx
;
char
helping
[
SAFE_NAME_LEN
+
USERNAME_LENGTH
+
2
],
*
end
;
char
helping2
[
SAFE_NAME_LEN
+
USERNAME_LENGTH
+
2
],
*
tmp_db
;
uint
len
,
UNINIT_VAR
(
len2
);
...
...
@@ -9650,10 +9647,10 @@ bool check_grant_db(THD *thd, const char *db)
}
if
(
error
)
error
=
check_grant_db_routine
(
thd
,
db
,
&
proc_priv_hash
)
&&
check_grant_db_routine
(
thd
,
db
,
&
func_priv_hash
)
&&
check_grant_db_routine
(
thd
,
db
,
&
package_spec_priv_hash
)
&&
check_grant_db_routine
(
thd
,
db
,
&
package_body_priv_hash
);
error
=
check_grant_db_routine
(
sctx
,
db
,
&
proc_priv_hash
)
&&
check_grant_db_routine
(
sctx
,
db
,
&
func_priv_hash
)
&&
check_grant_db_routine
(
sctx
,
db
,
&
package_spec_priv_hash
)
&&
check_grant_db_routine
(
sctx
,
db
,
&
package_body_priv_hash
);
mysql_rwlock_unlock
(
&
LOCK_grant
);
...
...
sql/sql_acl.h
View file @
bcd1520a
...
...
@@ -100,7 +100,7 @@ bool check_column_grant_in_table_ref(THD *thd, TABLE_LIST * table_ref,
const
char
*
name
,
size_t
length
,
Field
*
fld
);
bool
check_grant_all_columns
(
THD
*
thd
,
privilege_t
want_access
,
Field_iterator_table_ref
*
fields
);
bool
check_grant_db
(
THD
*
thd
,
const
char
*
db
);
bool
check_grant_db
(
Security_context
*
sctx
,
const
char
*
db
);
bool
check_fk_parent_table_access
(
THD
*
thd
,
HA_CREATE_INFO
*
create_info
,
Alter_info
*
alter_info
,
...
...
sql/sql_db.cc
View file @
bcd1520a
...
...
@@ -1789,7 +1789,7 @@ uint mysql_change_db(THD *thd, const LEX_CSTRING *new_db_name,
if
(
!
force_switch
&&
!
(
db_access
&
DB_ACLS
)
&&
check_grant_db
(
thd
,
new_db_file_name
.
str
))
check_grant_db
(
thd
->
security_ctx
,
new_db_file_name
.
str
))
{
my_error
(
ER_DBACCESS_DENIED_ERROR
,
MYF
(
0
),
sctx
->
priv_user
,
...
...
sql/sql_show.cc
View file @
bcd1520a
...
...
@@ -1409,7 +1409,7 @@ bool mysqld_show_create_db(THD *thd, LEX_CSTRING *dbname,
db_access
=
acl_get_all3
(
sctx
,
dbname
->
str
,
FALSE
)
|
sctx
->
master_access
;
if
(
!
(
db_access
&
DB_ACLS
)
&&
check_grant_db
(
thd
,
dbname
->
str
))
if
(
!
(
db_access
&
DB_ACLS
)
&&
check_grant_db
(
sctx
,
dbname
->
str
))
{
status_var_increment
(
thd
->
status_var
.
access_denied_errors
);
my_error
(
ER_DBACCESS_DENIED_ERROR
,
MYF
(
0
),
...
...
@@ -5314,7 +5314,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if
(
!
(
check_access
(
thd
,
SELECT_ACL
,
db_name
->
str
,
&
thd
->
col_access
,
NULL
,
0
,
1
)
||
(
!
thd
->
col_access
&&
check_grant_db
(
thd
,
db_name
->
str
)))
||
(
!
thd
->
col_access
&&
check_grant_db
(
sctx
,
db_name
->
str
)))
||
sctx
->
master_access
&
(
DB_ACLS
|
SHOW_DB_ACL
)
||
acl_get_all3
(
sctx
,
db_name
->
str
,
false
))
#endif
...
...
@@ -5517,7 +5517,7 @@ int fill_schema_schemata(THD *thd, TABLE_LIST *tables, COND *cond)
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if
(
sctx
->
master_access
&
(
DB_ACLS
|
SHOW_DB_ACL
)
||
acl_get_all3
(
sctx
,
db_name
->
str
,
false
)
||
!
check_grant_db
(
thd
,
db_name
->
str
))
!
check_grant_db
(
sctx
,
db_name
->
str
))
#endif
{
load_db_opt_by_name
(
thd
,
db_name
->
str
,
&
create
);
...
...
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