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
25fc844f
Commit
25fc844f
authored
Dec 23, 2008
by
Sergey Glukhov
Browse files
Options
Browse Files
Download
Plain Diff
5.0-bugteam->5.1-bugteam merge
parents
f42b9ad9
e1383368
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
36 deletions
+85
-36
sql/sql_acl.cc
sql/sql_acl.cc
+85
-36
No files found.
sql/sql_acl.cc
View file @
25fc844f
...
@@ -6304,10 +6304,11 @@ int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr)
...
@@ -6304,10 +6304,11 @@ int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr)
}
}
void
update_schema_privilege
(
TABLE
*
table
,
char
*
buff
,
const
char
*
db
,
static
bool
update_schema_privilege
(
THD
*
thd
,
TABLE
*
table
,
char
*
buff
,
const
char
*
t_name
,
const
char
*
column
,
const
char
*
db
,
const
char
*
t_name
,
uint
col_length
,
const
char
*
priv
,
const
char
*
column
,
uint
col_length
,
uint
priv_length
,
const
char
*
is_grantable
)
const
char
*
priv
,
uint
priv_length
,
const
char
*
is_grantable
)
{
{
int
i
=
2
;
int
i
=
2
;
CHARSET_INFO
*
cs
=
system_charset_info
;
CHARSET_INFO
*
cs
=
system_charset_info
;
...
@@ -6320,14 +6321,15 @@ void update_schema_privilege(TABLE *table, char *buff, const char* db,
...
@@ -6320,14 +6321,15 @@ void update_schema_privilege(TABLE *table, char *buff, const char* db,
if
(
column
)
if
(
column
)
table
->
field
[
i
++
]
->
store
(
column
,
col_length
,
cs
);
table
->
field
[
i
++
]
->
store
(
column
,
col_length
,
cs
);
table
->
field
[
i
++
]
->
store
(
priv
,
priv_length
,
cs
);
table
->
field
[
i
++
]
->
store
(
priv
,
priv_length
,
cs
);
table
->
field
[
i
]
->
store
(
is_grantable
,
(
uint
)
strlen
(
is_grantable
),
cs
);
table
->
field
[
i
]
->
store
(
is_grantable
,
strlen
(
is_grantable
),
cs
);
table
->
file
->
ha_write_row
(
table
->
record
[
0
]
);
return
schema_table_store_record
(
thd
,
table
);
}
}
int
fill_schema_user_privileges
(
THD
*
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
)
int
fill_schema_user_privileges
(
THD
*
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
)
{
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
#ifndef NO_EMBEDDED_ACCESS_CHECKS
int
error
=
0
;
uint
counter
;
uint
counter
;
ACL_USER
*
acl_user
;
ACL_USER
*
acl_user
;
ulong
want_access
;
ulong
want_access
;
...
@@ -6361,8 +6363,14 @@ int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
...
@@ -6361,8 +6363,14 @@ int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
strxmov
(
buff
,
"'"
,
user
,
"'@'"
,
host
,
"'"
,
NullS
);
strxmov
(
buff
,
"'"
,
user
,
"'@'"
,
host
,
"'"
,
NullS
);
if
(
!
(
want_access
&
~
GRANT_ACL
))
if
(
!
(
want_access
&
~
GRANT_ACL
))
update_schema_privilege
(
table
,
buff
,
0
,
0
,
0
,
0
,
{
STRING_WITH_LEN
(
"USAGE"
),
is_grantable
);
if
(
update_schema_privilege
(
thd
,
table
,
buff
,
0
,
0
,
0
,
0
,
STRING_WITH_LEN
(
"USAGE"
),
is_grantable
))
{
error
=
1
;
goto
err
;
}
}
else
else
{
{
uint
priv_id
;
uint
priv_id
;
...
@@ -6370,16 +6378,22 @@ int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
...
@@ -6370,16 +6378,22 @@ int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
for
(
priv_id
=
0
,
j
=
SELECT_ACL
;
j
<=
GLOBAL_ACLS
;
priv_id
++
,
j
<<=
1
)
for
(
priv_id
=
0
,
j
=
SELECT_ACL
;
j
<=
GLOBAL_ACLS
;
priv_id
++
,
j
<<=
1
)
{
{
if
(
test_access
&
j
)
if
(
test_access
&
j
)
update_schema_privilege
(
table
,
buff
,
0
,
0
,
0
,
0
,
{
if
(
update_schema_privilege
(
thd
,
table
,
buff
,
0
,
0
,
0
,
0
,
command_array
[
priv_id
],
command_array
[
priv_id
],
command_lengths
[
priv_id
],
is_grantable
);
command_lengths
[
priv_id
],
is_grantable
))
{
error
=
1
;
goto
err
;
}
}
}
}
}
}
}
}
err:
pthread_mutex_unlock
(
&
acl_cache
->
lock
);
pthread_mutex_unlock
(
&
acl_cache
->
lock
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
error
);
#else
#else
return
(
0
);
return
(
0
);
#endif
#endif
...
@@ -6389,6 +6403,7 @@ int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
...
@@ -6389,6 +6403,7 @@ int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
int
fill_schema_schema_privileges
(
THD
*
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
)
int
fill_schema_schema_privileges
(
THD
*
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
)
{
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
#ifndef NO_EMBEDDED_ACCESS_CHECKS
int
error
=
0
;
uint
counter
;
uint
counter
;
ACL_DB
*
acl_db
;
ACL_DB
*
acl_db
;
ulong
want_access
;
ulong
want_access
;
...
@@ -6426,24 +6441,36 @@ int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
...
@@ -6426,24 +6441,36 @@ int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
}
}
strxmov
(
buff
,
"'"
,
user
,
"'@'"
,
host
,
"'"
,
NullS
);
strxmov
(
buff
,
"'"
,
user
,
"'@'"
,
host
,
"'"
,
NullS
);
if
(
!
(
want_access
&
~
GRANT_ACL
))
if
(
!
(
want_access
&
~
GRANT_ACL
))
update_schema_privilege
(
table
,
buff
,
acl_db
->
db
,
0
,
0
,
{
0
,
STRING_WITH_LEN
(
"USAGE"
),
is_grantable
);
if
(
update_schema_privilege
(
thd
,
table
,
buff
,
acl_db
->
db
,
0
,
0
,
0
,
STRING_WITH_LEN
(
"USAGE"
),
is_grantable
))
{
error
=
1
;
goto
err
;
}
}
else
else
{
{
int
cnt
;
int
cnt
;
ulong
j
,
test_access
=
want_access
&
~
GRANT_ACL
;
ulong
j
,
test_access
=
want_access
&
~
GRANT_ACL
;
for
(
cnt
=
0
,
j
=
SELECT_ACL
;
j
<=
DB_ACLS
;
cnt
++
,
j
<<=
1
)
for
(
cnt
=
0
,
j
=
SELECT_ACL
;
j
<=
DB_ACLS
;
cnt
++
,
j
<<=
1
)
if
(
test_access
&
j
)
if
(
test_access
&
j
)
update_schema_privilege
(
table
,
buff
,
acl_db
->
db
,
0
,
0
,
0
,
{
if
(
update_schema_privilege
(
thd
,
table
,
buff
,
acl_db
->
db
,
0
,
0
,
0
,
command_array
[
cnt
],
command_lengths
[
cnt
],
command_array
[
cnt
],
command_lengths
[
cnt
],
is_grantable
);
is_grantable
))
{
error
=
1
;
goto
err
;
}
}
}
}
}
}
}
}
err:
pthread_mutex_unlock
(
&
acl_cache
->
lock
);
pthread_mutex_unlock
(
&
acl_cache
->
lock
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
error
);
#else
#else
return
(
0
);
return
(
0
);
#endif
#endif
...
@@ -6453,6 +6480,7 @@ int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
...
@@ -6453,6 +6480,7 @@ int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
int
fill_schema_table_privileges
(
THD
*
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
)
int
fill_schema_table_privileges
(
THD
*
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
)
{
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
#ifndef NO_EMBEDDED_ACCESS_CHECKS
int
error
=
0
;
uint
index
;
uint
index
;
char
buff
[
100
];
char
buff
[
100
];
TABLE
*
table
=
tables
->
table
;
TABLE
*
table
=
tables
->
table
;
...
@@ -6492,8 +6520,15 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
...
@@ -6492,8 +6520,15 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
strxmov
(
buff
,
"'"
,
user
,
"'@'"
,
host
,
"'"
,
NullS
);
strxmov
(
buff
,
"'"
,
user
,
"'@'"
,
host
,
"'"
,
NullS
);
if
(
!
test_access
)
if
(
!
test_access
)
update_schema_privilege
(
table
,
buff
,
grant_table
->
db
,
grant_table
->
tname
,
{
0
,
0
,
STRING_WITH_LEN
(
"USAGE"
),
is_grantable
);
if
(
update_schema_privilege
(
thd
,
table
,
buff
,
grant_table
->
db
,
grant_table
->
tname
,
0
,
0
,
STRING_WITH_LEN
(
"USAGE"
),
is_grantable
))
{
error
=
1
;
goto
err
;
}
}
else
else
{
{
ulong
j
;
ulong
j
;
...
@@ -6501,17 +6536,24 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
...
@@ -6501,17 +6536,24 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
for
(
cnt
=
0
,
j
=
SELECT_ACL
;
j
<=
TABLE_ACLS
;
cnt
++
,
j
<<=
1
)
for
(
cnt
=
0
,
j
=
SELECT_ACL
;
j
<=
TABLE_ACLS
;
cnt
++
,
j
<<=
1
)
{
{
if
(
test_access
&
j
)
if
(
test_access
&
j
)
update_schema_privilege
(
table
,
buff
,
grant_table
->
db
,
{
grant_table
->
tname
,
0
,
0
,
command_array
[
cnt
],
if
(
update_schema_privilege
(
thd
,
table
,
buff
,
grant_table
->
db
,
command_lengths
[
cnt
],
is_grantable
);
grant_table
->
tname
,
0
,
0
,
command_array
[
cnt
],
command_lengths
[
cnt
],
is_grantable
))
{
error
=
1
;
goto
err
;
}
}
}
}
}
}
}
}
}
}
err:
rw_unlock
(
&
LOCK_grant
);
rw_unlock
(
&
LOCK_grant
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
error
);
#else
#else
return
(
0
);
return
(
0
);
#endif
#endif
...
@@ -6521,6 +6563,7 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
...
@@ -6521,6 +6563,7 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
int
fill_schema_column_privileges
(
THD
*
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
)
int
fill_schema_column_privileges
(
THD
*
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
)
{
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
#ifndef NO_EMBEDDED_ACCESS_CHECKS
int
error
=
0
;
uint
index
;
uint
index
;
char
buff
[
100
];
char
buff
[
100
];
TABLE
*
table
=
tables
->
table
;
TABLE
*
table
=
tables
->
table
;
...
@@ -6570,22 +6613,28 @@ int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
...
@@ -6570,22 +6613,28 @@ int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
GRANT_COLUMN
*
grant_column
=
(
GRANT_COLUMN
*
)
GRANT_COLUMN
*
grant_column
=
(
GRANT_COLUMN
*
)
hash_element
(
&
grant_table
->
hash_columns
,
col_index
);
hash_element
(
&
grant_table
->
hash_columns
,
col_index
);
if
((
grant_column
->
rights
&
j
)
&&
(
table_access
&
j
))
if
((
grant_column
->
rights
&
j
)
&&
(
table_access
&
j
))
update_schema_privilege
(
table
,
buff
,
grant_table
->
db
,
{
if
(
update_schema_privilege
(
thd
,
table
,
buff
,
grant_table
->
db
,
grant_table
->
tname
,
grant_table
->
tname
,
grant_column
->
column
,
grant_column
->
column
,
grant_column
->
key_length
,
grant_column
->
key_length
,
command_array
[
cnt
],
command_array
[
cnt
],
command_lengths
[
cnt
],
is_grantable
);
command_lengths
[
cnt
],
is_grantable
))
{
error
=
1
;
goto
err
;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
err:
rw_unlock
(
&
LOCK_grant
);
rw_unlock
(
&
LOCK_grant
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
error
);
#else
#else
return
(
0
);
return
(
0
);
#endif
#endif
...
...
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