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
0499b301
Commit
0499b301
authored
May 11, 2006
by
kroki@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql.com:/home/tomash/src/mysql_ab/tmp_merge
into mysql.com:/home/tomash/src/mysql_ab/mysql-5.1-merge
parents
14a6cace
f6c95ee8
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
141 additions
and
50 deletions
+141
-50
mysql-test/r/func_misc.result
mysql-test/r/func_misc.result
+36
-0
mysql-test/t/func_misc.test
mysql-test/t/func_misc.test
+40
-0
sql/item_func.cc
sql/item_func.cc
+2
-0
sql/sql_acl.cc
sql/sql_acl.cc
+61
-47
sql/sql_acl.h
sql/sql_acl.h
+0
-1
sql/sql_parse.cc
sql/sql_parse.cc
+2
-2
No files found.
mysql-test/r/func_misc.result
View file @
0499b301
...
@@ -51,6 +51,42 @@ select a from t1 where mid(a+0,6,3) = ( mid(20040106123400,6,3) );
...
@@ -51,6 +51,42 @@ select a from t1 where mid(a+0,6,3) = ( mid(20040106123400,6,3) );
a
a
2004-01-06 12:34:00
2004-01-06 12:34:00
drop table t1;
drop table t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (conn CHAR(7), connection_id INT);
INSERT INTO t1 VALUES ('default', CONNECTION_ID());
SELECT GET_LOCK('bug16501',600);
GET_LOCK('bug16501',600)
1
INSERT INTO t1 VALUES ('con1', CONNECTION_ID());
SELECT IS_USED_LOCK('bug16501') = connection_id
FROM t1
WHERE conn = 'default';
IS_USED_LOCK('bug16501') = connection_id
1
SELECT GET_LOCK('bug16501',600);
SELECT IS_USED_LOCK('bug16501') = CONNECTION_ID();
IS_USED_LOCK('bug16501') = CONNECTION_ID()
1
SELECT RELEASE_LOCK('bug16501');
RELEASE_LOCK('bug16501')
1
GET_LOCK('bug16501',600)
1
SELECT IS_USED_LOCK('bug16501') = connection_id
FROM t1
WHERE conn = 'con1';
IS_USED_LOCK('bug16501') = connection_id
1
SELECT IS_USED_LOCK('bug16501') = CONNECTION_ID();
IS_USED_LOCK('bug16501') = CONNECTION_ID()
1
SELECT RELEASE_LOCK('bug16501');
RELEASE_LOCK('bug16501')
1
SELECT IS_USED_LOCK('bug16501');
IS_USED_LOCK('bug16501')
NULL
DROP TABLE t1;
create table t1 as select uuid(), length(uuid());
create table t1 as select uuid(), length(uuid());
show create table t1;
show create table t1;
Table Create Table
Table Create Table
...
...
mysql-test/t/func_misc.test
View file @
0499b301
...
@@ -38,6 +38,46 @@ select a from t1 where mid(a+0,6,3) = ( mid(20040106123400,6,3) );
...
@@ -38,6 +38,46 @@ select a from t1 where mid(a+0,6,3) = ( mid(20040106123400,6,3) );
drop
table
t1
;
drop
table
t1
;
#
# Bug#16501: IS_USED_LOCK does not appear to work
#
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
;
--
enable_warnings
CREATE
TABLE
t1
(
conn
CHAR
(
7
),
connection_id
INT
);
INSERT
INTO
t1
VALUES
(
'default'
,
CONNECTION_ID
());
SELECT
GET_LOCK
(
'bug16501'
,
600
);
connect
(
con1
,
localhost
,
root
,,);
INSERT
INTO
t1
VALUES
(
'con1'
,
CONNECTION_ID
());
SELECT
IS_USED_LOCK
(
'bug16501'
)
=
connection_id
FROM
t1
WHERE
conn
=
'default'
;
send
SELECT
GET_LOCK
(
'bug16501'
,
600
);
connection
default
;
SELECT
IS_USED_LOCK
(
'bug16501'
)
=
CONNECTION_ID
();
SELECT
RELEASE_LOCK
(
'bug16501'
);
connection
con1
;
reap
;
connection
default
;
SELECT
IS_USED_LOCK
(
'bug16501'
)
=
connection_id
FROM
t1
WHERE
conn
=
'con1'
;
connection
con1
;
SELECT
IS_USED_LOCK
(
'bug16501'
)
=
CONNECTION_ID
();
SELECT
RELEASE_LOCK
(
'bug16501'
);
SELECT
IS_USED_LOCK
(
'bug16501'
);
disconnect
con1
;
connection
default
;
DROP
TABLE
t1
;
# End of 4.1 tests
# End of 4.1 tests
#
#
...
...
sql/item_func.cc
View file @
0499b301
...
@@ -3013,6 +3013,7 @@ void item_user_lock_free(void)
...
@@ -3013,6 +3013,7 @@ void item_user_lock_free(void)
void
item_user_lock_release
(
User_level_lock
*
ull
)
void
item_user_lock_release
(
User_level_lock
*
ull
)
{
{
ull
->
locked
=
0
;
ull
->
locked
=
0
;
ull
->
thread_id
=
0
;
if
(
--
ull
->
count
)
if
(
--
ull
->
count
)
pthread_cond_signal
(
&
ull
->
cond
);
pthread_cond_signal
(
&
ull
->
cond
);
else
else
...
@@ -3220,6 +3221,7 @@ longlong Item_func_get_lock::val_int()
...
@@ -3220,6 +3221,7 @@ longlong Item_func_get_lock::val_int()
{
{
ull
->
locked
=
1
;
ull
->
locked
=
1
;
ull
->
thread
=
thd
->
real_id
;
ull
->
thread
=
thd
->
real_id
;
ull
->
thread_id
=
thd
->
thread_id
;
thd
->
ull
=
ull
;
thd
->
ull
=
ull
;
error
=
0
;
error
=
0
;
}
}
...
...
sql/sql_acl.cc
View file @
0499b301
...
@@ -1156,6 +1156,8 @@ static void acl_update_user(const char *user, const char *host,
...
@@ -1156,6 +1156,8 @@ static void acl_update_user(const char *user, const char *host,
USER_RESOURCES
*
mqh
,
USER_RESOURCES
*
mqh
,
ulong
privileges
)
ulong
privileges
)
{
{
safe_mutex_assert_owner
(
&
acl_cache
->
lock
);
for
(
uint
i
=
0
;
i
<
acl_users
.
elements
;
i
++
)
for
(
uint
i
=
0
;
i
<
acl_users
.
elements
;
i
++
)
{
{
ACL_USER
*
acl_user
=
dynamic_element
(
&
acl_users
,
i
,
ACL_USER
*
);
ACL_USER
*
acl_user
=
dynamic_element
(
&
acl_users
,
i
,
ACL_USER
*
);
...
@@ -1206,6 +1208,9 @@ static void acl_insert_user(const char *user, const char *host,
...
@@ -1206,6 +1208,9 @@ static void acl_insert_user(const char *user, const char *host,
ulong
privileges
)
ulong
privileges
)
{
{
ACL_USER
acl_user
;
ACL_USER
acl_user
;
safe_mutex_assert_owner
(
&
acl_cache
->
lock
);
acl_user
.
user
=*
user
?
strdup_root
(
&
mem
,
user
)
:
0
;
acl_user
.
user
=*
user
?
strdup_root
(
&
mem
,
user
)
:
0
;
update_hostname
(
&
acl_user
.
host
,
*
host
?
strdup_root
(
&
mem
,
host
)
:
0
);
update_hostname
(
&
acl_user
.
host
,
*
host
?
strdup_root
(
&
mem
,
host
)
:
0
);
acl_user
.
access
=
privileges
;
acl_user
.
access
=
privileges
;
...
@@ -1235,6 +1240,8 @@ static void acl_insert_user(const char *user, const char *host,
...
@@ -1235,6 +1240,8 @@ static void acl_insert_user(const char *user, const char *host,
static
void
acl_update_db
(
const
char
*
user
,
const
char
*
host
,
const
char
*
db
,
static
void
acl_update_db
(
const
char
*
user
,
const
char
*
host
,
const
char
*
db
,
ulong
privileges
)
ulong
privileges
)
{
{
safe_mutex_assert_owner
(
&
acl_cache
->
lock
);
for
(
uint
i
=
0
;
i
<
acl_dbs
.
elements
;
i
++
)
for
(
uint
i
=
0
;
i
<
acl_dbs
.
elements
;
i
++
)
{
{
ACL_DB
*
acl_db
=
dynamic_element
(
&
acl_dbs
,
i
,
ACL_DB
*
);
ACL_DB
*
acl_db
=
dynamic_element
(
&
acl_dbs
,
i
,
ACL_DB
*
);
...
@@ -1660,6 +1667,9 @@ find_acl_user(const char *host, const char *user, my_bool exact)
...
@@ -1660,6 +1667,9 @@ find_acl_user(const char *host, const char *user, my_bool exact)
{
{
DBUG_ENTER
(
"find_acl_user"
);
DBUG_ENTER
(
"find_acl_user"
);
DBUG_PRINT
(
"enter"
,(
"host: '%s' user: '%s'"
,
host
,
user
));
DBUG_PRINT
(
"enter"
,(
"host: '%s' user: '%s'"
,
host
,
user
));
safe_mutex_assert_owner
(
&
acl_cache
->
lock
);
for
(
uint
i
=
0
;
i
<
acl_users
.
elements
;
i
++
)
for
(
uint
i
=
0
;
i
<
acl_users
.
elements
;
i
++
)
{
{
ACL_USER
*
acl_user
=
dynamic_element
(
&
acl_users
,
i
,
ACL_USER
*
);
ACL_USER
*
acl_user
=
dynamic_element
(
&
acl_users
,
i
,
ACL_USER
*
);
...
@@ -1672,7 +1682,7 @@ find_acl_user(const char *host, const char *user, my_bool exact)
...
@@ -1672,7 +1682,7 @@ find_acl_user(const char *host, const char *user, my_bool exact)
if
(
!
acl_user
->
user
&&
!
user
[
0
]
||
if
(
!
acl_user
->
user
&&
!
user
[
0
]
||
acl_user
->
user
&&
!
strcmp
(
user
,
acl_user
->
user
))
acl_user
->
user
&&
!
strcmp
(
user
,
acl_user
->
user
))
{
{
if
(
exact
?
!
my_strcasecmp
(
&
my_charset_latin1
,
host
,
if
(
exact
?
!
my_strcasecmp
(
system_charset_info
,
host
,
acl_user
->
host
.
hostname
?
acl_user
->
host
.
hostname
?
acl_user
->
host
.
hostname
:
""
)
:
acl_user
->
host
.
hostname
:
""
)
:
compare_hostname
(
&
acl_user
->
host
,
host
,
host
))
compare_hostname
(
&
acl_user
->
host
,
host
,
host
))
...
@@ -2999,6 +3009,7 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list,
...
@@ -2999,6 +3009,7 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list,
create_new_users
=
test_if_create_new_users
(
thd
);
create_new_users
=
test_if_create_new_users
(
thd
);
bool
result
=
FALSE
;
bool
result
=
FALSE
;
rw_wrlock
(
&
LOCK_grant
);
rw_wrlock
(
&
LOCK_grant
);
pthread_mutex_lock
(
&
acl_cache
->
lock
);
MEM_ROOT
*
old_root
=
thd
->
mem_root
;
MEM_ROOT
*
old_root
=
thd
->
mem_root
;
thd
->
mem_root
=
&
memex
;
thd
->
mem_root
=
&
memex
;
grant_version
++
;
grant_version
++
;
...
@@ -3016,12 +3027,10 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list,
...
@@ -3016,12 +3027,10 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list,
continue
;
continue
;
}
}
/* Create user if needed */
/* Create user if needed */
pthread_mutex_lock
(
&
acl_cache
->
lock
);
error
=
replace_user_table
(
thd
,
tables
[
0
].
table
,
*
Str
,
error
=
replace_user_table
(
thd
,
tables
[
0
].
table
,
*
Str
,
0
,
revoke_grant
,
create_new_users
,
0
,
revoke_grant
,
create_new_users
,
test
(
thd
->
variables
.
sql_mode
&
test
(
thd
->
variables
.
sql_mode
&
MODE_NO_AUTO_CREATE_USER
));
MODE_NO_AUTO_CREATE_USER
));
pthread_mutex_unlock
(
&
acl_cache
->
lock
);
if
(
error
)
if
(
error
)
{
{
result
=
TRUE
;
// Remember error
result
=
TRUE
;
// Remember error
...
@@ -3113,6 +3122,7 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list,
...
@@ -3113,6 +3122,7 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list,
}
}
grant_option
=
TRUE
;
grant_option
=
TRUE
;
thd
->
mem_root
=
old_root
;
thd
->
mem_root
=
old_root
;
pthread_mutex_unlock
(
&
acl_cache
->
lock
);
rw_unlock
(
&
LOCK_grant
);
rw_unlock
(
&
LOCK_grant
);
if
(
!
result
)
if
(
!
result
)
send_ok
(
thd
);
send_ok
(
thd
);
...
@@ -3205,6 +3215,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc,
...
@@ -3205,6 +3215,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc,
if
(
!
revoke_grant
)
if
(
!
revoke_grant
)
create_new_users
=
test_if_create_new_users
(
thd
);
create_new_users
=
test_if_create_new_users
(
thd
);
rw_wrlock
(
&
LOCK_grant
);
rw_wrlock
(
&
LOCK_grant
);
pthread_mutex_lock
(
&
acl_cache
->
lock
);
MEM_ROOT
*
old_root
=
thd
->
mem_root
;
MEM_ROOT
*
old_root
=
thd
->
mem_root
;
thd
->
mem_root
=
&
memex
;
thd
->
mem_root
=
&
memex
;
...
@@ -3224,12 +3235,10 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc,
...
@@ -3224,12 +3235,10 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc,
continue
;
continue
;
}
}
/* Create user if needed */
/* Create user if needed */
pthread_mutex_lock
(
&
acl_cache
->
lock
);
error
=
replace_user_table
(
thd
,
tables
[
0
].
table
,
*
Str
,
error
=
replace_user_table
(
thd
,
tables
[
0
].
table
,
*
Str
,
0
,
revoke_grant
,
create_new_users
,
0
,
revoke_grant
,
create_new_users
,
test
(
thd
->
variables
.
sql_mode
&
test
(
thd
->
variables
.
sql_mode
&
MODE_NO_AUTO_CREATE_USER
));
MODE_NO_AUTO_CREATE_USER
));
pthread_mutex_unlock
(
&
acl_cache
->
lock
);
if
(
error
)
if
(
error
)
{
{
result
=
TRUE
;
// Remember error
result
=
TRUE
;
// Remember error
...
@@ -3271,6 +3280,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc,
...
@@ -3271,6 +3280,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc,
}
}
grant_option
=
TRUE
;
grant_option
=
TRUE
;
thd
->
mem_root
=
old_root
;
thd
->
mem_root
=
old_root
;
pthread_mutex_unlock
(
&
acl_cache
->
lock
);
rw_unlock
(
&
LOCK_grant
);
rw_unlock
(
&
LOCK_grant
);
if
(
!
result
&&
!
no_error
)
if
(
!
result
&&
!
no_error
)
send_ok
(
thd
);
send_ok
(
thd
);
...
@@ -4247,20 +4257,15 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user)
...
@@ -4247,20 +4257,15 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user)
DBUG_RETURN
(
TRUE
);
DBUG_RETURN
(
TRUE
);
}
}
for
(
counter
=
0
;
counter
<
acl_users
.
elements
;
counter
++
)
rw_rdlock
(
&
LOCK_grant
);
{
VOID
(
pthread_mutex_lock
(
&
acl_cache
->
lock
));
const
char
*
user
,
*
host
;
acl_user
=
dynamic_element
(
&
acl_users
,
counter
,
ACL_USER
*
);
acl_user
=
find_acl_user
(
lex_user
->
host
.
str
,
lex_user
->
user
.
str
,
TRUE
);
if
(
!
(
user
=
acl_user
->
user
))
if
(
!
acl_user
)
user
=
""
;
if
(
!
(
host
=
acl_user
->
host
.
hostname
))
host
=
""
;
if
(
!
strcmp
(
lex_user
->
user
.
str
,
user
)
&&
!
my_strcasecmp
(
system_charset_info
,
lex_user
->
host
.
str
,
host
))
break
;
}
if
(
counter
==
acl_users
.
elements
)
{
{
VOID
(
pthread_mutex_unlock
(
&
acl_cache
->
lock
));
rw_unlock
(
&
LOCK_grant
);
my_error
(
ER_NONEXISTING_GRANT
,
MYF
(
0
),
my_error
(
ER_NONEXISTING_GRANT
,
MYF
(
0
),
lex_user
->
user
.
str
,
lex_user
->
host
.
str
);
lex_user
->
user
.
str
,
lex_user
->
host
.
str
);
DBUG_RETURN
(
TRUE
);
DBUG_RETURN
(
TRUE
);
...
@@ -4275,10 +4280,12 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user)
...
@@ -4275,10 +4280,12 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user)
field_list
.
push_back
(
field
);
field_list
.
push_back
(
field
);
if
(
protocol
->
send_fields
(
&
field_list
,
if
(
protocol
->
send_fields
(
&
field_list
,
Protocol
::
SEND_NUM_ROWS
|
Protocol
::
SEND_EOF
))
Protocol
::
SEND_NUM_ROWS
|
Protocol
::
SEND_EOF
))
DBUG_RETURN
(
TRUE
);
{
VOID
(
pthread_mutex_unlock
(
&
acl_cache
->
lock
));
rw_unlock
(
&
LOCK_grant
);
rw_wrlock
(
&
LOCK_grant
);
DBUG_RETURN
(
TRUE
);
VOID
(
pthread_mutex_lock
(
&
acl_cache
->
lock
));
}
/* Add first global access grants */
/* Add first global access grants */
{
{
...
@@ -4686,10 +4693,15 @@ void get_privilege_desc(char *to, uint max_length, ulong access)
...
@@ -4686,10 +4693,15 @@ void get_privilege_desc(char *to, uint max_length, ulong access)
void
get_mqh
(
const
char
*
user
,
const
char
*
host
,
USER_CONN
*
uc
)
void
get_mqh
(
const
char
*
user
,
const
char
*
host
,
USER_CONN
*
uc
)
{
{
ACL_USER
*
acl_user
;
ACL_USER
*
acl_user
;
pthread_mutex_lock
(
&
acl_cache
->
lock
);
if
(
initialized
&&
(
acl_user
=
find_acl_user
(
host
,
user
,
FALSE
)))
if
(
initialized
&&
(
acl_user
=
find_acl_user
(
host
,
user
,
FALSE
)))
uc
->
user_resources
=
acl_user
->
user_resource
;
uc
->
user_resources
=
acl_user
->
user_resource
;
else
else
bzero
((
char
*
)
&
uc
->
user_resources
,
sizeof
(
uc
->
user_resources
));
bzero
((
char
*
)
&
uc
->
user_resources
,
sizeof
(
uc
->
user_resources
));
pthread_mutex_unlock
(
&
acl_cache
->
lock
);
}
}
/*
/*
...
@@ -4769,31 +4781,6 @@ int open_grant_tables(THD *thd, TABLE_LIST *tables)
...
@@ -4769,31 +4781,6 @@ int open_grant_tables(THD *thd, TABLE_LIST *tables)
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
ACL_USER
*
check_acl_user
(
LEX_USER
*
user_name
,
uint
*
acl_acl_userdx
)
{
ACL_USER
*
acl_user
=
0
;
uint
counter
;
for
(
counter
=
0
;
counter
<
acl_users
.
elements
;
counter
++
)
{
const
char
*
user
,
*
host
;
acl_user
=
dynamic_element
(
&
acl_users
,
counter
,
ACL_USER
*
);
if
(
!
(
user
=
acl_user
->
user
))
user
=
""
;
if
(
!
(
host
=
acl_user
->
host
.
hostname
))
host
=
""
;
if
(
!
strcmp
(
user_name
->
user
.
str
,
user
)
&&
!
my_strcasecmp
(
system_charset_info
,
user_name
->
host
.
str
,
host
))
break
;
}
if
(
counter
==
acl_users
.
elements
)
return
0
;
*
acl_acl_userdx
=
counter
;
return
acl_user
;
}
/*
/*
Modify a privilege table.
Modify a privilege table.
...
@@ -5040,6 +5027,8 @@ static int handle_grant_struct(uint struct_no, bool drop,
...
@@ -5040,6 +5027,8 @@ static int handle_grant_struct(uint struct_no, bool drop,
LINT_INIT
(
user
);
LINT_INIT
(
user
);
LINT_INIT
(
host
);
LINT_INIT
(
host
);
safe_mutex_assert_owner
(
&
acl_cache
->
lock
);
/* Get the number of elements in the in-memory structure. */
/* Get the number of elements in the in-memory structure. */
switch
(
struct_no
)
{
switch
(
struct_no
)
{
case
0
:
case
0
:
...
@@ -5502,7 +5491,7 @@ bool mysql_revoke_all(THD *thd, List <LEX_USER> &list)
...
@@ -5502,7 +5491,7 @@ bool mysql_revoke_all(THD *thd, List <LEX_USER> &list)
List_iterator
<
LEX_USER
>
user_list
(
list
);
List_iterator
<
LEX_USER
>
user_list
(
list
);
while
((
lex_user
=
user_list
++
))
while
((
lex_user
=
user_list
++
))
{
{
if
(
!
check_acl_user
(
lex_user
,
&
counter
))
if
(
!
find_acl_user
(
lex_user
->
host
.
str
,
lex_user
->
user
.
str
,
TRUE
))
{
{
sql_print_error
(
"REVOKE ALL PRIVILEGES, GRANT: User '%s'@'%s' does not "
sql_print_error
(
"REVOKE ALL PRIVILEGES, GRANT: User '%s'@'%s' does not "
"exists"
,
lex_user
->
user
.
str
,
lex_user
->
host
.
str
);
"exists"
,
lex_user
->
user
.
str
,
lex_user
->
host
.
str
);
...
@@ -5738,6 +5727,7 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
...
@@ -5738,6 +5727,7 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
combo
->
user
.
str
=
sctx
->
user
;
combo
->
user
.
str
=
sctx
->
user
;
VOID
(
pthread_mutex_lock
(
&
acl_cache
->
lock
));
if
(
!
find_acl_user
(
combo
->
host
.
str
=
(
char
*
)
sctx
->
host_or_ip
,
combo
->
user
.
str
,
if
(
!
find_acl_user
(
combo
->
host
.
str
=
(
char
*
)
sctx
->
host_or_ip
,
combo
->
user
.
str
,
FALSE
)
&&
FALSE
)
&&
!
find_acl_user
(
combo
->
host
.
str
=
(
char
*
)
sctx
->
host
,
combo
->
user
.
str
,
!
find_acl_user
(
combo
->
host
.
str
=
(
char
*
)
sctx
->
host
,
combo
->
user
.
str
,
...
@@ -5745,7 +5735,11 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
...
@@ -5745,7 +5735,11 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
!
find_acl_user
(
combo
->
host
.
str
=
(
char
*
)
sctx
->
ip
,
combo
->
user
.
str
,
!
find_acl_user
(
combo
->
host
.
str
=
(
char
*
)
sctx
->
ip
,
combo
->
user
.
str
,
FALSE
)
&&
FALSE
)
&&
!
find_acl_user
(
combo
->
host
.
str
=
(
char
*
)
"%"
,
combo
->
user
.
str
,
FALSE
))
!
find_acl_user
(
combo
->
host
.
str
=
(
char
*
)
"%"
,
combo
->
user
.
str
,
FALSE
))
{
VOID
(
pthread_mutex_unlock
(
&
acl_cache
->
lock
));
DBUG_RETURN
(
TRUE
);
DBUG_RETURN
(
TRUE
);
}
VOID
(
pthread_mutex_unlock
(
&
acl_cache
->
lock
));
bzero
((
char
*
)
tables
,
sizeof
(
TABLE_LIST
));
bzero
((
char
*
)
tables
,
sizeof
(
TABLE_LIST
));
user_list
.
empty
();
user_list
.
empty
();
...
@@ -5863,6 +5857,8 @@ int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
...
@@ -5863,6 +5857,8 @@ int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
char
*
curr_host
=
thd
->
security_ctx
->
priv_host_name
();
char
*
curr_host
=
thd
->
security_ctx
->
priv_host_name
();
DBUG_ENTER
(
"fill_schema_user_privileges"
);
DBUG_ENTER
(
"fill_schema_user_privileges"
);
pthread_mutex_lock
(
&
acl_cache
->
lock
);
for
(
counter
=
0
;
counter
<
acl_users
.
elements
;
counter
++
)
for
(
counter
=
0
;
counter
<
acl_users
.
elements
;
counter
++
)
{
{
const
char
*
user
,
*
host
,
*
is_grantable
=
"YES"
;
const
char
*
user
,
*
host
,
*
is_grantable
=
"YES"
;
...
@@ -5898,6 +5894,9 @@ int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
...
@@ -5898,6 +5894,9 @@ int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
}
}
}
}
}
}
pthread_mutex_unlock
(
&
acl_cache
->
lock
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
#else
#else
return
(
0
);
return
(
0
);
...
@@ -5917,6 +5916,8 @@ int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
...
@@ -5917,6 +5916,8 @@ int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
char
*
curr_host
=
thd
->
security_ctx
->
priv_host_name
();
char
*
curr_host
=
thd
->
security_ctx
->
priv_host_name
();
DBUG_ENTER
(
"fill_schema_schema_privileges"
);
DBUG_ENTER
(
"fill_schema_schema_privileges"
);
pthread_mutex_lock
(
&
acl_cache
->
lock
);
for
(
counter
=
0
;
counter
<
acl_dbs
.
elements
;
counter
++
)
for
(
counter
=
0
;
counter
<
acl_dbs
.
elements
;
counter
++
)
{
{
const
char
*
user
,
*
host
,
*
is_grantable
=
"YES"
;
const
char
*
user
,
*
host
,
*
is_grantable
=
"YES"
;
...
@@ -5955,6 +5956,9 @@ int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
...
@@ -5955,6 +5956,9 @@ int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
}
}
}
}
}
}
pthread_mutex_unlock
(
&
acl_cache
->
lock
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
#else
#else
return
(
0
);
return
(
0
);
...
@@ -5972,6 +5976,8 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
...
@@ -5972,6 +5976,8 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
char
*
curr_host
=
thd
->
security_ctx
->
priv_host_name
();
char
*
curr_host
=
thd
->
security_ctx
->
priv_host_name
();
DBUG_ENTER
(
"fill_schema_table_privileges"
);
DBUG_ENTER
(
"fill_schema_table_privileges"
);
rw_rdlock
(
&
LOCK_grant
);
for
(
index
=
0
;
index
<
column_priv_hash
.
records
;
index
++
)
for
(
index
=
0
;
index
<
column_priv_hash
.
records
;
index
++
)
{
{
const
char
*
user
,
*
is_grantable
=
"YES"
;
const
char
*
user
,
*
is_grantable
=
"YES"
;
...
@@ -6017,6 +6023,9 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
...
@@ -6017,6 +6023,9 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
}
}
}
}
}
}
rw_unlock
(
&
LOCK_grant
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
#else
#else
return
(
0
);
return
(
0
);
...
@@ -6034,6 +6043,8 @@ int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
...
@@ -6034,6 +6043,8 @@ int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
char
*
curr_host
=
thd
->
security_ctx
->
priv_host_name
();
char
*
curr_host
=
thd
->
security_ctx
->
priv_host_name
();
DBUG_ENTER
(
"fill_schema_table_privileges"
);
DBUG_ENTER
(
"fill_schema_table_privileges"
);
rw_rdlock
(
&
LOCK_grant
);
for
(
index
=
0
;
index
<
column_priv_hash
.
records
;
index
++
)
for
(
index
=
0
;
index
<
column_priv_hash
.
records
;
index
++
)
{
{
const
char
*
user
,
*
is_grantable
=
"YES"
;
const
char
*
user
,
*
is_grantable
=
"YES"
;
...
@@ -6085,6 +6096,9 @@ int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
...
@@ -6085,6 +6096,9 @@ int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
}
}
}
}
}
}
rw_unlock
(
&
LOCK_grant
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
#else
#else
return
(
0
);
return
(
0
);
...
...
sql/sql_acl.h
View file @
0499b301
...
@@ -236,7 +236,6 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table, List <LEX_USER> &user_list,
...
@@ -236,7 +236,6 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table, List <LEX_USER> &user_list,
bool
mysql_routine_grant
(
THD
*
thd
,
TABLE_LIST
*
table
,
bool
is_proc
,
bool
mysql_routine_grant
(
THD
*
thd
,
TABLE_LIST
*
table
,
bool
is_proc
,
List
<
LEX_USER
>
&
user_list
,
ulong
rights
,
List
<
LEX_USER
>
&
user_list
,
ulong
rights
,
bool
revoke
,
bool
no_error
);
bool
revoke
,
bool
no_error
);
ACL_USER
*
check_acl_user
(
LEX_USER
*
user_name
,
uint
*
acl_acl_userdx
);
my_bool
grant_init
();
my_bool
grant_init
();
void
grant_free
(
void
);
void
grant_free
(
void
);
my_bool
grant_reload
(
THD
*
thd
);
my_bool
grant_reload
(
THD
*
thd
);
...
...
sql/sql_parse.cc
View file @
0499b301
...
@@ -3982,7 +3982,6 @@ mysql_execute_command(THD *thd)
...
@@ -3982,7 +3982,6 @@ mysql_execute_command(THD *thd)
if
(
thd
->
security_ctx
->
user
)
// If not replication
if
(
thd
->
security_ctx
->
user
)
// If not replication
{
{
LEX_USER
*
user
;
LEX_USER
*
user
;
uint
counter
;
List_iterator
<
LEX_USER
>
user_list
(
lex
->
users_list
);
List_iterator
<
LEX_USER
>
user_list
(
lex
->
users_list
);
while
((
user
=
user_list
++
))
while
((
user
=
user_list
++
))
...
@@ -4000,7 +3999,8 @@ mysql_execute_command(THD *thd)
...
@@ -4000,7 +3999,8 @@ mysql_execute_command(THD *thd)
user
->
host
.
str
,
thd
->
security_ctx
->
host_or_ip
))
user
->
host
.
str
,
thd
->
security_ctx
->
host_or_ip
))
{
{
// TODO: use check_change_password()
// TODO: use check_change_password()
if
(
check_acl_user
(
user
,
&
counter
)
&&
user
->
password
.
str
&&
if
(
is_acl_user
(
user
->
host
.
str
,
user
->
user
.
str
)
&&
user
->
password
.
str
&&
check_access
(
thd
,
UPDATE_ACL
,
"mysql"
,
0
,
1
,
1
,
0
))
check_access
(
thd
,
UPDATE_ACL
,
"mysql"
,
0
,
1
,
1
,
0
))
{
{
my_message
(
ER_PASSWORD_NOT_ALLOWED
,
my_message
(
ER_PASSWORD_NOT_ALLOWED
,
...
...
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