Commit efc190e7 authored by unknown's avatar unknown
Browse files

Merge neptunus.(none):/home/msvensson/mysql/mysql-5.0

into  neptunus.(none):/home/msvensson/mysql/ssl_test/my50-ssl_test


client/mysqltest.c:
  Auto merged
mysql-test/mysql-test-run.pl:
  Auto merged
mysql-test/t/information_schema.test:
  Auto merged
mysql-test/t/myisam.test:
  Auto merged
mysql-test/t/mysqltest.test:
  Auto merged
mysql-test/t/rpl_openssl.test:
  Auto merged
sql/mysqld.cc:
  Auto merged
mysql-test/t/sp-security.test:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/structs.h:
  Auto merged
mysql-test/r/mysqltest.result:
  SCCS merged
parents 14b89a32 2bb0501d
Loading
Loading
Loading
Loading
+123 −39
Original line number Diff line number Diff line
@@ -77,7 +77,6 @@
#define PAD_SIZE	128
#define MAX_CONS	128
#define MAX_INCLUDE_DEPTH 16
#define LAZY_GUESS_BUF_SIZE 8192
#define INIT_Q_LINES	  1024
#define MIN_VAR_ALLOC	  32
#define BLOCK_STACK_DEPTH  32
@@ -1837,23 +1836,29 @@ void free_replace()
  DBUG_VOID_RETURN;
}


int select_connection_name(const char *name)
struct connection * find_connection_by_name(const char *name)
{
  struct connection *con;
  DBUG_ENTER("select_connection2");
  DBUG_PRINT("enter",("name: '%s'", name));

  for (con= cons; con < next_con; con++)
  {
    if (!strcmp(con->name, name))
    {
      cur_con= con;
      DBUG_RETURN(0);
      return con;
    }
  }
  return 0; /* Connection not found */
}


int select_connection_name(const char *name)
{
  struct connection *con;
  DBUG_ENTER("select_connection2");
  DBUG_PRINT("enter",("name: '%s'", name));

  if (!(cur_con= find_connection_by_name(name)))
    die("connection '%s' not found in connection pool", name);
  DBUG_RETURN(1);				/* Never reached */
  DBUG_RETURN(0);
}


@@ -1883,7 +1888,7 @@ int close_connection(struct st_query *q)
  DBUG_PRINT("enter",("name: '%s'",p));

  if (!*p)
    die("Missing connection name in connect");
    die("Missing connection name in disconnect");
  name= p;
  while (*p && !my_isspace(charset_info,*p))
    p++;
@@ -1906,6 +1911,14 @@ int close_connection(struct st_query *q)
      }
#endif
      mysql_close(&con->mysql);
      my_free(con->name, MYF(0));
      /*
         When the connection is closed set name to "closed_connection"
         to make it possible to reuse the connection name.
         The connection slot will not be reused
       */
      if (!(con->name = my_strdup("closed_connection", MYF(MY_WME))))
        die("Out of memory");
      DBUG_RETURN(0);
    }
  }
@@ -1921,18 +1934,22 @@ int close_connection(struct st_query *q)
   ) are delimiters/terminators
*/

char* safe_get_param(char *str, char** arg, const char *msg)
char* safe_get_param(char *str, char** arg, const char *msg, bool required)
{
  DBUG_ENTER("safe_get_param");
  if(!*str)
  {
    if (required)
      die(msg);
    *arg= str;
    DBUG_RETURN(str);
  }
  while (*str && my_isspace(charset_info,*str))
    str++;
  *arg= str;
  for (; *str && *str != ',' && *str != ')' ; str++)
  {
    if (my_isspace(charset_info,*str))
      *str= 0;
  }
  if (!*str)
  while (*str && *str != ',' && *str != ')')
    str++;
  if (required && !*arg)
    die(msg);

  *str++= 0;
@@ -2117,13 +2134,39 @@ int connect_n_handle_errors(struct st_query *q, MYSQL* con, const char* host,
}


/*
  Open a new connection to MySQL Server with the parameters
  specified

  SYNOPSIS
   do_connect()
    q	       called command

  DESCRIPTION
    connect(<name>,<host>,<user>,<pass>,<db>,[<port>,<sock>[<opts>]]);

      <name> - name of the new connection
      <host> - hostname of server
      <user> - user to connect as
      <pass> - password used when connecting
      <db>   - initial db when connected
      <port> - server port
      <sock> - server socket
      <opts> - options to use for the connection
               SSL - use SSL if available
               COMPRESS - use compression if available

 */

int do_connect(struct st_query *q)
{
  char *con_name, *con_user,*con_pass, *con_host, *con_port_str,
    *con_db, *con_sock;
  char *p= q->first_argument;
    *con_db, *con_sock, *con_options;
  char *con_buf, *p;
  char buff[FN_REFLEN];
  int con_port;
  bool con_ssl= 0;
  bool con_compress= 0;
  int free_con_sock= 0;
  int error= 0;
  int create_conn= 1;
@@ -2131,23 +2174,25 @@ int do_connect(struct st_query *q)
  DBUG_ENTER("do_connect");
  DBUG_PRINT("enter",("connect: %s",p));

  /* Make a copy of query before parsing, safe_get_param will modify */
  if (!(con_buf= my_strdup(q->first_argument, MYF(MY_WME))))
    die("Could not allocate con_buf");
  p= con_buf;

  if (*p != '(')
    die("Syntax error in connect - expected '(' found '%c'", *p);
  p++;
  p= safe_get_param(p, &con_name, "missing connection name");
  p= safe_get_param(p, &con_host, "missing connection host");
  p= safe_get_param(p, &con_user, "missing connection user");
  p= safe_get_param(p, &con_pass, "missing connection password");
  p= safe_get_param(p, &con_db, "missing connection db");
  if (!*p || *p == ';')				/* Default port and sock */
  {
    con_port= port;
    con_sock= (char*) unix_sock;
  }
  else
  p= safe_get_param(p, &con_name, "Missing connection name", 1);
  p= safe_get_param(p, &con_host, "Missing connection host", 1);
  p= safe_get_param(p, &con_user, "Missing connection user", 1);
  p= safe_get_param(p, &con_pass, "Missing connection password", 1);
  p= safe_get_param(p, &con_db, "Missing connection db", 1);

  /* Port */
  VAR* var_port;
  p= safe_get_param(p, &con_port_str, "Missing connection port", 0);
  if (*con_port_str)
  {
    VAR* var_port, *var_sock;
    p= safe_get_param(p, &con_port_str, "missing connection port");
    if (*con_port_str == '$')
    {
      if (!(var_port= var_get(con_port_str, 0, 0, 0)))
@@ -2155,8 +2200,22 @@ int do_connect(struct st_query *q)
      con_port= var_port->int_val;
    }
    else
    {
      con_port= atoi(con_port_str);
    p= safe_get_param(p, &con_sock, "missing connection socket");
      if (con_port == 0)
        die("Illegal argument for port: '%s'", con_port_str);
    }
  }
  else
  {
    con_port= port;
  }

  /* Sock */
  VAR *var_sock;
  p= safe_get_param(p, &con_sock, "Missing connection socket", 0);
  if (*con_sock)
  {
    if (*con_sock == '$')
    {
      if (!(var_sock= var_get(con_sock, 0, 0, 0)))
@@ -2168,20 +2227,44 @@ int do_connect(struct st_query *q)
      con_sock[var_sock->str_val_len]= 0;
    }
  }
  else
  {
    con_sock= (char*) unix_sock;
  }

  /* Options */
  p= safe_get_param(p, &con_options, "Missing options", 0);
  while (*con_options)
  {
    char* str= con_options;
    while (*str && !my_isspace(charset_info, *str))
      str++;
    *str++= 0;
    if (!strcmp(con_options, "SSL"))
      con_ssl= 1;
    else if (!strcmp(con_options, "COMPRESS"))
      con_compress= 1;
    else
      die("Illegal option to connect: %s", con_options);
    con_options= str;
  }
  q->last_argument= p;

  if (next_con == cons_end)
    die("Connection limit exhausted - increase MAX_CONS in mysqltest.c");

  if (find_connection_by_name(con_name))
    die("Connection %s already exists", con_name);

  if (!mysql_init(&next_con->mysql))
    die("Failed on mysql_init()");
  if (opt_compress)
  if (opt_compress || con_compress)
    mysql_options(&next_con->mysql,MYSQL_OPT_COMPRESS,NullS);
  mysql_options(&next_con->mysql, MYSQL_OPT_LOCAL_INFILE, 0);
  mysql_options(&next_con->mysql, MYSQL_SET_CHARSET_NAME, charset_name);

#ifdef HAVE_OPENSSL
  if (opt_use_ssl)
  if (opt_use_ssl || con_ssl)
    mysql_ssl_set(&next_con->mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
		  opt_ssl_capath, opt_ssl_cipher);
#endif
@@ -2212,6 +2295,7 @@ int do_connect(struct st_query *q)
  }
  if (free_con_sock)
    my_free(con_sock, MYF(MY_WME));
  my_free(con_buf, MYF(MY_WME));
  DBUG_RETURN(error);
}

+0 −4
Original line number Diff line number Diff line
-- require r/have_openssl_1.require
disable_query_log;
SHOW STATUS LIKE 'Ssl_cipher';
enable_query_log;
+91 −23
Original line number Diff line number Diff line
@@ -186,6 +186,11 @@ our $opt_big_test= 0; # Send --big-test to mysqltest
our @opt_extra_mysqld_opt;

our $opt_compress;
our $opt_ssl;
our $opt_skip_ssl;
our $opt_ssl_supported;
our $opt_ps_protocol;

our $opt_current_test;
our $opt_ddd;
our $opt_debug;
@@ -235,7 +240,6 @@ our $opt_skip_rpl;
our $opt_skip_test;

our $opt_sleep;
our $opt_ps_protocol;

our $opt_sleep_time_after_restart=  1;
our $opt_sleep_time_for_delete=    10;
@@ -276,7 +280,6 @@ our $opt_udiff;

our $opt_skip_ndbcluster;
our $opt_with_ndbcluster;
our $opt_with_openssl;

our $exe_ndb_mgm;
our $path_ndb_tools_dir;
@@ -297,7 +300,8 @@ sub executable_setup ();
sub environment_setup ();
sub kill_running_server ();
sub kill_and_cleanup ();
sub ndbcluster_support ();
sub check_ssl_support ();
sub check_ndbcluster_support ();
sub ndbcluster_install ();
sub ndbcluster_start ();
sub ndbcluster_stop ();
@@ -333,10 +337,8 @@ sub main () {
  command_line_setup();
  executable_setup();

  if (! $opt_skip_ndbcluster and ! $opt_with_ndbcluster)
  {
    $opt_with_ndbcluster= ndbcluster_support();
  }
  check_ndbcluster_support();
  check_ssl_support();

  environment_setup();
  signal_setup();
@@ -479,6 +481,9 @@ sub command_line_setup () {
             # Control what engine/variation to run
             'embedded-server'          => \$opt_embedded_server,
             'ps-protocol'              => \$opt_ps_protocol,
             'ssl|with-openssl'         => \$opt_ssl,
             'skip-ssl'                 => \$opt_skip_ssl,
             'compress'                 => \$opt_compress,
             'bench'                    => \$opt_bench,
             'small-bench'              => \$opt_small_bench,
             'no-manager'               => \$opt_no_manager, # Currently not used
@@ -530,7 +535,6 @@ sub command_line_setup () {

             # Misc
             'big-test'                 => \$opt_big_test,
             'compress'                 => \$opt_compress,
             'debug'                    => \$opt_debug,
             'fast'                     => \$opt_fast,
             'local'                    => \$opt_local,
@@ -555,7 +559,6 @@ sub command_line_setup () {
             'testcase-timeout=i'       => \$opt_testcase_timeout,
             'suite-timeout=i'          => \$opt_suite_timeout,
             'warnings|log-warnings'    => \$opt_warnings,
             'with-openssl'             => \$opt_with_openssl,

             'help|h'                   => \$opt_usage,
            ) or usage("Can't read options");
@@ -1140,13 +1143,59 @@ sub kill_and_cleanup () {
}


sub check_ssl_support () {

  if ($opt_skip_ssl)
  {
    mtr_report("Skipping SSL");
    $opt_ssl_supported= 0;
    $opt_ssl= 0;
    return;
  }

  # check ssl support by testing using a switch
  # that is only available in that case
  if ( mtr_run($exe_mysqld,
	       ["--no-defaults",
	        "--ssl",
	        "--help"],
	       "", "/dev/null", "/dev/null", "") != 0 )
  {
    if ( $opt_ssl)
    {
      mtr_error("Couldn't find support for SSL");
      return;
    }
    mtr_report("Skipping SSL, mysqld does not support it");
    $opt_ssl_supported= 0;
    $opt_ssl= 0;
    return;
  }
  mtr_report("Setting mysqld to support SSL connections");
  $opt_ssl_supported= 1;
}


##############################################################################
#
#  Start the ndb cluster
#
##############################################################################

sub ndbcluster_support () {
sub check_ndbcluster_support () {

  if ($opt_skip_ndbcluster)
  {
    mtr_report("Skipping ndbcluster");
    $opt_with_ndbcluster= 0;
    return;
  }

  if ($opt_with_ndbcluster)
  {
    mtr_report("Using ndbcluster");
    return;
  }

  # check ndbcluster support by testing using a switch
  # that is only available in that case
@@ -1156,11 +1205,13 @@ sub ndbcluster_support () {
	        "--help"],
	       "", "/dev/null", "/dev/null", "") != 0 )
  {
    mtr_report("No ndbcluster support");
    return 0;
    mtr_report("Skipping ndbcluster, mysqld does not support it");
    $opt_with_ndbcluster= 0;
    return;
  }
  mtr_report("Has ndbcluster support");
  return 1;
  mtr_report("Using ndbcluster, mysqld supports it");
  $opt_with_ndbcluster= 1;
  return;
}

# FIXME why is there a different start below?!
@@ -2049,7 +2100,7 @@ sub mysqld_arguments ($$$$$) {
  mtr_add_arg($args, "%s--max_heap_table_size=1M", $prefix);
  mtr_add_arg($args, "%s--log-bin-trust-routine-creators", $prefix);

  if ( $opt_with_openssl )
  if ( $opt_ssl_supported )
  {
    mtr_add_arg($args, "%s--ssl-ca=%s/std_data/cacert.pem", $prefix,
                $glob_mysql_test_dir);
@@ -2504,7 +2555,7 @@ sub run_mysqltest ($) {
    mtr_add_arg($args, "--debug=d:t:A,%s/log/mysqltest.trace", $opt_vardir);
  }

  if ( $opt_with_openssl )
  if ( $opt_ssl_supported )
  {
    mtr_add_arg($args, "--ssl-ca=%s/std_data/cacert.pem",
	        $glob_mysql_test_dir);
@@ -2514,6 +2565,18 @@ sub run_mysqltest ($) {
	        $glob_mysql_test_dir);
  }

  # Turn on SSL for all test cases
  if ( $opt_ssl )
  {
    mtr_add_arg($args, "--ssl",
		$glob_mysql_test_dir);
  }
  elsif ( $opt_ssl_supported )
  {
    mtr_add_arg($args, "--skip-ssl",
		$glob_mysql_test_dir);
  }

  # ----------------------------------------------------------------------
  # If embedded server, we create server args to give mysqltest to pass on
  # ----------------------------------------------------------------------
@@ -2590,6 +2653,9 @@ Options to control what engine/variation to run

  embedded-server       Use the embedded server, i.e. no mysqld daemons
  ps-protocol           Use the binary protocol between client and server
  compress              Use the compressed protocol between client and server
  ssl                   Use ssl protocol between client and server
  skip-ssl              Dont start sterver with support for ssl connections
  bench                 Run the benchmark suite FIXME
  small-bench           FIXME

@@ -2597,6 +2663,7 @@ Options to control what test suites or cases to run

  force                 Continue to run the suite after failure
  with-ndbcluster       Use cluster, and enable test cases that requres it
  skip-ndb[cluster]     Skip the ndb test cases, don't start cluster
  do-test=PREFIX        Run test cases which name are prefixed with PREFIX
  start-from=PREFIX     Run test cases starting from test prefixed with PREFIX
  suite=NAME            Run the test suite named NAME. The default is "main"
@@ -2648,7 +2715,6 @@ Misc options

  verbose               Verbose output from this script
  script-debug          Debug this script itself
  compress              Use the compressed protocol between client and server
  timer                 Show test case execution time
  start-and-exit        Only initiate and start the "mysqld" servers, use the startup
                        settings for the specified test case if any
@@ -2661,6 +2727,9 @@ Misc options
  testcase-timeout=MINUTES Max test case run time (default 5)
  suite-timeout=MINUTES    Max test suite run time (default 120)

Deprecated options
  with-openssl          Deprecated option for ssl


Options not yet described, or that I want to look into more

@@ -2677,7 +2746,6 @@ Options not yet described, or that I want to look into more
  wait-timeout=SECONDS  
  warnings              
  log-warnings          
  with-openssl          

HERE
  mtr_exit(1);
+2948 −0

File added.

Preview size limit exceeded, changes collapsed.

+20 −0
Original line number Diff line number Diff line
@@ -20,6 +20,10 @@ time_zone_transition_type
user
show tables;
Tables_in_test
connect(localhost,root,z,test2,9306,MYSQL_TEST_DIR/var/tmp/master.sock);
ERROR 28000: Access denied for user 'root'@'localhost' (using password: YES)
connect(localhost,root,z,test,9306,MYSQL_TEST_DIR/var/tmp/master.sock);
ERROR 28000: Access denied for user 'root'@'localhost' (using password: YES)
grant ALL on *.* to test@localhost identified by "gambling";
grant ALL on *.* to test@127.0.0.1 identified by "gambling";
show tables;
@@ -43,6 +47,14 @@ time_zone_transition_type
user
show tables;
Tables_in_test
connect(localhost,test,,test2,9306,MYSQL_TEST_DIR/var/tmp/master.sock);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
connect(localhost,test,,"",9306,MYSQL_TEST_DIR/var/tmp/master.sock);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
connect(localhost,test,zorro,test2,9306,MYSQL_TEST_DIR/var/tmp/master.sock);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
connect(localhost,test,zorro,test,9306,MYSQL_TEST_DIR/var/tmp/master.sock);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
update mysql.user set password=old_password("gambling2") where user=_binary"test";
flush privileges;
set password="";
@@ -70,6 +82,14 @@ time_zone_transition_type
user
show tables;
Tables_in_test
connect(localhost,test,,test2,9306,MYSQL_TEST_DIR/var/tmp/master.sock);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
connect(localhost,test,,test,9306,MYSQL_TEST_DIR/var/tmp/master.sock);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
connect(localhost,test,zorro,test2,9306,MYSQL_TEST_DIR/var/tmp/master.sock);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
connect(localhost,test,zorro,test,9306,MYSQL_TEST_DIR/var/tmp/master.sock);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
delete from mysql.user where user=_binary"test";
flush privileges;
create table t1 (id integer not null auto_increment primary key);
Loading