Commit 7d6644ad authored by unknown's avatar unknown

fixed coredump, and changed mngd->manager


sql/sql_acl.cc:
  fixed coredump when running without SSL
tools/Makefile.am:
  mysqlmngd -> mysqlmanager
tools/mysqlmanager.c:
  mngd->manager
BitKeeper/etc/ignore:
  Added tools/mysqlmanager to the ignore list
parent cda4e4d2
...@@ -399,3 +399,4 @@ tools/mysys_priv.h ...@@ -399,3 +399,4 @@ tools/mysys_priv.h
vio/test-sslclient vio/test-sslclient
vio/test-sslserver vio/test-sslserver
vio/viotest-ssl vio/viotest-ssl
tools/mysqlmanager
...@@ -61,7 +61,9 @@ public: ...@@ -61,7 +61,9 @@ public:
uint hostname_length; uint hostname_length;
char *user,*password; char *user,*password;
ulong salt[2]; ulong salt[2];
#ifdef HAVE_OPENSSL
char *ssl_type, *ssl_cipher, *ssl_issuer, *ssl_subject; char *ssl_type, *ssl_cipher, *ssl_issuer, *ssl_subject;
#endif
}; };
class ACL_DB :public ACL_ACCESS class ACL_DB :public ACL_ACCESS
...@@ -200,10 +202,12 @@ int acl_init(bool dont_read_acl_tables) ...@@ -200,10 +202,12 @@ int acl_init(bool dont_read_acl_tables)
update_hostname(&user.host,get_field(&mem, table,0)); update_hostname(&user.host,get_field(&mem, table,0));
user.user=get_field(&mem, table,1); user.user=get_field(&mem, table,1);
user.password=get_field(&mem, table,2); user.password=get_field(&mem, table,2);
#ifdef HAVE_OPENSSL
user.ssl_type=get_field(&mem, table,17); user.ssl_type=get_field(&mem, table,17);
user.ssl_cipher=get_field(&mem, table,18); user.ssl_cipher=get_field(&mem, table,18);
user.ssl_issuer=get_field(&mem, table,19); user.ssl_issuer=get_field(&mem, table,19);
user.ssl_subject=get_field(&mem, table,20); user.ssl_subject=get_field(&mem, table,20);
#endif
if (user.password && (length=(uint) strlen(user.password)) == 8 && if (user.password && (length=(uint) strlen(user.password)) == 8 &&
protocol_version == PROTOCOL_VERSION) protocol_version == PROTOCOL_VERSION)
{ {
...@@ -2416,6 +2420,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user) ...@@ -2416,6 +2420,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
global.append(passd_buff); global.append(passd_buff);
global.append('\''); global.append('\'');
} }
#ifdef HAVE_OPENSSL
/* SSL grant stuff */ /* SSL grant stuff */
DBUG_PRINT("info",("acl_user->ssl_type=%s",acl_user->ssl_type)); DBUG_PRINT("info",("acl_user->ssl_type=%s",acl_user->ssl_type));
DBUG_PRINT("info",("acl_user->ssl_cipher=%s",acl_user->ssl_cipher)); DBUG_PRINT("info",("acl_user->ssl_cipher=%s",acl_user->ssl_cipher));
...@@ -2439,7 +2444,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user) ...@@ -2439,7 +2444,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
} }
} }
} }
#endif
if (want_access & GRANT_ACL) if (want_access & GRANT_ACL)
global.append(" WITH GRANT OPTION",18); global.append(" WITH GRANT OPTION",18);
thd->packet.length(0); thd->packet.length(0);
......
...@@ -3,9 +3,9 @@ INCLUDES = -I$(srcdir)/../include $(openssl_includes) \ ...@@ -3,9 +3,9 @@ INCLUDES = -I$(srcdir)/../include $(openssl_includes) \
-I.. -I..
LIBS = @TOOLS_LIBS@ LIBS = @TOOLS_LIBS@
LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysql_r/libmysqlclient_r.la LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysql_r/libmysqlclient_r.la
bin_PROGRAMS = mysqlmngd bin_PROGRAMS = mysqlmanager
mysqlmngd_SOURCES = mysqlmngd.c my_vsnprintf.c mysqlmanager_SOURCES = mysqlmanager.c
#mysqltest_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) mysqlmanager_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
DEFS = -DUNDEF_THREADS_HACK DEFS = -DUNDEF_THREADS_HACK
# Don't update the files from bitkeeper # Don't update the files from bitkeeper
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
#endif #endif
#ifndef MNGD_LOG_FILE #ifndef MNGD_LOG_FILE
#define MNGD_LOG_FILE "/var/log/mysqlmngd.log" #define MNGD_LOG_FILE "/var/log/mysqlmanager.log"
#endif #endif
#ifndef MNGD_BACK_LOG #ifndef MNGD_BACK_LOG
...@@ -68,22 +68,22 @@ ...@@ -68,22 +68,22 @@
#define MAX_USER_NAME 16 #define MAX_USER_NAME 16
#endif #endif
/* Variable naming convention - if starts with mngd_, either is set /* Variable naming convention - if starts with manager_, either is set
directly by the user, or used closely in ocnjunction with a variable directly by the user, or used closely in ocnjunction with a variable
set by the user set by the user
*/ */
uint mngd_port = MNGD_PORT; uint manager_port = MNGD_PORT;
FILE* errfp; FILE* errfp;
const char* mngd_log_file = MNGD_LOG_FILE; const char* manager_log_file = MNGD_LOG_FILE;
pthread_mutex_t lock_log, lock_shutdown; pthread_mutex_t lock_log, lock_shutdown;
int mngd_sock = -1; int manager_sock = -1;
struct sockaddr_in mngd_addr; struct sockaddr_in manager_addr;
ulong mngd_bind_addr = INADDR_ANY; ulong manager_bind_addr = INADDR_ANY;
int mngd_back_log = MNGD_BACK_LOG; int manager_back_log = MNGD_BACK_LOG;
int in_shutdown = 0, shutdown_requested=0; int in_shutdown = 0, shutdown_requested=0;
const char* mngd_greeting = MNGD_GREETING; const char* manager_greeting = MNGD_GREETING;
uint mngd_max_cmd_len = MNGD_MAX_CMD_LEN; uint manager_max_cmd_len = MNGD_MAX_CMD_LEN;
/* messages */ /* messages */
...@@ -103,7 +103,7 @@ uint mngd_max_cmd_len = MNGD_MAX_CMD_LEN; ...@@ -103,7 +103,7 @@ uint mngd_max_cmd_len = MNGD_MAX_CMD_LEN;
#define PRIV_SHUTDOWN 1 #define PRIV_SHUTDOWN 1
struct mngd_thd struct manager_thd
{ {
Vio* vio; Vio* vio;
char user[MAX_USER_NAME]; char user[MAX_USER_NAME];
...@@ -112,25 +112,25 @@ struct mngd_thd ...@@ -112,25 +112,25 @@ struct mngd_thd
int fatal,finished; int fatal,finished;
}; };
struct mngd_thd* mngd_thd_new(Vio* vio); struct manager_thd* manager_thd_new(Vio* vio);
void mngd_thd_free(struct mngd_thd* thd); void manager_thd_free(struct manager_thd* thd);
typedef int (*mngd_cmd_handler)(struct mngd_thd*,char*,char*); typedef int (*manager_cmd_handler)(struct manager_thd*,char*,char*);
struct mngd_cmd struct manager_cmd
{ {
const char* name; const char* name;
const char* help; const char* help;
mngd_cmd_handler handler_func; manager_cmd_handler handler_func;
int len; int len;
}; };
#define HANDLE_DECL(com) static int handle_ ## com (struct mngd_thd* thd,\ #define HANDLE_DECL(com) static int handle_ ## com (struct manager_thd* thd,\
char* args_start,char* args_end) char* args_start,char* args_end)
#define HANDLE_NOARG_DECL(com) static int handle_ ## com \ #define HANDLE_NOARG_DECL(com) static int handle_ ## com \
(struct mngd_thd* thd, char* __attribute__((unused)) args_start,\ (struct manager_thd* thd, char* __attribute__((unused)) args_start,\
char* __attribute__((unused)) args_end) char* __attribute__((unused)) args_end)
...@@ -139,7 +139,7 @@ HANDLE_NOARG_DECL(quit); ...@@ -139,7 +139,7 @@ HANDLE_NOARG_DECL(quit);
HANDLE_NOARG_DECL(help); HANDLE_NOARG_DECL(help);
HANDLE_NOARG_DECL(shutdown); HANDLE_NOARG_DECL(shutdown);
struct mngd_cmd commands[] = struct manager_cmd commands[] =
{ {
{"ping", "Check if this server is alive", handle_ping,4}, {"ping", "Check if this server is alive", handle_ping,4},
{"quit", "Finish session", handle_quit,4}, {"quit", "Finish session", handle_quit,4},
...@@ -165,22 +165,22 @@ struct option long_options[] = ...@@ -165,22 +165,22 @@ struct option long_options[] =
static void die(const char* fmt,...); static void die(const char* fmt,...);
static void print_time(FILE* fp); static void print_time(FILE* fp);
static void clean_up(); static void clean_up();
static struct mngd_cmd* lookup_cmd(char* s,int len); static struct manager_cmd* lookup_cmd(char* s,int len);
static void client_msg(Vio* vio,int err_code,const char* fmt,...); static void client_msg(Vio* vio,int err_code,const char* fmt,...);
static void client_msg_pre(Vio* vio,int err_code,const char* fmt,...); static void client_msg_pre(Vio* vio,int err_code,const char* fmt,...);
static void client_msg_raw(Vio* vio,int err_code,int pre,const char* fmt, static void client_msg_raw(Vio* vio,int err_code,int pre,const char* fmt,
va_list args); va_list args);
static int authenticate(struct mngd_thd* thd); static int authenticate(struct manager_thd* thd);
static char* read_line(struct mngd_thd* thd); /* returns pointer to end of static char* read_line(struct manager_thd* thd); /* returns pointer to end of
line line
*/ */
static pthread_handler_decl(process_connection,arg); static pthread_handler_decl(process_connection,arg);
static int exec_line(struct mngd_thd* thd,char* buf,char* buf_end); static int exec_line(struct manager_thd* thd,char* buf,char* buf_end);
static int exec_line(struct mngd_thd* thd,char* buf,char* buf_end) static int exec_line(struct manager_thd* thd,char* buf,char* buf_end)
{ {
char* p=buf; char* p=buf;
struct mngd_cmd* cmd; struct manager_cmd* cmd;
for (;p<buf_end && !isspace(*p);p++) for (;p<buf_end && !isspace(*p);p++)
*p=tolower(*p); *p=tolower(*p);
if (!(cmd=lookup_cmd(buf,(int)(p-buf)))) if (!(cmd=lookup_cmd(buf,(int)(p-buf))))
...@@ -193,9 +193,9 @@ static int exec_line(struct mngd_thd* thd,char* buf,char* buf_end) ...@@ -193,9 +193,9 @@ static int exec_line(struct mngd_thd* thd,char* buf,char* buf_end)
return cmd->handler_func(thd,p,buf_end); return cmd->handler_func(thd,p,buf_end);
} }
static struct mngd_cmd* lookup_cmd(char* s,int len) static struct manager_cmd* lookup_cmd(char* s,int len)
{ {
struct mngd_cmd* cmd = commands; struct manager_cmd* cmd = commands;
for (;cmd->name;cmd++) for (;cmd->name;cmd++)
{ {
if (cmd->len == len && !memcmp(cmd->name,s,len)) if (cmd->len == len && !memcmp(cmd->name,s,len))
...@@ -219,7 +219,7 @@ HANDLE_NOARG_DECL(quit) ...@@ -219,7 +219,7 @@ HANDLE_NOARG_DECL(quit)
HANDLE_NOARG_DECL(help) HANDLE_NOARG_DECL(help)
{ {
struct mngd_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,MSG_INFO,"Available commands:");
for (;cmd->name;cmd++) for (;cmd->name;cmd++)
...@@ -238,10 +238,10 @@ HANDLE_NOARG_DECL(shutdown) ...@@ -238,10 +238,10 @@ HANDLE_NOARG_DECL(shutdown)
return 0; return 0;
} }
static int authenticate(struct mngd_thd* thd) static int authenticate(struct manager_thd* thd)
{ {
char* buf_end; char* buf_end;
client_msg(thd->vio,MSG_INFO, mngd_greeting); client_msg(thd->vio,MSG_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"); client_msg(thd->vio,MSG_OK,"OK");
...@@ -327,7 +327,7 @@ LOG_MSG_FUNC(debug,DEBUG) ...@@ -327,7 +327,7 @@ LOG_MSG_FUNC(debug,DEBUG)
static pthread_handler_decl(process_connection,arg) static pthread_handler_decl(process_connection,arg)
{ {
struct mngd_thd* thd = (struct mngd_thd*)arg; struct manager_thd* thd = (struct manager_thd*)arg;
my_thread_init(); my_thread_init();
pthread_detach_this_thread(); pthread_detach_this_thread();
for (;!thd->finished;) for (;!thd->finished;)
...@@ -340,7 +340,7 @@ static pthread_handler_decl(process_connection,arg) ...@@ -340,7 +340,7 @@ static pthread_handler_decl(process_connection,arg)
break; break;
} }
} }
mngd_thd_free(thd); manager_thd_free(thd);
pthread_exit(0); pthread_exit(0);
} }
...@@ -377,10 +377,10 @@ static void client_msg_pre(Vio* vio, int err_code, const char* fmt, ...) ...@@ -377,10 +377,10 @@ static void client_msg_pre(Vio* vio, int err_code, const char* fmt, ...)
client_msg_raw(vio,err_code,1,fmt,args); client_msg_raw(vio,err_code,1,fmt,args);
} }
static char* read_line(struct mngd_thd* thd) static char* read_line(struct manager_thd* thd)
{ {
char* p=thd->cmd_buf; char* p=thd->cmd_buf;
char* buf_end = thd->cmd_buf + mngd_max_cmd_len; char* buf_end = thd->cmd_buf + manager_max_cmd_len;
int escaped = 0; int escaped = 0;
for (;p<buf_end;) for (;p<buf_end;)
{ {
...@@ -422,13 +422,13 @@ static char* read_line(struct mngd_thd* thd) ...@@ -422,13 +422,13 @@ static char* read_line(struct mngd_thd* thd)
return 0; return 0;
} }
struct mngd_thd* mngd_thd_new(Vio* vio) struct manager_thd* manager_thd_new(Vio* vio)
{ {
struct mngd_thd* tmp; struct manager_thd* tmp;
if (!(tmp=(struct mngd_thd*)my_malloc(sizeof(*tmp)+mngd_max_cmd_len, if (!(tmp=(struct manager_thd*)my_malloc(sizeof(*tmp)+manager_max_cmd_len,
MYF(0)))) MYF(0))))
{ {
log_err("Out of memory in mngd_thd_new"); log_err("Out of memory in manager_thd_new");
return 0; return 0;
} }
tmp->vio=vio; tmp->vio=vio;
...@@ -439,7 +439,7 @@ struct mngd_thd* mngd_thd_new(Vio* vio) ...@@ -439,7 +439,7 @@ struct mngd_thd* mngd_thd_new(Vio* vio)
return tmp; return tmp;
} }
void mngd_thd_free(struct mngd_thd* thd) void manager_thd_free(struct manager_thd* thd)
{ {
if (thd->vio) if (thd->vio)
vio_close(thd->vio); vio_close(thd->vio);
...@@ -457,8 +457,8 @@ static void clean_up() ...@@ -457,8 +457,8 @@ static void clean_up()
in_shutdown = 1; in_shutdown = 1;
pthread_mutex_unlock(&lock_shutdown); pthread_mutex_unlock(&lock_shutdown);
log_info("Shutdown started"); log_info("Shutdown started");
if (mngd_sock) if (manager_sock)
close(mngd_sock); close(manager_sock);
log_info("Ended"); log_info("Ended");
if (errfp != stderr) if (errfp != stderr)
fclose(errfp); fclose(errfp);
...@@ -505,21 +505,21 @@ int parse_args(int argc, char **argv) ...@@ -505,21 +505,21 @@ int parse_args(int argc, char **argv)
DBUG_PUSH(optarg ? optarg : "d:t:O,/tmp/mysqlmgrd.trace"); DBUG_PUSH(optarg ? optarg : "d:t:O,/tmp/mysqlmgrd.trace");
break; break;
case 'P': case 'P':
mngd_port=atoi(optarg); manager_port=atoi(optarg);
break; break;
case 'm': case 'm':
mngd_max_cmd_len=atoi(optarg); manager_max_cmd_len=atoi(optarg);
break; break;
case 'g': case 'g':
mngd_greeting=optarg; manager_greeting=optarg;
case 'b': case 'b':
mngd_bind_addr = inet_addr(optarg); manager_bind_addr = inet_addr(optarg);
break; break;
case 'B': case 'B':
mngd_back_log = atoi(optarg); manager_back_log = atoi(optarg);
break; break;
case 'l': case 'l':
mngd_log_file=optarg; manager_log_file=optarg;
break; break;
case 'V': case 'V':
print_version(); print_version();
...@@ -539,16 +539,16 @@ int init_server() ...@@ -539,16 +539,16 @@ int init_server()
{ {
int arg=1; int arg=1;
log_info("Started"); log_info("Started");
if ((mngd_sock=socket(PF_INET,SOCK_STREAM,0)) < 0) if ((manager_sock=socket(PF_INET,SOCK_STREAM,0)) < 0)
die("Could not create socket"); die("Could not create socket");
bzero((char*)&mngd_addr, sizeof(mngd_addr)); bzero((char*)&manager_addr, sizeof(manager_addr));
mngd_addr.sin_family = AF_INET; manager_addr.sin_family = AF_INET;
mngd_addr.sin_addr.s_addr = mngd_bind_addr; manager_addr.sin_addr.s_addr = manager_bind_addr;
mngd_addr.sin_port = htons(mngd_port); manager_addr.sin_port = htons(manager_port);
setsockopt(mngd_sock,SOL_SOCKET, SO_REUSEADDR,(char*)&arg,sizeof(arg)); setsockopt(manager_sock,SOL_SOCKET, SO_REUSEADDR,(char*)&arg,sizeof(arg));
if (bind(mngd_sock,(struct sockaddr*)&mngd_addr, sizeof(mngd_addr)) < 0) if (bind(manager_sock,(struct sockaddr*)&manager_addr, sizeof(manager_addr)) < 0)
die("Could not bind"); die("Could not bind");
if (listen(mngd_sock,mngd_back_log) < 0) if (listen(manager_sock,manager_back_log) < 0)
die("Could not listen"); die("Could not listen");
return 0; return 0;
...@@ -557,14 +557,14 @@ int init_server() ...@@ -557,14 +557,14 @@ int init_server()
int run_server_loop() int run_server_loop()
{ {
pthread_t th; pthread_t th;
struct mngd_thd *thd; struct manager_thd *thd;
int client_sock,len; int client_sock,len;
Vio* vio; Vio* vio;
for (;!shutdown_requested;) for (;!shutdown_requested;)
{ {
len=sizeof(struct sockaddr_in); len=sizeof(struct sockaddr_in);
if ((client_sock=accept(mngd_sock,(struct sockaddr*)&mngd_addr,&len))<0) if ((client_sock=accept(manager_sock,(struct sockaddr*)&manager_addr,&len))<0)
{ {
if (shutdown_requested) if (shutdown_requested)
break; break;
...@@ -583,7 +583,7 @@ int run_server_loop() ...@@ -583,7 +583,7 @@ int run_server_loop()
close(client_sock); close(client_sock);
continue; continue;
} }
if (!(thd=mngd_thd_new(vio))) if (!(thd=manager_thd_new(vio)))
{ {
log_err("Could not create thread object"); log_err("Could not create thread object");
vio_close(vio); vio_close(vio);
...@@ -593,7 +593,7 @@ int run_server_loop() ...@@ -593,7 +593,7 @@ int run_server_loop()
if (authenticate(thd)) if (authenticate(thd))
{ {
client_msg(vio,MSG_ACCESS, "Access denied"); client_msg(vio,MSG_ACCESS, "Access denied");
mngd_thd_free(thd); manager_thd_free(thd);
continue; continue;
} }
if (shutdown_requested) if (shutdown_requested)
...@@ -602,7 +602,7 @@ int run_server_loop() ...@@ -602,7 +602,7 @@ int run_server_loop()
{ {
client_msg(vio,MSG_INTERNAL_ERR,"Could not create thread, errno=%d", client_msg(vio,MSG_INTERNAL_ERR,"Could not create thread, errno=%d",
errno); errno);
mngd_thd_free(thd); manager_thd_free(thd);
continue; continue;
} }
} }
...@@ -612,8 +612,8 @@ int run_server_loop() ...@@ -612,8 +612,8 @@ int run_server_loop()
FILE* open_log_stream() FILE* open_log_stream()
{ {
FILE* fp; FILE* fp;
if (!(fp=fopen(mngd_log_file,"a"))) if (!(fp=fopen(manager_log_file,"a")))
die("Could not open log file '%s'", mngd_log_file); die("Could not open log file '%s'", manager_log_file);
return fp; return fp;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment