Commit 537846a4 authored by tonu@hundin.mysql.fi's avatar tonu@hundin.mysql.fi
Browse files

Merge tonu@work.mysql.com:/home/bk/mysql-4.0

into hundin.mysql.fi:/home/tonu/mysql-4.0
parents df56b252 1519e5d0
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
#! /bin/sh

path=`dirname $0`
. "$path/SETUP.sh"

extra_flags="$pentium_cflags $debug_cflags"
c_warnings="$c_warnings $debug_extra_warnings"
cxx_warnings="$cxx_warnings $debug_extra_warnings"
extra_configs="$pentium_configs $debug_configs"

extra_configs="$extra_configs  --with-debug=full --with-vio --with-openssl"

. "$path/FINISH.sh"
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ TAR = gtar
EXTRA_DIST =		INSTALL-SOURCE README \
			COPYING COPYING.LIB MIRRORS
SUBDIRS =		include @docs_dirs@ @readline_dir@ \
			@thread_dirs@ @pstack_dirs@ @sql_client_dirs@ \
			@thread_dirs@ @pstack_dirs@ vio @sql_client_dirs@ \
			@sql_server_dirs@ @libmysqld_dirs@ scripts tests man \
			@bench_dirs@ support-files @fs_dirs@

+0 −7
Original line number Diff line number Diff line
@@ -101,15 +101,8 @@ enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
#define NET_WRITE_TIMEOUT	60		/* Timeout on write */
#define NET_WAIT_TIMEOUT	8*60*60		/* Wait for new query */

#ifndef Vio_defined
#define Vio_defined
#ifdef HAVE_VIO
class Vio;					/* Fill Vio class in C++ */
#else
struct st_vio;					/* Only C */
typedef struct st_vio Vio;
#endif
#endif

typedef struct st_net {
  Vio* vio;
+155 −15
Original line number Diff line number Diff line
@@ -25,9 +25,6 @@

#include "my_net.h"			/* needed because of struct in_addr */

#ifdef HAVE_VIO
#include <Vio.h>				/* Full VIO interface */
#else

/* Simple vio interface in C;  The functions are implemented in violite.c */

@@ -35,12 +32,6 @@
extern "C" {
#endif /* __cplusplus */

#ifndef Vio_defined
#define Vio_defined
struct st_vio;					/* Only C */
typedef struct st_vio Vio;
#endif

enum enum_vio_type { VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET,
	                     VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL};

@@ -117,5 +108,154 @@ my_bool vio_poll_read(Vio *vio,uint timeout);
#ifdef	__cplusplus
}
#endif
#endif /* HAVE_VIO */
#endif /* vio_violite_h_ */
#ifdef HAVE_VIO
#ifndef DONT_MAP_VIO
#define vio_delete(vio) 			(vio)->viodelete(vio)
#define vio_errno(vio)	 			(vio)->vioerrno(vio)
#define vio_read(vio, buf, size) 		(vio)->read(vio,buf,size)
#define vio_write(vio, buf, size) 		(vio)->write(vio, buf, size)
#define vio_blocking(vio, set_blocking_mode) 	(vio)->vioblocking(vio, set_blocking_mode)
#define vio_is_blocking(vio) 			(vio)->is_blocking(vio)
#define vio_fastsend(vio)			(vio)->fastsend(vio)
#define vio_keepalive(vio, set_keep_alive)	(vio)->viokeepalive(vio, set_keep_alive)
#define vio_should_retry(vio) 			(vio)->should_retry(vio)
#define vio_close(vio)				((vio)->vioclose)(vio)
#define vio_peer_addr(vio, buf)			(vio)->peer_addr(vio, buf)
#define vio_in_addr(vio, in)			(vio)->in_addr(vio, in)
#define vio_poll_read(vio,timeout)		(vio)->poll_read(vio,timeout)
#endif /* !DONT_MAP_VIO */
#endif /* HAVE_VIO */


#ifdef HAVE_OPENSSL
#include <openssl/x509.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/pem.h>
#include <openssl/asn1.h>
#include "my_net.h"			/* needed because of struct in_addr */


#ifdef	__cplusplus
extern "C" {
#endif /* __cplusplus */

void vio_ssl_delete(Vio* vio);

#ifdef EMBEDDED_LIBRARY
void vio_reset(Vio *vio);
#endif

int		vio_ssl_read(Vio* vio,gptr buf,	int size);
int		vio_ssl_write(Vio* vio,const gptr buf,int size);
int		vio_ssl_blocking(Vio* vio,my_bool onoff);
my_bool		vio_ssl_is_blocking(Vio* vio);

/* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible. */
  int vio_ssl_fastsend(Vio* vio);
/* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible. */
int vio_ssl_keepalive(Vio* vio, my_bool onoff);
/* Whenever we should retry the last read/write operation. */
my_bool vio_ssl_should_retry(Vio* vio);
/* When the workday is over... */
int vio_ssl_close(Vio* vio);
/* Return last error number */
int vio_ssl_errno(Vio *vio);
my_bool vio_ssl_peer_addr(Vio* vio, char *buf);
void vio_ssl_in_addr(Vio *vio, struct in_addr *in);

/* Return 1 if there is data to be read */
my_bool vio_ssl_poll_read(Vio *vio,uint timeout);

#ifdef HAVE_OPENSSL

/* Single copy for server */
struct st_VioSSLAcceptorFd 
{
  SSL_CTX* ssl_context_;
  SSL_METHOD* ssl_method_;
  struct st_VioSSLAcceptorFd* session_id_context_;
  enum {
    state_connect       = 1,
    state_accept        = 2
  };
  BIO* bio_;
  char *ssl_cip_;
  char desc_[100];
  Vio* sd_;

  /* function pointers which are only once for SSL server 
  Vio*(*sslaccept)(struct st_VioSSLAcceptorFd*,Vio*); */
};

/* One copy for client */
struct st_VioSSLConnectorFd
{
  BIO* bio_;
  gptr ssl_;
  SSL_CTX* ssl_context_;
  SSL_METHOD* ssl_method_;
  /* function pointers which are only once for SSL client */ 
};
Vio *sslaccept(struct st_VioSSLAcceptorFd*, Vio*);
Vio *sslconnect(struct st_VioSSLConnectorFd*, Vio*);

#else /* HAVE_OPENSSL */
/* This dummy is required to maintain proper size of st_mysql in mysql.h */
struct st_VioSSLConnectorFd {};
#endif /* HAVE_OPENSSL */
struct st_VioSSLConnectorFd *new_VioSSLConnectorFd(
		const char* key_file,const char* cert_file,const char* ca_file,const char* ca_path);
struct st_VioSSLAcceptorFd *new_VioSSLAcceptorFd(
		const char* key_file,const char* cert_file,const char* ca_file,const char* ca_path);
Vio* new_VioSSL(struct st_VioSSLAcceptorFd* fd, Vio* sd,int state);
//static int
//init_bio_(struct st_VioSSLAcceptorFd* fd, Vio* sd, int state,  int bio_flags);
//void report_errors();
	
#ifdef	__cplusplus
}
#endif
#endif /* HAVE_OPENSSL */

#ifndef __WIN__
#define HANDLE void *
#endif

/* This structure is for every connection on both sides */
struct st_vio
{
  my_socket		sd;		/* my_socket - real or imaginary */
  HANDLE hPipe;
  my_bool		localhost;	/* Are we from localhost? */
  int			fcntl_mode;	/* Buffered fcntl(sd,F_GETFL) */
  struct sockaddr_in	local;		/* Local internet address */
  struct sockaddr_in	remote;		/* Remote internet address */
  enum enum_vio_type	type;		/* Type of connection */
  char			desc[30];	/* String description */
#ifdef HAVE_VIO
  /* function pointers. They are similar for socket/SSL/whatever */
  void (*viodelete)(Vio*);
  int(*vioerrno)(Vio*);
  int(*read)(Vio*, gptr, int);
  int(*write)(Vio*, gptr, int);
  int(*vioblocking)(Vio*, my_bool);
  my_bool(*is_blocking)(Vio*);
  int(*viokeepalive)(Vio*, my_bool);
  int(*fastsend)(Vio*);
  my_bool(*peer_addr)(Vio*, gptr);
  void(*in_addr)(Vio*, struct in_addr*);
  my_bool(*should_retry)(Vio*);
  int(*vioclose)(Vio*);
  my_bool(*poll_read)(Vio*,uint);

#ifdef HAVE_OPENSSL
  BIO* bio_;
  SSL* ssl_;
  my_bool open_;
#endif /* HAVE_OPENSSL */
#endif /* HAVE_VIO */
};

+0 −3
Original line number Diff line number Diff line
@@ -34,9 +34,6 @@ LTCHARSET_OBJS= ${CHARSET_OBJS:.o=.lo}
target_sources = libmysql.c net.c  password.c \
			    get_password.c errmsg.c

#quick easy dirty hack to make it work after Tonu's changes
#In my opinion, violite.c really belongs into mysys - Sasha
sqlobjects = violite.lo
mystringsobjects =	strmov.lo strxmov.lo strnmov.lo strmake.lo strend.lo \
			strnlen.lo strfill.lo is_prefix.lo \
			int2str.lo str2int.lo strinstr.lo strcont.lo \
Loading