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
0877eff4
Commit
0877eff4
authored
Mar 06, 2017
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
thd_rnd service
parent
6305533d
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
148 additions
and
4 deletions
+148
-4
include/mysql/plugin_audit.h.pp
include/mysql/plugin_audit.h.pp
+6
-0
include/mysql/plugin_auth.h.pp
include/mysql/plugin_auth.h.pp
+6
-0
include/mysql/plugin_encryption.h.pp
include/mysql/plugin_encryption.h.pp
+6
-0
include/mysql/plugin_ftparser.h.pp
include/mysql/plugin_ftparser.h.pp
+6
-0
include/mysql/plugin_password_validation.h.pp
include/mysql/plugin_password_validation.h.pp
+6
-0
include/mysql/service_thd_rnd.h
include/mysql/service_thd_rnd.h
+62
-0
include/mysql/services.h
include/mysql/services.h
+1
-0
include/service_versions.h
include/service_versions.h
+1
-0
libservices/CMakeLists.txt
libservices/CMakeLists.txt
+1
-0
libservices/thd_rnd_service.c
libservices/thd_rnd_service.c
+17
-0
sql/password.c
sql/password.c
+5
-1
sql/sql_acl.cc
sql/sql_acl.cc
+3
-3
sql/sql_class.cc
sql/sql_class.cc
+22
-0
sql/sql_plugin_services.ic
sql/sql_plugin_services.ic
+6
-0
No files found.
include/mysql/plugin_audit.h.pp
View file @
0877eff4
...
...
@@ -219,6 +219,12 @@ extern struct thd_autoinc_service_st {
}
*
thd_autoinc_service
;
void
thd_get_autoinc
(
const
void
*
thd
,
unsigned
long
*
off
,
unsigned
long
*
inc
);
extern
struct
thd_rnd_service_st
{
double
(
*
thd_rnd_ptr
)(
void
*
thd
);
void
(
*
thd_c_r_p_ptr
)(
void
*
thd
,
char
*
to
,
size_t
length
);
}
*
thd_rnd_service
;
double
thd_rnd
(
void
*
thd
);
void
thd_create_random_password
(
void
*
thd
,
char
*
to
,
size_t
length
);
extern
struct
thd_error_context_service_st
{
const
char
*
(
*
thd_get_error_message_func
)(
const
void
*
thd
);
unsigned
int
(
*
thd_get_error_number_func
)(
const
void
*
thd
);
...
...
include/mysql/plugin_auth.h.pp
View file @
0877eff4
...
...
@@ -219,6 +219,12 @@ extern struct thd_autoinc_service_st {
}
*
thd_autoinc_service
;
void
thd_get_autoinc
(
const
void
*
thd
,
unsigned
long
*
off
,
unsigned
long
*
inc
);
extern
struct
thd_rnd_service_st
{
double
(
*
thd_rnd_ptr
)(
void
*
thd
);
void
(
*
thd_c_r_p_ptr
)(
void
*
thd
,
char
*
to
,
size_t
length
);
}
*
thd_rnd_service
;
double
thd_rnd
(
void
*
thd
);
void
thd_create_random_password
(
void
*
thd
,
char
*
to
,
size_t
length
);
extern
struct
thd_error_context_service_st
{
const
char
*
(
*
thd_get_error_message_func
)(
const
void
*
thd
);
unsigned
int
(
*
thd_get_error_number_func
)(
const
void
*
thd
);
...
...
include/mysql/plugin_encryption.h.pp
View file @
0877eff4
...
...
@@ -219,6 +219,12 @@ extern struct thd_autoinc_service_st {
}
*
thd_autoinc_service
;
void
thd_get_autoinc
(
const
void
*
thd
,
unsigned
long
*
off
,
unsigned
long
*
inc
);
extern
struct
thd_rnd_service_st
{
double
(
*
thd_rnd_ptr
)(
void
*
thd
);
void
(
*
thd_c_r_p_ptr
)(
void
*
thd
,
char
*
to
,
size_t
length
);
}
*
thd_rnd_service
;
double
thd_rnd
(
void
*
thd
);
void
thd_create_random_password
(
void
*
thd
,
char
*
to
,
size_t
length
);
extern
struct
thd_error_context_service_st
{
const
char
*
(
*
thd_get_error_message_func
)(
const
void
*
thd
);
unsigned
int
(
*
thd_get_error_number_func
)(
const
void
*
thd
);
...
...
include/mysql/plugin_ftparser.h.pp
View file @
0877eff4
...
...
@@ -219,6 +219,12 @@ extern struct thd_autoinc_service_st {
}
*
thd_autoinc_service
;
void
thd_get_autoinc
(
const
void
*
thd
,
unsigned
long
*
off
,
unsigned
long
*
inc
);
extern
struct
thd_rnd_service_st
{
double
(
*
thd_rnd_ptr
)(
void
*
thd
);
void
(
*
thd_c_r_p_ptr
)(
void
*
thd
,
char
*
to
,
size_t
length
);
}
*
thd_rnd_service
;
double
thd_rnd
(
void
*
thd
);
void
thd_create_random_password
(
void
*
thd
,
char
*
to
,
size_t
length
);
extern
struct
thd_error_context_service_st
{
const
char
*
(
*
thd_get_error_message_func
)(
const
void
*
thd
);
unsigned
int
(
*
thd_get_error_number_func
)(
const
void
*
thd
);
...
...
include/mysql/plugin_password_validation.h.pp
View file @
0877eff4
...
...
@@ -219,6 +219,12 @@ extern struct thd_autoinc_service_st {
}
*
thd_autoinc_service
;
void
thd_get_autoinc
(
const
void
*
thd
,
unsigned
long
*
off
,
unsigned
long
*
inc
);
extern
struct
thd_rnd_service_st
{
double
(
*
thd_rnd_ptr
)(
void
*
thd
);
void
(
*
thd_c_r_p_ptr
)(
void
*
thd
,
char
*
to
,
size_t
length
);
}
*
thd_rnd_service
;
double
thd_rnd
(
void
*
thd
);
void
thd_create_random_password
(
void
*
thd
,
char
*
to
,
size_t
length
);
extern
struct
thd_error_context_service_st
{
const
char
*
(
*
thd_get_error_message_func
)(
const
void
*
thd
);
unsigned
int
(
*
thd_get_error_number_func
)(
const
void
*
thd
);
...
...
include/mysql/service_thd_rnd.h
0 → 100644
View file @
0877eff4
#ifndef MYSQL_SERVICE_THD_RND_INCLUDED
/* Copyright (C) 2017 MariaDB Corporation
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
/**
@file
This service provides access to the thd-local random number generator.
It's preferrable over the global one, because concurrent threads
can generate random numbers without fighting each other over the access
to the shared rnd state.
*/
#ifdef __cplusplus
extern
"C"
{
#endif
#ifndef MYSQL_ABI_CHECK
#include <stdlib.h>
#endif
extern
struct
thd_rnd_service_st
{
double
(
*
thd_rnd_ptr
)(
MYSQL_THD
thd
);
void
(
*
thd_c_r_p_ptr
)(
MYSQL_THD
thd
,
char
*
to
,
size_t
length
);
}
*
thd_rnd_service
;
#ifdef MYSQL_DYNAMIC_PLUGIN
#define thd_rnd(A) thd_rnd_service->thd_rnd_ptr(A)
#define thd_create_random_password(A,B,C) thd_rnd_service->thd_c_r_p_ptr(A,B,C)
#else
double
thd_rnd
(
MYSQL_THD
thd
);
/**
Generate string of printable random characters of requested length.
@param to[out] Buffer for generation; must be at least length+1 bytes
long; result string is always null-terminated
@param length[in] How many random characters to put in buffer
*/
void
thd_create_random_password
(
MYSQL_THD
thd
,
char
*
to
,
size_t
length
);
#endif
#ifdef __cplusplus
}
#endif
#define MYSQL_SERVICE_THD_RND_INCLUDED
#endif
include/mysql/services.h
View file @
0877eff4
...
...
@@ -32,6 +32,7 @@ extern "C" {
#include <mysql/service_base64.h>
#include <mysql/service_logger.h>
#include <mysql/service_thd_autoinc.h>
#include <mysql/service_thd_rnd.h>
#include <mysql/service_thd_error_context.h>
#include <mysql/service_thd_specifics.h>
#include <mysql/service_encryption.h>
...
...
include/service_versions.h
View file @
0877eff4
...
...
@@ -34,6 +34,7 @@
#define VERSION_wsrep 0x0201
#define VERSION_logger 0x0100
#define VERSION_base64 0x0100
#define VERSION_thd_rnd 0x0100
#define VERSION_thd_autoinc 0x0100
#define VERSION_thd_error_context 0x0100
#define VERSION_thd_specifics 0x0100
...
...
libservices/CMakeLists.txt
View file @
0877eff4
...
...
@@ -22,6 +22,7 @@ SET(MYSQLSERVICES_SOURCES
thd_timezone_service.c
thd_autoinc_service.c
thd_error_context_service.c
thd_rnd_service.c
thd_specifics_service.c
progress_report_service.c
debug_sync_service.c
...
...
libservices/thd_rnd_service.c
0 → 100644
View file @
0877eff4
/* Copyright (C) 2017 MariaDB Corporation
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#include <service_versions.h>
SERVICE_VERSION
thd_rnd_service
=
(
void
*
)
VERSION_thd_rnd
;
sql/password.c
View file @
0877eff4
...
...
@@ -38,7 +38,7 @@
The new authentication is performed in following manner:
SERVER: public_seed=
create_random_string
()
SERVER: public_seed=
thd_create_random_password
()
send(public_seed)
CLIENT: recv(public_seed)
...
...
@@ -278,6 +278,7 @@ void make_password_from_salt_323(char *to, const ulong *salt)
**************** MySQL 4.1.1 authentication routines *************
*/
#if MYSQL_VERSION_ID < 0x100200
/**
Generate string of printable random characters of requested length.
...
...
@@ -296,6 +297,9 @@ void create_random_string(char *to, uint length,
*
to
=
(
char
)
(
my_rnd
(
rand_st
)
*
94
+
33
);
*
to
=
'\0'
;
}
#else
#error
#endif
/* Character to use as version identifier for version 4.1 */
...
...
sql/sql_acl.cc
View file @
0877eff4
...
...
@@ -11313,7 +11313,7 @@ static bool send_server_handshake_packet(MPVIO_EXT *mpvio,
native_password_plugin will have to send it in a separate packet,
adding one more round trip.
*/
create_random_string
(
thd
->
scramble
,
SCRAMBLE_LENGTH
,
&
thd
->
rand
);
thd_create_random_password
(
thd
,
thd
->
scramble
,
SCRAMBLE_LENGTH
);
data
=
thd
->
scramble
;
}
data_len
=
SCRAMBLE_LENGTH
;
...
...
@@ -12671,7 +12671,7 @@ static int native_password_authenticate(MYSQL_PLUGIN_VIO *vio,
/* generate the scramble, or reuse the old one */
if
(
thd
->
scramble
[
SCRAMBLE_LENGTH
])
{
create_random_string
(
thd
->
scramble
,
SCRAMBLE_LENGTH
,
&
thd
->
rand
);
thd_create_random_password
(
thd
,
thd
->
scramble
,
SCRAMBLE_LENGTH
);
/* and send it to the client */
if
(
mpvio
->
write_packet
(
mpvio
,
(
uchar
*
)
thd
->
scramble
,
SCRAMBLE_LENGTH
+
1
))
DBUG_RETURN
(
CR_AUTH_HANDSHAKE
);
...
...
@@ -12755,7 +12755,7 @@ static int old_password_authenticate(MYSQL_PLUGIN_VIO *vio,
/* generate the scramble, or reuse the old one */
if
(
thd
->
scramble
[
SCRAMBLE_LENGTH
])
{
create_random_string
(
thd
->
scramble
,
SCRAMBLE_LENGTH
,
&
thd
->
rand
);
thd_create_random_password
(
thd
,
thd
->
scramble
,
SCRAMBLE_LENGTH
);
/* and send it to the client */
if
(
mpvio
->
write_packet
(
mpvio
,
(
uchar
*
)
thd
->
scramble
,
SCRAMBLE_LENGTH
+
1
))
return
CR_AUTH_HANDSHAKE
;
...
...
sql/sql_class.cc
View file @
0877eff4
...
...
@@ -4475,6 +4475,28 @@ extern "C" int thd_is_connected(MYSQL_THD thd)
}
extern
"C"
double
thd_rnd
(
MYSQL_THD
thd
)
{
return
my_rnd
(
&
thd
->
rand
);
}
/**
Generate string of printable random characters of requested length.
@param to[out] Buffer for generation; must be at least length+1 bytes
long; result string is always null-terminated
@param length[in] How many random characters to put in buffer
*/
extern
"C"
void
thd_create_random_password
(
MYSQL_THD
thd
,
char
*
to
,
size_t
length
)
{
for
(
char
*
end
=
to
+
length
;
to
<
end
;
to
++
)
*
to
=
(
char
)
(
my_rnd
(
&
thd
->
rand
)
*
94
+
33
);
*
to
=
'\0'
;
}
#ifdef INNODB_COMPATIBILITY_HOOKS
extern
"C"
const
struct
charset_info_st
*
thd_charset
(
MYSQL_THD
thd
)
{
...
...
sql/sql_plugin_services.ic
View file @
0877eff4
...
...
@@ -119,6 +119,11 @@ static struct thd_autoinc_service_st thd_autoinc_handler= {
thd_get_autoinc
};
static struct thd_rnd_service_st thd_rnd_handler= {
thd_rnd,
thd_create_random_password
};
static struct base64_service_st base64_handler= {
base64_needed_encoded_length,
base64_encode_max_arg_length,
...
...
@@ -205,6 +210,7 @@ static struct st_service_ref list_of_services[]=
{ "my_md5_service", VERSION_my_md5, &my_md5_handler},
{ "logger_service", VERSION_logger, &logger_service_handler },
{ "base64_service", VERSION_base64, &base64_handler },
{ "thd_rnd_service", VERSION_thd_rnd, &thd_rnd_handler },
{ "thd_autoinc_service", VERSION_thd_autoinc, &thd_autoinc_handler },
{ "wsrep_service", VERSION_wsrep, &wsrep_handler },
{ "encryption_service", VERSION_encryption, &encryption_handler },
...
...
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