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
e100530b
Commit
e100530b
authored
Feb 14, 2004
by
hf@deer.(none)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for #2212 (mysql_change_user doesn't work in embedded library)
now it's working
parent
b0d04923
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
63 additions
and
36 deletions
+63
-36
include/mysql.h
include/mysql.h
+1
-0
libmysql/client_settings.h
libmysql/client_settings.h
+1
-0
libmysql/libmysql.c
libmysql/libmysql.c
+33
-30
libmysqld/lib_sql.cc
libmysqld/lib_sql.cc
+9
-1
sql-common/client.c
sql-common/client.c
+2
-1
sql/sql_parse.cc
sql/sql_parse.cc
+17
-4
No files found.
include/mysql.h
View file @
e100530b
...
...
@@ -575,6 +575,7 @@ typedef struct st_mysql_methods
void
(
*
free_embedded_thd
)(
MYSQL
*
mysql
);
const
char
*
(
*
read_statistic
)(
MYSQL
*
mysql
);
int
(
*
next_result
)(
MYSQL
*
mysql
);
int
(
*
read_change_user_result
)(
MYSQL
*
mysql
,
char
*
buff
,
const
char
*
passwd
);
#endif
}
MYSQL_METHODS
;
...
...
libmysql/client_settings.h
View file @
e100530b
...
...
@@ -58,6 +58,7 @@ int cli_stmt_execute(MYSQL_STMT *stmt);
MYSQL_DATA
*
cli_read_binary_rows
(
MYSQL_STMT
*
stmt
);
int
cli_unbuffered_fetch
(
MYSQL
*
mysql
,
char
**
row
);
const
char
*
cli_read_statistic
(
MYSQL
*
mysql
);
int
cli_read_change_user_result
(
MYSQL
*
mysql
,
char
*
buff
,
const
char
*
passwd
);
#ifdef EMBEDDED_LIBRARY
int
init_embedded_server
(
int
argc
,
char
**
argv
,
char
**
groups
);
...
...
libmysql/libmysql.c
View file @
e100530b
...
...
@@ -606,13 +606,42 @@ mysql_connect(MYSQL *mysql,const char *host,
/**************************************************************************
Change user and database
**************************************************************************/
int
cli_read_change_user_result
(
MYSQL
*
mysql
,
char
*
buff
,
const
char
*
passwd
)
{
NET
*
net
=
&
mysql
->
net
;
ulong
pkt_length
;
pkt_length
=
net_safe_read
(
mysql
);
if
(
pkt_length
==
packet_error
)
return
1
;
if
(
pkt_length
==
1
&&
net
->
read_pos
[
0
]
==
254
&&
mysql
->
server_capabilities
&
CLIENT_SECURE_CONNECTION
)
{
/*
By sending this very specific reply server asks us to send scrambled
password in old format. The reply contains scramble_323.
*/
scramble_323
(
buff
,
mysql
->
scramble
,
passwd
);
if
(
my_net_write
(
net
,
buff
,
SCRAMBLE_LENGTH_323
+
1
)
||
net_flush
(
net
))
{
net
->
last_errno
=
CR_SERVER_LOST
;
strmov
(
net
->
sqlstate
,
unknown_sqlstate
);
strmov
(
net
->
last_error
,
ER
(
net
->
last_errno
));
return
1
;
}
/* Read what server thinks about out new auth message report */
if
(
net_safe_read
(
mysql
)
==
packet_error
)
return
1
;
}
return
0
;
}
my_bool
STDCALL
mysql_change_user
(
MYSQL
*
mysql
,
const
char
*
user
,
const
char
*
passwd
,
const
char
*
db
)
{
char
buff
[
512
],
*
end
=
buff
;
NET
*
net
=
&
mysql
->
net
;
ulong
pkt_length
;
DBUG_ENTER
(
"mysql_change_user"
);
if
(
!
user
)
...
...
@@ -646,31 +675,8 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
/* Write authentication package */
simple_command
(
mysql
,
COM_CHANGE_USER
,
buff
,(
ulong
)
(
end
-
buff
),
1
);
pkt_length
=
net_safe_read
(
mysql
);
if
(
pkt_length
==
packet_error
)
goto
error
;
if
(
pkt_length
==
1
&&
net
->
read_pos
[
0
]
==
254
&&
mysql
->
server_capabilities
&
CLIENT_SECURE_CONNECTION
)
{
/*
By sending this very specific reply server asks us to send scrambled
password in old format. The reply contains scramble_323.
*/
scramble_323
(
buff
,
mysql
->
scramble
,
passwd
);
if
(
my_net_write
(
net
,
buff
,
SCRAMBLE_LENGTH_323
+
1
)
||
net_flush
(
net
))
{
net
->
last_errno
=
CR_SERVER_LOST
;
strmov
(
net
->
sqlstate
,
unknown_sqlstate
);
strmov
(
net
->
last_error
,
ER
(
net
->
last_errno
));
goto
error
;
}
/* Read what server thinks about out new auth message report */
if
(
net_safe_read
(
mysql
)
==
packet_error
)
goto
error
;
}
if
((
*
mysql
->
methods
->
read_change_user_result
)(
mysql
,
buff
,
passwd
))
DBUG_RETURN
(
1
);
/* Free old connect information */
my_free
(
mysql
->
user
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
passwd
,
MYF
(
MY_ALLOW_ZERO_PTR
));
...
...
@@ -681,9 +687,6 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
mysql
->
passwd
=
my_strdup
(
passwd
,
MYF
(
MY_WME
));
mysql
->
db
=
db
?
my_strdup
(
db
,
MYF
(
MY_WME
))
:
0
;
DBUG_RETURN
(
0
);
error:
DBUG_RETURN
(
1
);
}
#if defined(HAVE_GETPWUID) && defined(NO_GETPWUID_DECL)
...
...
libmysqld/lib_sql.cc
View file @
e100530b
...
...
@@ -258,6 +258,13 @@ int emb_next_result(MYSQL *mysql)
DBUG_RETURN
(
0
);
/* No more results */
}
int
emb_read_change_user_result
(
MYSQL
*
mysql
,
char
*
buff
__attribute__
((
unused
)),
const
char
*
passwd
__attribute__
((
unused
)))
{
return
mysql_errno
(
mysql
);
}
MYSQL_METHODS
embedded_methods
=
{
emb_mysql_read_query_result
,
...
...
@@ -272,7 +279,8 @@ MYSQL_METHODS embedded_methods=
emb_unbuffered_fetch
,
emb_free_embedded_thd
,
emb_read_statistic
,
emb_next_result
emb_next_result
,
emb_read_change_user_result
};
C_MODE_END
...
...
sql-common/client.c
View file @
e100530b
...
...
@@ -1421,7 +1421,8 @@ static MYSQL_METHODS client_methods=
cli_unbuffered_fetch
,
NULL
,
cli_read_statistic
,
cli_read_query_result
cli_read_query_result
,
cli_read_change_user_result
#endif
};
...
...
sql/sql_parse.cc
View file @
e100530b
...
...
@@ -206,7 +206,21 @@ int check_user(THD *thd, enum enum_server_command command,
#ifdef NO_EMBEDDED_ACCESS_CHECKS
thd
->
master_access
=
GLOBAL_ACLS
;
// Full rights
return
0
;
/* Change database if necessary: OK or FAIL is sent in mysql_change_db */
if
(
db
&&
db
[
0
])
{
thd
->
db
=
0
;
thd
->
db_length
=
0
;
if
(
mysql_change_db
(
thd
,
db
))
{
if
(
thd
->
user_connect
)
decrease_user_connections
(
thd
->
user_connect
);
DBUG_RETURN
(
-
1
);
}
}
else
send_ok
(
thd
);
DBUG_RETURN
(
0
);
#else
my_bool
opt_secure_auth_local
;
...
...
@@ -1282,7 +1296,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
send_error
(
thd
);
// dump to NET
break
;
}
#ifndef EMBEDDED_LIBRARY
case
COM_CHANGE_USER
:
{
thd
->
change_user
();
...
...
@@ -1301,13 +1314,14 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
uint
passwd_len
=
thd
->
client_capabilities
&
CLIENT_SECURE_CONNECTION
?
*
passwd
++
:
strlen
(
passwd
);
db
+=
passwd_len
+
1
;
#ifndef EMBEDDED_LIBRARY
/* Small check for incomming packet */
if
((
uint
)
((
uchar
*
)
db
-
net
->
read_pos
)
>
packet_length
)
{
send_error
(
thd
,
ER_UNKNOWN_COM_ERROR
);
break
;
}
#endif
/* Convert database name to utf8 */
db_buff
[
copy_and_convert
(
db_buff
,
sizeof
(
db_buff
)
-
1
,
system_charset_info
,
db
,
strlen
(
db
),
...
...
@@ -1358,7 +1372,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
}
break
;
}
#endif
/* EMBEDDED_LIBRARY */
case
COM_EXECUTE
:
{
mysql_stmt_execute
(
thd
,
packet
);
...
...
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