summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bzrignore1
-rw-r--r--client/Makefile.am2
-rw-r--r--client/mysqlmanager-pwgen.c153
-rw-r--r--client/mysqlmanagerc.c6
-rw-r--r--include/my_sys.h3
-rw-r--r--mysql-test/mysql-test-run.sh31
-rw-r--r--mysys/my_read.c14
-rw-r--r--tools/managertest1.nc2
-rw-r--r--tools/mysqlmanager.c159
9 files changed, 344 insertions, 27 deletions
diff --git a/.bzrignore b/.bzrignore
index 3282a9a0e85..7807a43c947 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -413,3 +413,4 @@ vio/test-ssl
vio/test-sslclient
vio/test-sslserver
vio/viotest-ssl
+client/mysqlmanager-pwgen
diff --git a/client/Makefile.am b/client/Makefile.am
index 365d013f074..a90bfbad7be 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -23,7 +23,7 @@ noinst_HEADERS = client_priv.h
LIBS = @CLIENT_LIBS@
LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysql/libmysqlclient.la
bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow \
- mysqldump mysqlimport mysqltest mysqlbinlog mysqlmanagerc
+ mysqldump mysqlimport mysqltest mysqlbinlog mysqlmanagerc mysqlmanager-pwgen
noinst_PROGRAMS = insert_test select_test thread_test
noinst_HEADERS = sql_string.h completion_hash.h my_readline.h
mysql_SOURCES = mysql.cc readline.cc sql_string.cc completion_hash.cc
diff --git a/client/mysqlmanager-pwgen.c b/client/mysqlmanager-pwgen.c
new file mode 100644
index 00000000000..eca9bfa23ea
--- /dev/null
+++ b/client/mysqlmanager-pwgen.c
@@ -0,0 +1,153 @@
+/* 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_PWGEN_VERSION "1.0"
+
+#include <my_global.h>
+#include <m_ctype.h>
+#include <my_sys.h>
+#include <m_string.h>
+#include <mysql_version.h>
+#include <errno.h>
+#include <getopt.h>
+#include <md5.h>
+
+const char* outfile=0,*user="root";
+
+struct option long_options[] =
+{
+ {"output-file",required_argument,0,'o'},
+ {"user",required_argument,0,'u'},
+ {"help",no_argument,0,'?'},
+ {"version",no_argument,0,'V'},
+ {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_PWGEN_VERSION,
+ MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
+}
+
+void usage()
+{
+ print_version();
+ printf("MySQL AB, by Sasha\n");
+ printf("This software comes with ABSOLUTELY NO WARRANTY\n\n");
+ printf("Generates a password file to be used by mysqltest.\n\n");
+ printf("Usage: %s [OPTIONS]\n", my_progname);
+ printf("-?,--help Display this message and exit\n\
+-V,--version Display version info\n\
+-u,--user= Put given user in the password file\n\
+-o,--output-file= Write the output to the file with the given name\n");
+}
+
+int parse_args(int argc, char** argv)
+{
+ int c,option_index=0;
+ while ((c=getopt_long(argc,argv,"?Vu:o:",long_options,&option_index))
+ != EOF)
+ {
+ switch (c)
+ {
+ case 'o':
+ outfile=optarg;
+ break;
+ case 'u':
+ user=optarg;
+ break;
+ case '?':
+ usage();
+ exit(0);
+ case 'V':
+ print_version();
+ exit(0);
+ default:
+ usage();
+ exit(1);
+ }
+ }
+ return 0;
+}
+
+void get_pass(char* pw, int len)
+{
+ FILE* fp;
+ char* pw_end=pw+len;
+/* /dev/random is more secure than rand() because the seed is easy to
+ predict, so we resort to rand() only if /dev/random is not available */
+ if ((fp=fopen("/dev/random","r")))
+ {
+ fread(pw,len,1,fp);
+ fclose(fp);
+ while (pw<pw_end)
+ {
+ *pw++='a'+((uint)*pw % 26);
+ }
+ }
+ else
+ {
+ srand(time(NULL));
+ while (pw<pw_end)
+ *pw++='a'+((uint)rand() % 26);
+ }
+ *pw_end=0;
+}
+
+int main(int argc, char** argv)
+{
+ FILE* fp;
+ my_MD5_CTX context;
+ uchar digest[16];
+ char pw[17];
+ uint i;
+
+ MY_INIT(argv[0]);
+ parse_args(argc,argv);
+ if (!outfile)
+ die("Missing --output-file");
+
+ if (!(fp=fopen(outfile,"w")))
+ die("Could not open '%s'(errno=%d)",outfile,errno);
+ get_pass(pw,sizeof(pw)-1);
+ my_MD5Init(&context);
+ my_MD5Update(&context,pw,sizeof(pw)-1);
+ my_MD5Final(digest,&context);
+ fprintf(fp,"%s:",user);
+ for (i=0;i<sizeof(digest);i++)
+ fprintf(fp,"%02x",digest[i]);
+ fprintf(fp,"\n");
+ fclose(fp);
+ printf("%s\n",pw);
+ return 0;
+}
diff --git a/client/mysqlmanagerc.c b/client/mysqlmanagerc.c
index ce5242364c3..77211af0eff 100644
--- a/client/mysqlmanagerc.c
+++ b/client/mysqlmanagerc.c
@@ -92,9 +92,9 @@ static void print_version(void)
void usage()
{
print_version();
- printf("MySQL AB, by Sasha, Matt & Monty\n");
+ printf("MySQL AB, by Sasha\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("Command-line client for MySQL manager daemon.\n\n");
printf("Usage: %s [OPTIONS] < command_file\n", my_progname);
printf("\n\
-?, --help Display this help and exit.\n");
@@ -148,7 +148,7 @@ int parse_args(int argc, char **argv)
exit(0);
case '?':
usage();
- exit(1); /* Unknown option */
+ exit(0);
default:
usage();
exit(1);
diff --git a/include/my_sys.h b/include/my_sys.h
index b70d123a66a..679237236d5 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -59,6 +59,9 @@ extern int NEAR my_errno; /* Last error in mysys */
#define MY_WME 16 /* Write message on error */
#define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */
#define MY_RAID 64 /* Support for RAID (not the "Johnson&Johnson"-s one ;) */
+#define MY_FULL_IO 128 /* For my_read - loop intil I/O
+ is complete
+ */
#define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */
#define MY_LINK_WARNING 32 /* my_redel() gives warning if links */
#define MY_COPYTIME 64 /* my_redel() copys time */
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index 3a925372085..04b0b27cdb8 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -118,6 +118,7 @@ MASTER_RUNNING=0
MASTER_MYPORT=9306
SLAVE_RUNNING=0
SLAVE_MYPORT=9307
+MYSQL_MANAGER_PORT=23546
NO_SLAVE=0
EXTRA_MASTER_OPT=""
@@ -276,6 +277,9 @@ if [ x$SOURCE_DIST = x1 ] ; then
MYSQL_TEST="$BASEDIR/client/mysqltest"
fi
MYSQLADMIN="$BASEDIR/client/mysqladmin"
+ MYSQL_MANAGER_CLIENT="$BASEDIR/client/mysqlmanagerc"
+ MYSQL_MANAGER="$BASEDIR/tools/mysqlmanager"
+ MYSQL_MANAGER_PWGEN="$BASEDIR/client/mysqlmanager-pwgen"
MYSQL="$BASEDIR/client/mysql"
LANGUAGE="$BASEDIR/sql/share/english/"
CHARSETSDIR="$BASEDIR/sql/share/charsets"
@@ -284,6 +288,9 @@ else
MYSQLD="$BASEDIR/bin/mysqld"
MYSQL_TEST="$BASEDIR/bin/mysqltest"
MYSQLADMIN="$BASEDIR/bin/mysqladmin"
+ MYSQL_MANAGER="$BASEDIR/bin/mysqlmanager"
+ MYSQL_MANAGER_CLIENT="$BASEDIR/bin/mysqlmanagerc"
+ MYSQL_MANAGER_PWGEN="$BASEDIR/bin/mysqlmanager-pwgen"
MYSQL="$BASEDIR/bin/mysql"
INSTALL_DB="./install_test_db -bin"
if test -d "$BASEDIR/share/mysql/english"
@@ -487,6 +494,30 @@ gcov_collect () {
$ECHO "gcov info in $GCOV_MSG, errors in $GCOV_ERR"
}
+abort_if_failed()
+{
+ if [ ! $? = 0 ] ; then
+ echo $1
+ exit 1
+ fi
+}
+
+start_manager()
+{
+ MYSQL_MANAGER_PW=`$MYSQL_MANAGER_PWGEN -o $MYSQL_MANAGER_PW_FILE`
+ $MYSQL_MANAGER --log=$MYSQL_MANAGER_LOG --port=$MYSQL_MANAGER_PORT \
+ --password-file=$MYSQL_MANAGER_PW_FILE
+ abort_if_failed "Could not start MySQL manager"
+}
+
+manager_cmd()
+{
+ $MYSQL_MANAGER_CLIENT --user=$MYSQL_MANAGER_USER \
+ --password=$MYSQL_MANAGER_PW --port=$MYSQL_MANAGER_PORT <<EOF
+$@
+EOF
+ abort_if_failed "Could not execute manager command"
+}
start_master()
{
diff --git a/mysys/my_read.c b/mysys/my_read.c
index b317630f4bd..9a6c7f4d9dc 100644
--- a/mysys/my_read.c
+++ b/mysys/my_read.c
@@ -28,10 +28,11 @@ uint my_read(File Filedes, byte *Buffer, uint Count, myf MyFlags)
/* Max number of bytes returnd */
/* Flags on what to do on error */
{
- uint readbytes;
+ uint readbytes,save_count;
DBUG_ENTER("my_read");
DBUG_PRINT("my",("Fd: %d Buffer: %lx Count: %u MyFlags: %d",
Filedes, Buffer, Count, MyFlags));
+ save_count=Count;
for (;;)
{
@@ -54,12 +55,21 @@ uint my_read(File Filedes, byte *Buffer, uint Count, myf MyFlags)
my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG),
my_filename(Filedes),my_errno);
}
- if ((int) readbytes == -1 || (MyFlags & (MY_FNABP | MY_NABP)))
+ if ((int) readbytes == -1 ||
+ ((MyFlags & (MY_FNABP | MY_NABP)) && !(MyFlags & MY_FULL_IO)))
DBUG_RETURN(MY_FILE_ERROR); /* Return with error */
+ if (readbytes > 0 && (MyFlags & MY_FULL_IO))
+ {
+ Buffer+=readbytes;
+ Count-=readbytes;
+ continue;
+ }
}
if (MyFlags & (MY_NABP | MY_FNABP))
readbytes=0; /* Ok on read */
+ else if (MyFlags & MY_FULL_IO)
+ readbytes=save_count;
break;
}
DBUG_RETURN(readbytes);
diff --git a/tools/managertest1.nc b/tools/managertest1.nc
index 5478cb56abb..19736b250e5 100644
--- a/tools/managertest1.nc
+++ b/tools/managertest1.nc
@@ -1,5 +1,7 @@
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_stdout server /tmp/mysqld.err
+set_exec_stderr server /tmp/mysqld.err
start_exec server 3
show_exec
stop_exec server 3
diff --git a/tools/mysqlmanager.c b/tools/mysqlmanager.c
index 4ca8c7768cd..aa599beee93 100644
--- a/tools/mysqlmanager.c
+++ b/tools/mysqlmanager.c
@@ -117,6 +117,8 @@ uint manager_max_cmd_len = MANAGER_MAX_CMD_LEN;
const char* manager_pw_file=MANAGER_PW_FILE;
int one_thread = 0; /* for debugging */
+typedef enum {PARAM_STDOUT,PARAM_STDERR} PARAM_TYPE;
+
/* messages */
#define MAX_CLIENT_MSG_LEN 256
@@ -170,6 +172,7 @@ static byte* get_user_key(const byte* u, uint* len,
static uint tokenize_args(char* arg_start,char** arg_end);
static void init_arg_array(char* arg_str,char** args,uint arg_count);
static int hex_val(char c);
+static int open_and_dup(int fd,char* path);
typedef int (*manager_cmd_handler)(struct manager_thd*,char*,char*);
@@ -211,12 +214,18 @@ struct manager_exec
pthread_t th;
char con_sock[FN_REFLEN];
char con_host[MAX_HOST];
+ char stderr_path[FN_REFLEN];
+ char stdout_path[FN_REFLEN];
MYSQL mysql;
char* data_buf;
int req_len;
+ int stderr_path_size,stdout_path_size,data_buf_size;
int num_args;
};
+static int set_exec_param(struct manager_thd* thd, char* args_start,
+ char* args_end, PARAM_TYPE param_type);
+
#define HANDLE_DECL(com) static int handle_ ## com (struct manager_thd* thd,\
char* args_start,char* args_end)
@@ -233,6 +242,8 @@ HANDLE_DECL(def_exec);
HANDLE_DECL(start_exec);
HANDLE_DECL(stop_exec);
HANDLE_DECL(set_exec_con);
+HANDLE_DECL(set_exec_stdout);
+HANDLE_DECL(set_exec_stderr);
HANDLE_NOARG_DECL(show_exec);
struct manager_cmd commands[] =
@@ -247,6 +258,10 @@ struct manager_cmd commands[] =
handle_stop_exec,9},
{"set_exec_con", "Set connection parameters for executable entry",
handle_set_exec_con,12},
+ {"set_exec_stdout", "Set stdout path for executable entry",
+ handle_set_exec_stdout,15},
+ {"set_exec_stderr", "Set stderr path for executable entry",
+ handle_set_exec_stderr,15},
{"show_exec","Show defined executable entries",handle_show_exec,9},
{"help", "Print this message", handle_help,4},
{0,0,0,0}
@@ -460,6 +475,68 @@ err:
return 1;
}
+HANDLE_DECL(set_exec_stdout)
+{
+ return set_exec_param(thd,args_start,args_end,PARAM_STDOUT);
+}
+
+HANDLE_DECL(set_exec_stderr)
+{
+ return set_exec_param(thd,args_start,args_end,PARAM_STDERR);
+}
+
+static int set_exec_param(struct manager_thd* thd, char* args_start,
+ char* args_end, PARAM_TYPE param_type)
+{
+ int num_args;
+ const char* error=0;
+ struct manager_exec* e;
+ char* arg_p;
+ char* param;
+ int param_size;
+
+ if ((num_args=tokenize_args(args_start,&args_end))<2)
+ {
+ error="Too few arguments";
+ goto err;
+ }
+ arg_p=args_start;
+ pthread_mutex_lock(&lock_exec_hash);
+ if (!(e=(struct manager_exec*)hash_search(&exec_hash,arg_p,
+ strlen(arg_p))))
+ {
+ pthread_mutex_unlock(&lock_exec_hash);
+ error="Exec definition entry does not exist";
+ goto err;
+ }
+ arg_p+=strlen(arg_p)+1;
+ param_size=strlen(arg_p)+1;
+ switch (param_type)
+ {
+ case PARAM_STDOUT:
+ param=e->stdout_path;
+ e->req_len+=(param_size-e->stdout_path_size);
+ e->stdout_path_size=param_size;
+ break;
+ case PARAM_STDERR:
+ param=e->stderr_path;
+ e->req_len+=(param_size-e->stderr_path_size);
+ e->stderr_path_size=param_size;
+ break;
+ default:
+ error="Internal error";
+ goto err;
+ }
+ strnmov(param,arg_p,FN_REFLEN);
+ pthread_mutex_unlock(&lock_exec_hash);
+ client_msg(thd->vio,MANAGER_OK,"Entry updated");
+ return 0;
+err:
+ client_msg(thd->vio,MANAGER_CLIENT_ERR,error);
+ return 1;
+}
+
+
HANDLE_DECL(start_exec)
{
int num_args;
@@ -488,7 +565,8 @@ HANDLE_DECL(start_exec)
pthread_mutex_lock(&e->lock);
t.tv_sec=time(0)+atoi(args_start+ident_len+1);
t.tv_nsec=0;
- pthread_cond_timedwait(&e->cond,&e->lock,&t);
+ if (!e->pid)
+ pthread_cond_timedwait(&e->cond,&e->lock,&t);
if (!e->pid)
{
pthread_mutex_unlock(&e->lock);
@@ -548,7 +626,8 @@ HANDLE_DECL(stop_exec)
error="Could not send shutdown command";
goto err;
}
- pthread_cond_timedwait(&e->cond,&e->lock,&abstime);
+ if (e->pid)
+ pthread_cond_timedwait(&e->cond,&e->lock,&abstime);
if (e->pid)
error="Process failed to terminate within alotted time";
e->th=0;
@@ -600,7 +679,7 @@ HANDLE_NOARG_DECL(show_exec)
{
uint i;
client_msg_pre(thd->vio,MANAGER_INFO,"Exec_def\tPid\tExit_status\tCon_info\
-\tArguments");
+\tStdout\tStderr\tArguments");
pthread_mutex_lock(&lock_exec_hash);
for (i=0;i<exec_hash.records;i++)
{
@@ -668,9 +747,16 @@ static int manager_exec_launch(struct manager_exec* e)
}
else
{
- if (write(to_launcher_pipe[1],&e->req_len,sizeof(int))!=sizeof(int) ||
- write(to_launcher_pipe[1],&e->num_args,sizeof(int))!=sizeof(int) ||
- write(to_launcher_pipe[1],e->data_buf,e->req_len)!=e->req_len)
+ if (my_write(to_launcher_pipe[1],(byte*)&e->req_len,
+ sizeof(int),MYF(MY_NABP))||
+ my_write(to_launcher_pipe[1],(byte*)&e->num_args,
+ sizeof(int),MYF(MY_NABP)) ||
+ my_write(to_launcher_pipe[1],e->stdout_path,e->stdout_path_size,
+ MYF(MY_NABP)) ||
+ my_write(to_launcher_pipe[1],e->stderr_path,e->stderr_path_size,
+ MYF(MY_NABP)) ||
+ my_write(to_launcher_pipe[1],e->data_buf,e->data_buf_size,
+ MYF(MY_NABP)))
{
e->error="Failed write request to launcher";
return 1;
@@ -724,6 +810,14 @@ static void manager_exec_print(Vio* vio,struct manager_exec* e)
p=int10_to_str(e->con_port,p,10);
}
*p++='\t';
+ p=arg_strmov(p,e->stdout_path,(int)(buf_end-p)-1);
+ if (p==buf_end-1)
+ goto end;
+ *p++='\t';
+ p=arg_strmov(p,e->stderr_path,(int)(buf_end-p)-1);
+ if (p==buf_end-1)
+ goto end;
+ *p++='\t';
for(;p<buf_end && *args;args++)
{
@@ -1341,7 +1435,8 @@ static struct manager_exec* manager_exec_new(char* arg_start,char* arg_end)
num_args=tokenize_args(arg_start,&arg_end);
arg_len=(uint)(arg_end-arg_start)+1; /* include \0 terminator*/
if (!(tmp=(struct manager_exec*)my_malloc(sizeof(*tmp)+arg_len+
- sizeof(char*)*num_args,MYF(0))))
+ sizeof(char*)*num_args,
+ MYF(MY_ZEROFILL))))
return 0;
if (num_args<2)
{
@@ -1350,7 +1445,7 @@ static struct manager_exec* manager_exec_new(char* arg_start,char* arg_end)
}
tmp->data_buf=(char*)tmp+sizeof(*tmp);
memcpy(tmp->data_buf,arg_start,arg_len);
- tmp->req_len=arg_len;
+ tmp->data_buf_size=arg_len;
tmp->args=(char**)(tmp->data_buf+arg_len);
tmp->num_args=num_args;
tmp->ident=tmp->data_buf;
@@ -1358,18 +1453,14 @@ static struct manager_exec* manager_exec_new(char* arg_start,char* arg_end)
first_arg=tmp->ident+tmp->ident_len+1;
init_arg_array(first_arg,tmp->args,num_args-1);
strmov(tmp->con_user,"root");
- tmp->con_pass[0]=0;
- tmp->con_sock[0]=0;
tmp->con_port=MYSQL_PORT;
memcpy(tmp->con_host,"localhost",10);
tmp->bin_path=tmp->args[0];
- tmp->pid=0;
- tmp->exit_code=0;
- tmp->th=0;
+ tmp->stdout_path_size=tmp->stderr_path_size=1;
+ tmp->req_len=tmp->data_buf_size+2;
pthread_mutex_init(&tmp->lock,0);
pthread_cond_init(&tmp->cond,0);
mysql_init(&tmp->mysql);
- tmp->error=0;
return tmp;
}
@@ -1480,6 +1571,23 @@ static void init_globals()
signal(SIGPIPE,handle_sigpipe);
}
+static int open_and_dup(int fd,char* path)
+{
+ int old_fd;
+ if ((old_fd=my_open(path,O_WRONLY|O_APPEND|O_CREAT,MYF(0)))<0)
+ {
+ log_err("Could not open '%s' for append, errno=%d",path,errno);
+ return 1;
+ }
+ if (dup2(old_fd,fd)<0)
+ {
+ log_err("Failed in dup2(), errno=%d",errno);
+ return 1;
+ }
+ my_close(old_fd,MYF(0));
+ return 0;
+}
+
static void run_launcher_loop()
{
for (;;)
@@ -1487,14 +1595,17 @@ static void run_launcher_loop()
int req_len,ident_len,num_args;
char* request_buf=0;
pid_t pid;
- char* exec_path,*ident;
+ char* exec_path,*ident,*stdout_path,*stderr_path;
char** args=0;
- if (read(to_launcher_pipe[0],&req_len,sizeof(int))!=sizeof(int) ||
- read(to_launcher_pipe[0],&num_args,sizeof(int))!=sizeof(int) ||
+ if (my_read(to_launcher_pipe[0],(byte*)&req_len,
+ sizeof(int),MYF(MY_NABP|MY_FULL_IO)) ||
+ my_read(to_launcher_pipe[0],(byte*)&num_args,
+ sizeof(int),MYF(MY_NABP|MY_FULL_IO)) ||
!(request_buf=(char*)my_malloc(req_len+sizeof(pid)+2,MYF(0))) ||
!(args=(char**)my_malloc(num_args*sizeof(char*),MYF(0))) ||
- read(to_launcher_pipe[0],request_buf+1,req_len)!=req_len)
+ my_read(to_launcher_pipe[0],request_buf,req_len,
+ MYF(MY_NABP|MY_FULL_IO)))
{
log_err("launcher: Error reading request");
my_free((gptr)request_buf,MYF(MY_ALLOW_ZERO_PTR));
@@ -1502,12 +1613,16 @@ static void run_launcher_loop()
sleep(1);
continue;
}
+ stdout_path=request_buf;
+ stderr_path=stdout_path+strlen(stdout_path)+1;
+ request_buf=stderr_path+strlen(stderr_path); /* black magic */
ident=request_buf+1;
ident_len=strlen(ident);
exec_path=ident+ident_len+1;
- log_debug("num_args=%d,req_len=%d,ident=%s,ident_len=%d,exec_path=%s",
+ log_debug("num_args=%d,req_len=%d,ident=%s,ident_len=%d,exec_path=%s,\
+stdout_path=%s,stderr_path=%s",
num_args,
- req_len,ident,ident_len,exec_path);
+ req_len,ident,ident_len,exec_path,stdout_path,stderr_path);
init_arg_array(exec_path,args,num_args-1);
switch ((pid=fork()))
@@ -1517,6 +1632,8 @@ static void run_launcher_loop()
sleep(1);
break;
case 0:
+ if (open_and_dup(1,stdout_path) || open_and_dup(2,stderr_path))
+ exit(1);
if (execv(exec_path,args))
log_err("launcher: cannot exec %s",exec_path);
exit(1);
@@ -1527,7 +1644,7 @@ static void run_launcher_loop()
log_err("launcher: error sending launch status report");
break;
}
- my_free((gptr)request_buf,MYF(0));
+ my_free((gptr)(stdout_path),MYF(0));
my_free((gptr)args,MYF(0));
}
}