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
3bc863b2
Commit
3bc863b2
authored
Apr 16, 2019
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-19256 sql_acl.cc does not compile with WITH_VALGRIND with gcc 8.0
Turning initializing code into constructors.
parent
e4c55519
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
24 deletions
+43
-24
sql/sql_acl.cc
sql/sql_acl.cc
+43
-24
No files found.
sql/sql_acl.cc
View file @
3bc863b2
...
...
@@ -119,6 +119,9 @@ class ACL_ACCESS {
public:
ulong
sort
;
ulong
access
;
ACL_ACCESS
()
:
sort
(
0
),
access
(
0
)
{
}
};
/* ACL_HOST is used if no host is specified */
...
...
@@ -134,15 +137,25 @@ class ACL_USER_BASE :public ACL_ACCESS, public Sql_alloc
{
public:
ACL_USER_BASE
()
:
flags
(
0
),
user
(
null_clex_str
)
{
bzero
(
&
role_grants
,
sizeof
(
role_grants
));
}
uchar
flags
;
// field used to store various state information
LEX_CSTRING
user
;
/* list to hold references to granted roles (ACL_ROLE instances) */
DYNAMIC_ARRAY
role_grants
;
const
char
*
get_username
()
{
return
user
.
str
;
}
};
class
ACL_USER
:
public
ACL_USER_BASE
class
ACL_USER
_PARAM
{
public:
ACL_USER_PARAM
()
{
bzero
(
this
,
sizeof
(
*
this
));
}
acl_host_and_ip
host
;
size_t
hostname_length
;
USER_RESOURCES
user_resource
;
...
...
@@ -161,6 +174,18 @@ class ACL_USER :public ACL_USER_BASE
{
return
!
(
auth
=
(
AUTH
*
)
alloc_root
(
root
,
(
nauth
=
n
)
*
sizeof
(
AUTH
)));
}
};
class
ACL_USER
:
public
ACL_USER_BASE
,
public
ACL_USER_PARAM
{
public:
ACL_USER
()
{
}
ACL_USER
(
THD
*
thd
,
const
LEX_USER
&
combo
,
const
Account_options
&
options
,
const
ulong
privileges
);
ACL_USER
*
copy
(
MEM_ROOT
*
root
)
{
...
...
@@ -206,8 +231,6 @@ class ACL_USER :public ACL_USER_BASE
bool
eq
(
const
char
*
user2
,
const
char
*
host2
)
{
return
!
cmp
(
user2
,
host2
);
}
const
char
*
get_username
(){
return
user
.
str
;
}
bool
wild_eq
(
const
char
*
user2
,
const
char
*
host2
,
const
char
*
ip2
)
{
if
(
strcmp
(
user
.
str
,
user2
))
...
...
@@ -1931,12 +1954,10 @@ enum enum_acl_lists
ACL_ROLE
::
ACL_ROLE
(
ACL_USER
*
user
,
MEM_ROOT
*
root
)
:
counter
(
0
)
{
access
=
user
->
access
;
/* set initial role access the same as the table row privileges */
initial_role_access
=
user
->
access
;
this
->
user
=
user
->
user
;
bzero
(
&
role_grants
,
sizeof
(
role_grants
));
bzero
(
&
parent_grantee
,
sizeof
(
parent_grantee
));
flags
=
IS_ROLE
;
}
...
...
@@ -1947,7 +1968,6 @@ ACL_ROLE::ACL_ROLE(const char * rolename, ulong privileges, MEM_ROOT *root) :
this
->
access
=
initial_role_access
;
this
->
user
.
str
=
safe_strdup_root
(
root
,
rolename
);
this
->
user
.
length
=
strlen
(
rolename
);
bzero
(
&
role_grants
,
sizeof
(
role_grants
));
bzero
(
&
parent_grantee
,
sizeof
(
parent_grantee
));
flags
=
IS_ROLE
;
}
...
...
@@ -2348,7 +2368,6 @@ static bool acl_load(THD *thd, const Grant_tables& tables)
{
ACL_USER
user
;
bool
is_role
=
FALSE
;
bzero
(
&
user
,
sizeof
(
user
));
update_hostname
(
&
user
.
host
,
user_table
.
get_host
(
&
acl_memroot
));
char
*
username
=
safe_str
(
user_table
.
get_user
(
&
acl_memroot
));
user
.
user
.
str
=
username
;
...
...
@@ -3122,26 +3141,25 @@ static void acl_update_role(const char *rolename, ulong privileges)
}
ACL_USER
::
ACL_USER
(
THD
*
thd
,
const
LEX_USER
&
combo
,
const
Account_options
&
options
,
const
ulong
privileges
)
{
user
=
safe_lexcstrdup_root
(
&
acl_memroot
,
combo
.
user
);
update_hostname
(
&
host
,
safe_strdup_root
(
&
acl_memroot
,
combo
.
host
.
str
));
hostname_length
=
combo
.
host
.
length
;
sort
=
get_sort
(
2
,
host
.
hostname
,
user
.
str
);
password_last_changed
=
thd
->
query_start
();
password_lifetime
=
-
1
;
my_init_dynamic_array
(
&
role_grants
,
sizeof
(
ACL_USER
*
),
0
,
8
,
MYF
(
0
));
}
static
int
acl_user_update
(
THD
*
thd
,
ACL_USER
*
acl_user
,
uint
nauth
,
const
ACL_USER
*
from
,
const
LEX_USER
&
combo
,
const
LEX_USER
&
combo
,
const
Account_options
&
options
,
const
ulong
privileges
)
{
if
(
from
)
*
acl_user
=
*
from
;
else
{
bzero
(
acl_user
,
sizeof
(
*
acl_user
));
acl_user
->
user
=
safe_lexcstrdup_root
(
&
acl_memroot
,
combo
.
user
);
update_hostname
(
&
acl_user
->
host
,
safe_strdup_root
(
&
acl_memroot
,
combo
.
host
.
str
));
acl_user
->
hostname_length
=
combo
.
host
.
length
;
acl_user
->
sort
=
get_sort
(
2
,
acl_user
->
host
.
hostname
,
acl_user
->
user
.
str
);
acl_user
->
password_last_changed
=
thd
->
query_start
();
acl_user
->
password_lifetime
=
-
1
;
my_init_dynamic_array
(
&
acl_user
->
role_grants
,
sizeof
(
ACL_USER
*
),
0
,
8
,
MYF
(
0
));
}
if
(
nauth
)
{
if
(
acl_user
->
nauth
>=
nauth
)
...
...
@@ -4424,8 +4442,9 @@ static int replace_user_table(THD *thd, const User_table &user_table,
my_error
(
ER_PASSWORD_NO_MATCH
,
MYF
(
0
));
goto
end
;
}
new_acl_user
=
old_row_exists
?
*
old_acl_user
:
ACL_USER
(
thd
,
*
combo
,
lex
->
account_options
,
rights
);
if
(
acl_user_update
(
thd
,
&
new_acl_user
,
nauth
,
old_row_exists
?
old_acl_user
:
NULL
,
*
combo
,
lex
->
account_options
,
rights
))
goto
end
;
...
...
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