mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
merged
This commit is contained in:
21
.bzrignore
21
.bzrignore
@ -152,6 +152,7 @@ client/mysqlbinlog
|
|||||||
client/mysqlcheck
|
client/mysqlcheck
|
||||||
client/mysqldump
|
client/mysqldump
|
||||||
client/mysqlimport
|
client/mysqlimport
|
||||||
|
client/mysqlmanagerc
|
||||||
client/mysqlshow
|
client/mysqlshow
|
||||||
client/mysqltest
|
client/mysqltest
|
||||||
client/mysys_priv.h
|
client/mysys_priv.h
|
||||||
@ -203,6 +204,16 @@ libmysqld/backup_dir
|
|||||||
libmysqld/convert.cc
|
libmysqld/convert.cc
|
||||||
libmysqld/derror.cc
|
libmysqld/derror.cc
|
||||||
libmysqld/errmsg.c
|
libmysqld/errmsg.c
|
||||||
|
libmysqld/examples/completion_hash.cc
|
||||||
|
libmysqld/examples/completion_hash.h
|
||||||
|
libmysqld/examples/my_readline.h
|
||||||
|
libmysqld/examples/mysql
|
||||||
|
libmysqld/examples/mysql.cc
|
||||||
|
libmysqld/examples/mysqltest
|
||||||
|
libmysqld/examples/mysqltest.c
|
||||||
|
libmysqld/examples/readline.cc
|
||||||
|
libmysqld/examples/sql_string.cc
|
||||||
|
libmysqld/examples/sql_string.h
|
||||||
libmysqld/field.cc
|
libmysqld/field.cc
|
||||||
libmysqld/field_conv.cc
|
libmysqld/field_conv.cc
|
||||||
libmysqld/filesort.cc
|
libmysqld/filesort.cc
|
||||||
@ -402,13 +413,3 @@ vio/test-ssl
|
|||||||
vio/test-sslclient
|
vio/test-sslclient
|
||||||
vio/test-sslserver
|
vio/test-sslserver
|
||||||
vio/viotest-ssl
|
vio/viotest-ssl
|
||||||
libmysqld/examples/completion_hash.cc
|
|
||||||
libmysqld/examples/completion_hash.h
|
|
||||||
libmysqld/examples/my_readline.h
|
|
||||||
libmysqld/examples/mysql.cc
|
|
||||||
libmysqld/examples/mysqltest.c
|
|
||||||
libmysqld/examples/readline.cc
|
|
||||||
libmysqld/examples/sql_string.cc
|
|
||||||
libmysqld/examples/sql_string.h
|
|
||||||
libmysqld/examples/mysql
|
|
||||||
libmysqld/examples/mysqltest
|
|
||||||
|
@ -23,7 +23,7 @@ noinst_HEADERS = client_priv.h
|
|||||||
LIBS = @CLIENT_LIBS@
|
LIBS = @CLIENT_LIBS@
|
||||||
LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysql/libmysqlclient.la
|
LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysql/libmysqlclient.la
|
||||||
bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow \
|
bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow \
|
||||||
mysqldump mysqlimport mysqltest mysqlbinlog
|
mysqldump mysqlimport mysqltest mysqlbinlog mysqlmanagerc
|
||||||
noinst_PROGRAMS = insert_test select_test thread_test
|
noinst_PROGRAMS = insert_test select_test thread_test
|
||||||
noinst_HEADERS = sql_string.h completion_hash.h my_readline.h
|
noinst_HEADERS = sql_string.h completion_hash.h my_readline.h
|
||||||
mysql_SOURCES = mysql.cc readline.cc sql_string.cc completion_hash.cc
|
mysql_SOURCES = mysql.cc readline.cc sql_string.cc completion_hash.cc
|
||||||
@ -36,14 +36,16 @@ mysqldump_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
|
|||||||
mysqlimport_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
|
mysqlimport_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
|
||||||
insert_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
|
insert_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
|
||||||
select_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
|
select_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
|
||||||
mysqltest_SOURCES= mysqltest.c
|
mysqltest_SOURCES= mysqltest.c
|
||||||
mysqltest_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
|
mysqltest_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
|
||||||
mysqlbinlog_SOURCES = mysqlbinlog.cc
|
mysqlbinlog_SOURCES = mysqlbinlog.cc
|
||||||
mysqlbinlog_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
|
mysqlbinlog_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
|
||||||
sql_src= log_event.h log_event.cc
|
mysqlmanagerc_SOURCES = mysqlmanagerc.c
|
||||||
|
mysqlmanagerc_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
|
||||||
|
sql_src=log_event.h log_event.cc
|
||||||
|
|
||||||
# Fix for mit-threads
|
# Fix for mit-threads
|
||||||
DEFS= -DUNDEF_THREADS_HACK
|
DEFS = -DUNDEF_THREADS_HACK
|
||||||
|
|
||||||
link_sources:
|
link_sources:
|
||||||
for f in $(sql_src) ; do \
|
for f in $(sql_src) ; do \
|
||||||
|
189
client/mysqlmanagerc.c
Normal file
189
client/mysqlmanagerc.c
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
||||||
|
|
||||||
|
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; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||||
|
|
||||||
|
#define MANAGER_CLIENT_VERSION "1.0"
|
||||||
|
|
||||||
|
#include <global.h>
|
||||||
|
#include <my_sys.h>
|
||||||
|
#include <m_string.h>
|
||||||
|
#include <mysql.h>
|
||||||
|
#include <mysql_version.h>
|
||||||
|
#include <m_ctype.h>
|
||||||
|
#ifdef OS2
|
||||||
|
#include <config-os2.h>
|
||||||
|
#else
|
||||||
|
#include <my_config.h>
|
||||||
|
#endif
|
||||||
|
#include <my_dir.h>
|
||||||
|
#include <hash.h>
|
||||||
|
#include <mysqld_error.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <getopt.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <violite.h>
|
||||||
|
|
||||||
|
#ifndef MYSQL_MANAGER_PORT
|
||||||
|
#define MYSQL_MANAGER_PORT 23546
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void die(const char* fmt, ...);
|
||||||
|
|
||||||
|
const char* user="root",*host="localhost";
|
||||||
|
char* pass=0;
|
||||||
|
int quiet=0;
|
||||||
|
uint port=MYSQL_MANAGER_PORT;
|
||||||
|
static const char *load_default_groups[]= { "mysqlmanagerc",0 };
|
||||||
|
char** default_argv;
|
||||||
|
MYSQL_MANAGER *manager;
|
||||||
|
FILE* fp, *fp_out;
|
||||||
|
|
||||||
|
struct option long_options[] =
|
||||||
|
{
|
||||||
|
{"host",required_argument,0,'h'},
|
||||||
|
{"user",required_argument,0,'u'},
|
||||||
|
{"password",optional_argument,0,'p',},
|
||||||
|
{"port",required_argument,0,'P'},
|
||||||
|
{"help",no_argument,0,'?'},
|
||||||
|
{"version",no_argument,0,'V'},
|
||||||
|
{"quiet",no_argument,0,'q'},
|
||||||
|
{0,0,0,0}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void die(const char* fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
DBUG_ENTER("die");
|
||||||
|
va_start(args, fmt);
|
||||||
|
if (fmt)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: ", my_progname);
|
||||||
|
vfprintf(stderr, fmt, args);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
fflush(stderr);
|
||||||
|
}
|
||||||
|
va_end(args);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_version(void)
|
||||||
|
{
|
||||||
|
printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname,
|
||||||
|
MANAGER_CLIENT_VERSION,
|
||||||
|
MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void usage()
|
||||||
|
{
|
||||||
|
print_version();
|
||||||
|
printf("MySQL AB, by Sasha, Matt & Monty\n");
|
||||||
|
printf("This software comes with ABSOLUTELY NO WARRANTY\n\n");
|
||||||
|
printf("Runs a test against the mysql server and compares output with a results file.\n\n");
|
||||||
|
printf("Usage: %s [OPTIONS] < command_file\n", my_progname);
|
||||||
|
printf("\n\
|
||||||
|
-?, --help Display this help and exit.\n");
|
||||||
|
printf("\
|
||||||
|
-h, --host=... Connect to host.\n\
|
||||||
|
-u, --user=... User for login.\n\
|
||||||
|
-p[password], --password[=...]\n\
|
||||||
|
Password to use when connecting to server.\n\
|
||||||
|
-P, --port=... Port number to use for connection.\n\
|
||||||
|
-q, --quiet, --silent Suppress all normal output.\n\
|
||||||
|
-V, --version Output version information and exit.\n\
|
||||||
|
--no-defaults Don't read default options from any options file.\n\n");
|
||||||
|
}
|
||||||
|
int parse_args(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int c, option_index = 0;
|
||||||
|
my_bool tty_password=0;
|
||||||
|
|
||||||
|
load_defaults("my",load_default_groups,&argc,&argv);
|
||||||
|
default_argv= argv;
|
||||||
|
|
||||||
|
while ((c = getopt_long(argc, argv, "h:p::u:P:?Vq",
|
||||||
|
long_options, &option_index)) != EOF)
|
||||||
|
{
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case 'h':
|
||||||
|
host=optarg;
|
||||||
|
break;
|
||||||
|
case 'u':
|
||||||
|
user=optarg;
|
||||||
|
break;
|
||||||
|
case 'p':
|
||||||
|
if (optarg)
|
||||||
|
{
|
||||||
|
my_free(pass,MYF(MY_ALLOW_ZERO_PTR));
|
||||||
|
pass=my_strdup(optarg,MYF(MY_FAE));
|
||||||
|
while (*optarg) *optarg++= 'x'; /* Destroy argument */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tty_password=1;
|
||||||
|
break;
|
||||||
|
case 'P':
|
||||||
|
port=atoi(optarg);
|
||||||
|
break;
|
||||||
|
case 'q':
|
||||||
|
quiet=1;
|
||||||
|
break;
|
||||||
|
case 'V':
|
||||||
|
print_version();
|
||||||
|
exit(0);
|
||||||
|
case '?':
|
||||||
|
usage();
|
||||||
|
exit(1); /* Unknown option */
|
||||||
|
default:
|
||||||
|
usage();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
MY_INIT(argv[0]);
|
||||||
|
fp=stdin;
|
||||||
|
fp_out=stdout;
|
||||||
|
parse_args(argc,argv);
|
||||||
|
if (!(manager=mysql_manager_init(0)))
|
||||||
|
die("Failed in mysql_manager_init()");
|
||||||
|
if (!mysql_manager_connect(manager,host,user,pass,port))
|
||||||
|
die("Could not connect to MySQL manager: %s(%d)",manager->last_error,
|
||||||
|
manager->last_errno);
|
||||||
|
for (;!feof(fp);)
|
||||||
|
{
|
||||||
|
char buf[1024];
|
||||||
|
if (!fgets(buf,sizeof(buf),fp))
|
||||||
|
break;
|
||||||
|
if (mysql_manager_command(manager,buf,strlen(buf)))
|
||||||
|
die("Error in command: %s(%d)",manager->last_error,manager->last_errno);
|
||||||
|
while (!manager->eof)
|
||||||
|
{
|
||||||
|
if (mysql_manager_fetch_line(manager,buf,sizeof(buf)))
|
||||||
|
die("Error fetching result line: %s(%d)", manager->last_error,
|
||||||
|
manager->last_errno);
|
||||||
|
fprintf(fp_out,"%s\n",buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mysql_manager_close(manager);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ noinst_HEADERS = config-win.h \
|
|||||||
my_dir.h mysys_err.h my_base.h \
|
my_dir.h mysys_err.h my_base.h \
|
||||||
my_nosys.h my_alarm.h queues.h \
|
my_nosys.h my_alarm.h queues.h \
|
||||||
my_tree.h hash.h thr_alarm.h thr_lock.h \
|
my_tree.h hash.h thr_alarm.h thr_lock.h \
|
||||||
getopt.h t_ctype.h violite.h \
|
getopt.h t_ctype.h violite.h md5.h \
|
||||||
mysql_version.h.in
|
mysql_version.h.in
|
||||||
|
|
||||||
# mysql_version.h are generated
|
# mysql_version.h are generated
|
||||||
|
@ -223,7 +223,31 @@ typedef struct st_mysql_res {
|
|||||||
my_bool eof; /* Used my mysql_fetch_row */
|
my_bool eof; /* Used my mysql_fetch_row */
|
||||||
} MYSQL_RES;
|
} MYSQL_RES;
|
||||||
|
|
||||||
|
#define MAX_MYSQL_MANAGER_ERR 256
|
||||||
|
#define MAX_MYSQL_MANAGER_MSG 256
|
||||||
|
|
||||||
|
#define MANAGER_OK 200
|
||||||
|
#define MANAGER_INFO 250
|
||||||
|
#define MANAGER_ACCESS 401
|
||||||
|
#define MANAGER_CLIENT_ERR 450
|
||||||
|
#define MANAGER_INTERNAL_ERR 500
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct st_mysql_manager
|
||||||
|
{
|
||||||
|
Vio* vio;
|
||||||
|
char *host,*user,*passwd;
|
||||||
|
unsigned int port;
|
||||||
|
my_bool free_me;
|
||||||
|
my_bool eof;
|
||||||
|
int cmd_status;
|
||||||
|
int last_errno;
|
||||||
|
char* net_buf,*net_buf_pos,*net_data_end;
|
||||||
|
int net_buf_size;
|
||||||
|
char last_error[MAX_MYSQL_MANAGER_ERR];
|
||||||
|
} MYSQL_MANAGER;
|
||||||
|
|
||||||
/* Set up and bring down the server; to ensure that applications will
|
/* Set up and bring down the server; to ensure that applications will
|
||||||
* work when linked against either the standard client library or the
|
* work when linked against either the standard client library or the
|
||||||
* embedded server library, these functions should be called. */
|
* embedded server library, these functions should be called. */
|
||||||
@ -368,7 +392,18 @@ char * STDCALL mysql_odbc_escape_string(MYSQL *mysql,
|
|||||||
unsigned long *length));
|
unsigned long *length));
|
||||||
void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name);
|
void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name);
|
||||||
unsigned int STDCALL mysql_thread_safe(void);
|
unsigned int STDCALL mysql_thread_safe(void);
|
||||||
|
MYSQL_MANAGER* STDCALL mysql_manager_init(MYSQL_MANAGER* con);
|
||||||
|
MYSQL_MANAGER* STDCALL mysql_manager_connect(MYSQL_MANAGER* con,
|
||||||
|
const char* host,
|
||||||
|
const char* user,
|
||||||
|
const char* passwd,
|
||||||
|
unsigned int port);
|
||||||
|
void STDCALL mysql_manager_close(MYSQL_MANAGER* con);
|
||||||
|
int STDCALL mysql_manager_command(MYSQL_MANAGER* con,
|
||||||
|
const char* cmd, int cmd_len);
|
||||||
|
int STDCALL mysql_manager_fetch_line(MYSQL_MANAGER* con,
|
||||||
|
char* res_buf,
|
||||||
|
int res_buf_size);
|
||||||
#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
|
#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
|
||||||
|
|
||||||
#ifdef USE_OLD_FUNCTIONS
|
#ifdef USE_OLD_FUNCTIONS
|
||||||
|
@ -164,6 +164,8 @@ int net_write_command(NET *net,unsigned char command,const char *packet,
|
|||||||
unsigned long len);
|
unsigned long len);
|
||||||
int net_real_write(NET *net,const char *packet,unsigned long len);
|
int net_real_write(NET *net,const char *packet,unsigned long len);
|
||||||
unsigned long my_net_read(NET *net);
|
unsigned long my_net_read(NET *net);
|
||||||
|
int my_connect(my_socket s, const struct sockaddr *name, uint namelen,
|
||||||
|
uint timeout);
|
||||||
|
|
||||||
struct rand_struct {
|
struct rand_struct {
|
||||||
unsigned long seed1,seed2,max_value;
|
unsigned long seed1,seed2,max_value;
|
||||||
|
@ -31,7 +31,7 @@ noinst_PROGRAMS = conf_to_src
|
|||||||
CHARSET_OBJS=@CHARSET_OBJS@
|
CHARSET_OBJS=@CHARSET_OBJS@
|
||||||
LTCHARSET_OBJS= ${CHARSET_OBJS:.o=.lo}
|
LTCHARSET_OBJS= ${CHARSET_OBJS:.o=.lo}
|
||||||
|
|
||||||
target_sources = libmysql.c net.c password.c \
|
target_sources = libmysql.c net.c password.c manager.c \
|
||||||
get_password.c errmsg.c
|
get_password.c errmsg.c
|
||||||
|
|
||||||
mystringsobjects = strmov.lo strxmov.lo strnmov.lo strmake.lo strend.lo \
|
mystringsobjects = strmov.lo strxmov.lo strnmov.lo strmake.lo strend.lo \
|
||||||
@ -56,7 +56,7 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
|
|||||||
thr_mutex.lo mulalloc.lo string.lo default.lo \
|
thr_mutex.lo mulalloc.lo string.lo default.lo \
|
||||||
my_compress.lo array.lo my_once.lo list.lo my_net.lo \
|
my_compress.lo array.lo my_once.lo list.lo my_net.lo \
|
||||||
charset.lo hash.lo mf_iocache.lo my_seek.lo \
|
charset.lo hash.lo mf_iocache.lo my_seek.lo \
|
||||||
my_pread.lo mf_cache.lo my_vsnprintf.lo
|
my_pread.lo mf_cache.lo my_vsnprintf.lo md5.lo
|
||||||
|
|
||||||
# Not needed in the minimum library
|
# Not needed in the minimum library
|
||||||
mysysobjects2 = getopt.lo getopt1.lo getvar.lo my_lib.lo
|
mysysobjects2 = getopt.lo getopt1.lo getvar.lo my_lib.lo
|
||||||
|
@ -140,12 +140,12 @@ static MYSQL* spawn_init(MYSQL* parent, const char* host,
|
|||||||
* A modified version of connect(). connect2() allows you to specify
|
* A modified version of connect(). connect2() allows you to specify
|
||||||
* a timeout value, in seconds, that we should wait until we
|
* a timeout value, in seconds, that we should wait until we
|
||||||
* derermine we can't connect to a particular host. If timeout is 0,
|
* derermine we can't connect to a particular host. If timeout is 0,
|
||||||
* connect2() will behave exactly like connect().
|
* my_connect() will behave exactly like connect().
|
||||||
*
|
*
|
||||||
* Base version coded by Steve Bernacki, Jr. <steve@navinet.net>
|
* Base version coded by Steve Bernacki, Jr. <steve@navinet.net>
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
static int connect2(my_socket s, const struct sockaddr *name, uint namelen,
|
int my_connect(my_socket s, const struct sockaddr *name, uint namelen,
|
||||||
uint timeout)
|
uint timeout)
|
||||||
{
|
{
|
||||||
#if defined(__WIN__) || defined(OS2)
|
#if defined(__WIN__) || defined(OS2)
|
||||||
@ -1523,7 +1523,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
|||||||
bzero((char*) &UNIXaddr,sizeof(UNIXaddr));
|
bzero((char*) &UNIXaddr,sizeof(UNIXaddr));
|
||||||
UNIXaddr.sun_family = AF_UNIX;
|
UNIXaddr.sun_family = AF_UNIX;
|
||||||
strmov(UNIXaddr.sun_path, unix_socket);
|
strmov(UNIXaddr.sun_path, unix_socket);
|
||||||
if (connect2(sock,(struct sockaddr *) &UNIXaddr, sizeof(UNIXaddr),
|
if (my_connect(sock,(struct sockaddr *) &UNIXaddr, sizeof(UNIXaddr),
|
||||||
mysql->options.connect_timeout) <0)
|
mysql->options.connect_timeout) <0)
|
||||||
{
|
{
|
||||||
DBUG_PRINT("error",("Got error %d on connect to local server",socket_errno));
|
DBUG_PRINT("error",("Got error %d on connect to local server",socket_errno));
|
||||||
@ -1623,7 +1623,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
sock_addr.sin_port = (ushort) htons((ushort) port);
|
sock_addr.sin_port = (ushort) htons((ushort) port);
|
||||||
if (connect2(sock,(struct sockaddr *) &sock_addr, sizeof(sock_addr),
|
if (my_connect(sock,(struct sockaddr *) &sock_addr, sizeof(sock_addr),
|
||||||
mysql->options.connect_timeout) <0)
|
mysql->options.connect_timeout) <0)
|
||||||
{
|
{
|
||||||
DBUG_PRINT("error",("Got error %d on connect to '%s'",socket_errno,host));
|
DBUG_PRINT("error",("Got error %d on connect to '%s'",socket_errno,host));
|
||||||
|
@ -45,7 +45,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\
|
|||||||
my_quick.c my_lockmem.c my_static.c \
|
my_quick.c my_lockmem.c my_static.c \
|
||||||
getopt.c getopt1.c getvar.c my_mkdir.c \
|
getopt.c getopt1.c getvar.c my_mkdir.c \
|
||||||
default.c my_compress.c checksum.c raid.cc my_net.c \
|
default.c my_compress.c checksum.c raid.cc my_net.c \
|
||||||
my_vsnprintf.c charset.c my_bitmap.c
|
my_vsnprintf.c charset.c my_bitmap.c md5.c
|
||||||
EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
|
EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
|
||||||
thr_mutex.c thr_rwlock.c
|
thr_mutex.c thr_rwlock.c
|
||||||
libmysys_a_LIBADD = @THREAD_LOBJECTS@
|
libmysys_a_LIBADD = @THREAD_LOBJECTS@
|
||||||
|
@ -55,7 +55,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \
|
|||||||
ha_heap.h ha_myisam.h ha_berkeley.h ha_innobase.h \
|
ha_heap.h ha_myisam.h ha_berkeley.h ha_innobase.h \
|
||||||
ha_gemini.h opt_range.h opt_ft.h \
|
ha_gemini.h opt_range.h opt_ft.h \
|
||||||
sql_select.h structs.h table.h sql_udf.h hash_filo.h\
|
sql_select.h structs.h table.h sql_udf.h hash_filo.h\
|
||||||
lex.h lex_symbol.h sql_acl.h sql_crypt.h md5.h \
|
lex.h lex_symbol.h sql_acl.h sql_crypt.h \
|
||||||
log_event.h mini_client.h sql_repl.h slave.h \
|
log_event.h mini_client.h sql_repl.h slave.h \
|
||||||
stacktrace.h sql_sort.h
|
stacktrace.h sql_sort.h
|
||||||
mysqld_SOURCES = sql_lex.cc sql_handler.cc \
|
mysqld_SOURCES = sql_lex.cc sql_handler.cc \
|
||||||
@ -82,7 +82,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \
|
|||||||
sql_udf.cc sql_analyse.cc sql_analyse.h sql_cache.cc \
|
sql_udf.cc sql_analyse.cc sql_analyse.h sql_cache.cc \
|
||||||
slave.cc sql_repl.cc sql_union.cc \
|
slave.cc sql_repl.cc sql_union.cc \
|
||||||
mini_client.cc mini_client_errors.c \
|
mini_client.cc mini_client_errors.c \
|
||||||
md5.c stacktrace.c
|
stacktrace.c
|
||||||
gen_lex_hash_SOURCES = gen_lex_hash.cc
|
gen_lex_hash_SOURCES = gen_lex_hash.cc
|
||||||
gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
|
gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
root secret
|
|
||||||
def_exec server /usr/sbin/mysqld --socket=/tmp/temp.sock --skip-grant --skip-net --datadir=/tmp
|
def_exec server /usr/sbin/mysqld --socket=/tmp/temp.sock --skip-grant --skip-net --datadir=/tmp
|
||||||
set_exec_con server root localhost /tmp/temp.sock
|
set_exec_con server root localhost /tmp/temp.sock
|
||||||
start_exec server 3
|
start_exec server 3
|
||||||
@ -9,4 +8,4 @@ start_exec server 3
|
|||||||
show_exec
|
show_exec
|
||||||
stop_exec server 3
|
stop_exec server 3
|
||||||
show_exec
|
show_exec
|
||||||
shutdown
|
quit
|
||||||
|
1
tools/mysqlmanager-sample.pwd
Normal file
1
tools/mysqlmanager-sample.pwd
Normal file
@ -0,0 +1 @@
|
|||||||
|
root:5ebe2294ecd0e0f08eab7690d2a6ee69
|
@ -20,27 +20,31 @@
|
|||||||
* Sasha Pachev <sasha@mysql.com>
|
* Sasha Pachev <sasha@mysql.com>
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include <my_global.h>
|
#include <global.h>
|
||||||
#include <my_sys.h>
|
#include <my_sys.h>
|
||||||
#include <my_pthread.h>
|
|
||||||
#include <m_ctype.h>
|
|
||||||
#include <m_string.h>
|
#include <m_string.h>
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
#include <mysql_version.h>
|
#include <mysql_version.h>
|
||||||
#include <mysqld_error.h>
|
#include <m_ctype.h>
|
||||||
|
#include <my_config.h>
|
||||||
#include <my_dir.h>
|
#include <my_dir.h>
|
||||||
#include <hash.h>
|
#include <hash.h>
|
||||||
|
#include <mysqld_error.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <violite.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <violite.h>
|
||||||
|
#include <my_pthread.h>
|
||||||
|
#include <md5.h>
|
||||||
|
|
||||||
#define MANAGER_VERSION "1.0"
|
#define MANAGER_VERSION "1.0"
|
||||||
#define MANAGER_GREETING "MySQL Server Management Daemon v." ## \
|
#define MANAGER_GREETING "MySQL Server Management Daemon v. 1.0"
|
||||||
MANAGER_VERSION
|
|
||||||
|
|
||||||
#define LOG_ERR 1
|
#define LOG_ERR 1
|
||||||
#define LOG_WARN 2
|
#define LOG_WARN 2
|
||||||
@ -117,16 +121,10 @@ int one_thread = 0; /* for debugging */
|
|||||||
|
|
||||||
#define MAX_CLIENT_MSG_LEN 256
|
#define MAX_CLIENT_MSG_LEN 256
|
||||||
#define NET_BLOCK 2048
|
#define NET_BLOCK 2048
|
||||||
#define MD5_LEN 32
|
#define MD5_LEN 16
|
||||||
#define ESCAPE_CHAR '\\'
|
#define ESCAPE_CHAR '\\'
|
||||||
#define EOL_CHAR '\n'
|
#define EOL_CHAR '\n'
|
||||||
|
|
||||||
#define MSG_OK 200
|
|
||||||
#define MSG_INFO 250
|
|
||||||
#define MSG_ACCESS 401
|
|
||||||
#define MSG_CLIENT_ERR 450
|
|
||||||
#define MSG_INTERNAL_ERR 500
|
|
||||||
|
|
||||||
/* access flags */
|
/* access flags */
|
||||||
|
|
||||||
#define PRIV_SHUTDOWN 1
|
#define PRIV_SHUTDOWN 1
|
||||||
@ -134,7 +132,7 @@ int one_thread = 0; /* for debugging */
|
|||||||
struct manager_thd
|
struct manager_thd
|
||||||
{
|
{
|
||||||
Vio* vio;
|
Vio* vio;
|
||||||
char user[MAX_USER_NAME];
|
char user[MAX_USER_NAME+1];
|
||||||
int priv_flags;
|
int priv_flags;
|
||||||
char* cmd_buf;
|
char* cmd_buf;
|
||||||
int fatal,finished;
|
int fatal,finished;
|
||||||
@ -142,7 +140,7 @@ struct manager_thd
|
|||||||
|
|
||||||
struct manager_user
|
struct manager_user
|
||||||
{
|
{
|
||||||
char user[MAX_USER_NAME];
|
char user[MAX_USER_NAME+1];
|
||||||
char md5_pass[MD5_LEN];
|
char md5_pass[MD5_LEN];
|
||||||
int user_len;
|
int user_len;
|
||||||
const char* error;
|
const char* error;
|
||||||
@ -171,6 +169,7 @@ static byte* get_user_key(const byte* u, uint* len,
|
|||||||
my_bool __attribute__((unused)) t);
|
my_bool __attribute__((unused)) t);
|
||||||
static uint tokenize_args(char* arg_start,char** arg_end);
|
static uint tokenize_args(char* arg_start,char** arg_end);
|
||||||
static void init_arg_array(char* arg_str,char** args,uint arg_count);
|
static void init_arg_array(char* arg_str,char** args,uint arg_count);
|
||||||
|
static int hex_val(char c);
|
||||||
|
|
||||||
typedef int (*manager_cmd_handler)(struct manager_thd*,char*,char*);
|
typedef int (*manager_cmd_handler)(struct manager_thd*,char*,char*);
|
||||||
|
|
||||||
@ -355,7 +354,7 @@ static int exec_line(struct manager_thd* thd,char* buf,char* buf_end)
|
|||||||
*p=tolower(*p);
|
*p=tolower(*p);
|
||||||
if (!(cmd=lookup_cmd(buf,(int)(p-buf))))
|
if (!(cmd=lookup_cmd(buf,(int)(p-buf))))
|
||||||
{
|
{
|
||||||
client_msg(thd->vio,MSG_CLIENT_ERR,
|
client_msg(thd->vio,MANAGER_CLIENT_ERR,
|
||||||
"Unrecognized command, type help to see list of supported\
|
"Unrecognized command, type help to see list of supported\
|
||||||
commands");
|
commands");
|
||||||
return 1;
|
return 1;
|
||||||
@ -377,13 +376,13 @@ static struct manager_cmd* lookup_cmd(char* s,int len)
|
|||||||
|
|
||||||
HANDLE_NOARG_DECL(ping)
|
HANDLE_NOARG_DECL(ping)
|
||||||
{
|
{
|
||||||
client_msg(thd->vio,MSG_OK,"Server management daemon is alive");
|
client_msg(thd->vio,MANAGER_OK,"Server management daemon is alive");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE_NOARG_DECL(quit)
|
HANDLE_NOARG_DECL(quit)
|
||||||
{
|
{
|
||||||
client_msg(thd->vio,MSG_OK,"Goodbye");
|
client_msg(thd->vio,MANAGER_OK,"Goodbye");
|
||||||
thd->finished=1;
|
thd->finished=1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -392,18 +391,18 @@ HANDLE_NOARG_DECL(help)
|
|||||||
{
|
{
|
||||||
struct manager_cmd* cmd = commands;
|
struct manager_cmd* cmd = commands;
|
||||||
Vio* vio = thd->vio;
|
Vio* vio = thd->vio;
|
||||||
client_msg_pre(vio,MSG_INFO,"Available commands:");
|
client_msg_pre(vio,MANAGER_INFO,"Available commands:");
|
||||||
for (;cmd->name;cmd++)
|
for (;cmd->name;cmd++)
|
||||||
{
|
{
|
||||||
client_msg_pre(vio,MSG_INFO,"%s - %s", cmd->name, cmd->help);
|
client_msg_pre(vio,MANAGER_INFO,"%s - %s", cmd->name, cmd->help);
|
||||||
}
|
}
|
||||||
client_msg_pre(vio,MSG_INFO,"End of help");
|
client_msg_pre(vio,MANAGER_INFO,"End of help");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE_NOARG_DECL(shutdown)
|
HANDLE_NOARG_DECL(shutdown)
|
||||||
{
|
{
|
||||||
client_msg(thd->vio,MSG_OK,"Shutdown started, goodbye");
|
client_msg(thd->vio,MANAGER_OK,"Shutdown started, goodbye");
|
||||||
thd->finished=1;
|
thd->finished=1;
|
||||||
shutdown_requested = 1;
|
shutdown_requested = 1;
|
||||||
if (!one_thread)
|
if (!one_thread)
|
||||||
@ -454,10 +453,10 @@ HANDLE_DECL(set_exec_con)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&lock_exec_hash);
|
pthread_mutex_unlock(&lock_exec_hash);
|
||||||
client_msg(thd->vio,MSG_OK,"Entry updated");
|
client_msg(thd->vio,MANAGER_OK,"Entry updated");
|
||||||
return 0;
|
return 0;
|
||||||
err:
|
err:
|
||||||
client_msg(thd->vio,MSG_CLIENT_ERR,error);
|
client_msg(thd->vio,MANAGER_CLIENT_ERR,error);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,10 +501,10 @@ HANDLE_DECL(start_exec)
|
|||||||
pthread_mutex_unlock(&e->lock);
|
pthread_mutex_unlock(&e->lock);
|
||||||
if (error)
|
if (error)
|
||||||
goto err;
|
goto err;
|
||||||
client_msg(thd->vio,MSG_OK,"'%s' started",e->ident);
|
client_msg(thd->vio,MANAGER_OK,"'%s' started",e->ident);
|
||||||
return 0;
|
return 0;
|
||||||
err:
|
err:
|
||||||
client_msg(thd->vio,MSG_CLIENT_ERR,error);
|
client_msg(thd->vio,MANAGER_CLIENT_ERR,error);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -556,11 +555,11 @@ HANDLE_DECL(stop_exec)
|
|||||||
pthread_mutex_unlock(&e->lock);
|
pthread_mutex_unlock(&e->lock);
|
||||||
if (!error)
|
if (!error)
|
||||||
{
|
{
|
||||||
client_msg(thd->vio,MSG_OK,"'%s' terminated",e->ident);
|
client_msg(thd->vio,MANAGER_OK,"'%s' terminated",e->ident);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
err:
|
err:
|
||||||
client_msg(thd->vio,MSG_CLIENT_ERR,error);
|
client_msg(thd->vio,MANAGER_CLIENT_ERR,error);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -588,10 +587,10 @@ HANDLE_DECL(def_exec)
|
|||||||
}
|
}
|
||||||
hash_insert(&exec_hash,(byte*)e);
|
hash_insert(&exec_hash,(byte*)e);
|
||||||
pthread_mutex_unlock(&lock_exec_hash);
|
pthread_mutex_unlock(&lock_exec_hash);
|
||||||
client_msg(thd->vio,MSG_OK,"Exec definition created");
|
client_msg(thd->vio,MANAGER_OK,"Exec definition created");
|
||||||
return 0;
|
return 0;
|
||||||
err:
|
err:
|
||||||
client_msg(thd->vio,MSG_CLIENT_ERR,error);
|
client_msg(thd->vio,MANAGER_CLIENT_ERR,error);
|
||||||
if (e)
|
if (e)
|
||||||
manager_exec_free(e);
|
manager_exec_free(e);
|
||||||
return 1;
|
return 1;
|
||||||
@ -600,7 +599,7 @@ err:
|
|||||||
HANDLE_NOARG_DECL(show_exec)
|
HANDLE_NOARG_DECL(show_exec)
|
||||||
{
|
{
|
||||||
uint i;
|
uint i;
|
||||||
client_msg_pre(thd->vio,MSG_INFO,"Exec_def\tPid\tExit_status\tCon_info\
|
client_msg_pre(thd->vio,MANAGER_INFO,"Exec_def\tPid\tExit_status\tCon_info\
|
||||||
\tArguments");
|
\tArguments");
|
||||||
pthread_mutex_lock(&lock_exec_hash);
|
pthread_mutex_lock(&lock_exec_hash);
|
||||||
for (i=0;i<exec_hash.records;i++)
|
for (i=0;i<exec_hash.records;i++)
|
||||||
@ -609,7 +608,7 @@ HANDLE_NOARG_DECL(show_exec)
|
|||||||
manager_exec_print(thd->vio,e);
|
manager_exec_print(thd->vio,e);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&lock_exec_hash);
|
pthread_mutex_unlock(&lock_exec_hash);
|
||||||
client_msg(thd->vio,MSG_INFO,"End");
|
client_msg(thd->vio,MANAGER_INFO,"End");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -695,7 +694,7 @@ static char* arg_strmov(char* dest, const char* src, int n)
|
|||||||
|
|
||||||
static void manager_exec_print(Vio* vio,struct manager_exec* e)
|
static void manager_exec_print(Vio* vio,struct manager_exec* e)
|
||||||
{
|
{
|
||||||
char buf[MAX_CLIENT_MSG_LEN];
|
char buf[MAX_MYSQL_MANAGER_MSG];
|
||||||
char* p=buf,*buf_end=buf+sizeof(buf)-1;
|
char* p=buf,*buf_end=buf+sizeof(buf)-1;
|
||||||
char** args=e->args;
|
char** args=e->args;
|
||||||
|
|
||||||
@ -733,17 +732,45 @@ static void manager_exec_print(Vio* vio,struct manager_exec* e)
|
|||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
*p=0;
|
*p=0;
|
||||||
client_msg_pre(vio,MSG_INFO,buf);
|
client_msg_pre(vio,MANAGER_INFO,buf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int authenticate(struct manager_thd* thd)
|
static int authenticate(struct manager_thd* thd)
|
||||||
{
|
{
|
||||||
char* buf_end;
|
char* buf_end,*buf,*p,*p_end;
|
||||||
client_msg(thd->vio,MSG_INFO, manager_greeting);
|
my_MD5_CTX context;
|
||||||
|
uchar digest[MD5_LEN];
|
||||||
|
struct manager_user* u;
|
||||||
|
char c;
|
||||||
|
|
||||||
|
client_msg(thd->vio,MANAGER_INFO, manager_greeting);
|
||||||
if (!(buf_end=read_line(thd)))
|
if (!(buf_end=read_line(thd)))
|
||||||
return -1;
|
return -1;
|
||||||
client_msg(thd->vio,MSG_OK,"OK");
|
for (buf=thd->cmd_buf,p=thd->user,p_end=p+MAX_USER_NAME;
|
||||||
|
buf<buf_end && (c=*buf) && p<p_end; buf++,p++)
|
||||||
|
{
|
||||||
|
if (isspace(c))
|
||||||
|
{
|
||||||
|
*p=0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*p=c;
|
||||||
|
}
|
||||||
|
if (p==p_end || buf==buf_end)
|
||||||
|
return 1;
|
||||||
|
if (!(u=(struct manager_user*)hash_search(&user_hash,thd->user,
|
||||||
|
(uint)(p-thd->user))))
|
||||||
|
return 1;
|
||||||
|
for (;isspace(*buf) && buf<buf_end;buf++) /* empty */;
|
||||||
|
|
||||||
|
my_MD5Init(&context);
|
||||||
|
my_MD5Update(&context,buf,(uint)(buf_end-buf));
|
||||||
|
my_MD5Final(digest,&context);
|
||||||
|
if (memcmp(u->md5_pass,digest,MD5_LEN))
|
||||||
|
return 1;
|
||||||
|
client_msg(thd->vio,MANAGER_OK,"OK");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -823,7 +850,7 @@ LOG_MSG_FUNC(info,INFO)
|
|||||||
#ifndef DBUG_OFF
|
#ifndef DBUG_OFF
|
||||||
LOG_MSG_FUNC(debug,DEBUG)
|
LOG_MSG_FUNC(debug,DEBUG)
|
||||||
#else
|
#else
|
||||||
void log_debug(char* __attribute__((unused)) fmt,...) {}
|
inline void log_debug(char* __attribute__((unused)) fmt,...) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static pthread_handler_decl(process_launcher_messages,
|
static pthread_handler_decl(process_launcher_messages,
|
||||||
@ -920,7 +947,7 @@ static void client_msg_raw(Vio* vio, int err_code, int pre, const char* fmt,
|
|||||||
*p++='\r';
|
*p++='\r';
|
||||||
*p++='\n';
|
*p++='\n';
|
||||||
if (vio_write(vio,buf,(uint)(p-buf))<=0)
|
if (vio_write(vio,buf,(uint)(p-buf))<=0)
|
||||||
log_err("Failed writing to client: errno=%d");
|
log_err("Failed writing to client: errno=%d",errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void client_msg(Vio* vio, int err_code, const char* fmt, ...)
|
static void client_msg(Vio* vio, int err_code, const char* fmt, ...)
|
||||||
@ -950,6 +977,7 @@ static char* read_line(struct manager_thd* thd)
|
|||||||
if ((len=vio_read(thd->vio,p,read_len))<=0)
|
if ((len=vio_read(thd->vio,p,read_len))<=0)
|
||||||
{
|
{
|
||||||
log_err("Error reading command from client");
|
log_err("Error reading command from client");
|
||||||
|
thd->fatal=1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
block_end=p+len;
|
block_end=p+len;
|
||||||
@ -978,7 +1006,7 @@ static char* read_line(struct manager_thd* thd)
|
|||||||
return p_back;
|
return p_back;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
client_msg(thd->vio,MSG_CLIENT_ERR,"Command line too long");
|
client_msg(thd->vio,MANAGER_CLIENT_ERR,"Command line too long");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1089,7 +1117,7 @@ static int parse_args(int argc, char **argv)
|
|||||||
one_thread=1;
|
one_thread=1;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
manager_pw_file=MANAGER_PW_FILE;
|
manager_pw_file=optarg;
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
manager_connect_retries=atoi(optarg);
|
manager_connect_retries=atoi(optarg);
|
||||||
@ -1184,7 +1212,7 @@ static int run_server_loop()
|
|||||||
|
|
||||||
if (authenticate(thd))
|
if (authenticate(thd))
|
||||||
{
|
{
|
||||||
client_msg(vio,MSG_ACCESS, "Access denied");
|
client_msg(vio,MANAGER_ACCESS, "Access denied");
|
||||||
manager_thd_free(thd);
|
manager_thd_free(thd);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1198,7 +1226,7 @@ static int run_server_loop()
|
|||||||
}
|
}
|
||||||
else if (pthread_create(&th,0,process_connection,(void*)thd))
|
else if (pthread_create(&th,0,process_connection,(void*)thd))
|
||||||
{
|
{
|
||||||
client_msg(vio,MSG_INTERNAL_ERR,"Could not create thread, errno=%d",
|
client_msg(vio,MANAGER_INTERNAL_ERR,"Could not create thread, errno=%d",
|
||||||
errno);
|
errno);
|
||||||
manager_thd_free(thd);
|
manager_thd_free(thd);
|
||||||
continue;
|
continue;
|
||||||
@ -1351,15 +1379,24 @@ static void manager_exec_free(void* e)
|
|||||||
my_free(e,MYF(0));
|
my_free(e,MYF(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int hex_val(char c)
|
||||||
|
{
|
||||||
|
if (isdigit(c))
|
||||||
|
return c-'0';
|
||||||
|
c=tolower(c);
|
||||||
|
return c-'a'+10;
|
||||||
|
}
|
||||||
|
|
||||||
static struct manager_user* manager_user_new(char* buf)
|
static struct manager_user* manager_user_new(char* buf)
|
||||||
{
|
{
|
||||||
struct manager_user* tmp;
|
struct manager_user* tmp;
|
||||||
char* p,*user_end;
|
char* p,*user_end,*p_end;
|
||||||
char c;
|
char c;
|
||||||
if (!(tmp=(struct manager_user*)my_malloc(sizeof(*tmp),MYF(0))))
|
if (!(tmp=(struct manager_user*)my_malloc(sizeof(*tmp),MYF(0))))
|
||||||
return 0;
|
return 0;
|
||||||
p=tmp->user;
|
p=tmp->user;
|
||||||
user_end=p+MAX_USER_NAME-1;
|
tmp->error=0;
|
||||||
|
user_end=p+MAX_USER_NAME;
|
||||||
for (;(c=*buf) && p<user_end;buf++)
|
for (;(c=*buf) && p<user_end;buf++)
|
||||||
{
|
{
|
||||||
if (c == ':')
|
if (c == ':')
|
||||||
@ -1378,13 +1415,18 @@ static struct manager_user* manager_user_new(char* buf)
|
|||||||
tmp->error="Username too long";
|
tmp->error="Username too long";
|
||||||
if (tmp->error)
|
if (tmp->error)
|
||||||
return tmp;
|
return tmp;
|
||||||
if (strlen(buf) < MD5_LEN)
|
if (strlen(buf) < 2*MD5_LEN)
|
||||||
{
|
{
|
||||||
tmp->error="Invalid MD5 sum, too short";
|
tmp->error="Invalid MD5 sum, too short";
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
memcpy(tmp->md5_pass,buf,MD5_LEN);
|
p=tmp->md5_pass;
|
||||||
tmp->error=0;
|
p_end=p+MD5_LEN;
|
||||||
|
for (; p<p_end;p++,buf+=2)
|
||||||
|
{
|
||||||
|
*p=hex_val(*buf)*16+hex_val(buf[1]);
|
||||||
|
}
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user