List:Commits« Previous MessageNext Message »
From:Tor Didriksen Date:May 18 2012 1:59pm
Subject:bzr push into mysql-trunk branch (tor.didriksen:3865 to 3866) WL#5603
View as plain text  
 3866 Tor Didriksen	2012-05-18
      WL#5603 Revise how we handle passwords on the command line
      
      Fix some linking problems on various platforms.
      All executables which link with mysys_ssl must be linked with C++
      SET_TARGET_PROPERTIES(<executable> PROPERTIES LINKER_LANGUAGE CXX)
      
      Add new header file mysys_ssl/my_default.h
      (TODO: move all declarations pertaining to default.c here)
      
      MAX_CIPHER_STORE_LEN must be a #define, since it is used
      for stack allocation of arrays (windows requirement)
     @ client/mysql_config_editor.cc
        Fix some compile warnings
         - always include my_config.h first
         - avoid 'while(condition);' use empty braces instead.
     @ unittest/gunit/CMakeLists.txt
        The unit test main programs also need the mysys_ssl library.

    added:
      mysys_ssl/my_default.h
    modified:
      client/CMakeLists.txt
      client/mysql_config_editor.cc
      extra/CMakeLists.txt
      extra/my_print_defaults.c
      include/my_sys.h
      mysys_ssl/default.c
      storage/myisam/CMakeLists.txt
      unittest/gunit/CMakeLists.txt
 3865 Nirbhay Choubey	2012-05-17
      WL#5603 :  Revise how we handle passwords on
                 the command line

    removed:
      include/rijndael.h
      mysys/rijndael.c
    added:
      client/mysql_config_editor.cc
      mysql-test/r/mysql_config_editor.result
      mysql-test/t/mysql_config_editor.test
      mysys_ssl/
      mysys_ssl/CMakeLists.txt
      mysys_ssl/my_aes.cc
    renamed:
      mysys/default.c => mysys_ssl/default.c
      mysys/my_getopt.c => mysys_ssl/my_getopt.c
    modified:
      CMakeLists.txt
      client/CMakeLists.txt
      client/client_priv.h
      extra/CMakeLists.txt
      extra/my_print_defaults.c
      extra/yassl/taocrypt/include/misc.hpp
      include/my_aes.h
      include/my_sys.h
      libmysql/CMakeLists.txt
      libmysqld/CMakeLists.txt
      mysql-test/lib/v1/mysql-test-run.pl
      mysql-test/mysql-test-run.pl
      mysys/CMakeLists.txt
      sql/CMakeLists.txt
      storage/myisam/CMakeLists.txt
      mysys_ssl/default.c
      mysys_ssl/my_getopt.c
=== modified file 'client/CMakeLists.txt'
--- a/client/CMakeLists.txt	2012-05-17 13:22:24 +0000
+++ b/client/CMakeLists.txt	2012-05-18 13:52:53 +0000
@@ -15,6 +15,7 @@
 
 INCLUDE_DIRECTORIES(
   ${CMAKE_SOURCE_DIR}/include
+  ${CMAKE_SOURCE_DIR}/mysys_ssl
   ${ZLIB_INCLUDE_DIR}
   ${SSL_INCLUDE_DIRS}
   ${CMAKE_SOURCE_DIR}/libmysql

=== modified file 'client/mysql_config_editor.cc'
--- a/client/mysql_config_editor.cc	2012-05-17 13:22:24 +0000
+++ b/client/mysql_config_editor.cc	2012-05-18 13:52:53 +0000
@@ -23,11 +23,13 @@
 */
 
 /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
+#include "my_config.h"
 #include <welcome_copyright_notice.h>
 #include <signal.h>
 #include <my_dir.h>
 #include "my_aes.h"
 #include "client_priv.h"
+#include "my_default.h"
 
 #define MYSQL_CONFIG_EDITOR_VERSION "1.0"
 #define MY_LINE_MAX 1024
@@ -272,6 +274,15 @@ static my_bool check_and_create_login_fi
 
   MY_STAT stat_info;
 
+// This is a hack to make it compile. File permissions are different on Windows.
+#ifdef _WIN32
+#define S_IRUSR  00400
+#define S_IWUSR  00200
+#define S_IRWXU  00700
+#define S_IRWXG  00070
+#define S_IRWXO  00007
+#endif
+
   const int access_flag= (O_RDWR);
   const ushort create_mode= (S_IRUSR | S_IWUSR );
   const ushort create_mode_all= (S_IRWXU | S_IRWXG | S_IRWXO);
@@ -417,12 +428,14 @@ static void mask_password_and_print(char
 
   while ((next= strstr(buf, password_str)) != NULL)
   {
-    while ( *buf != 0 && buf != next) putc( *(buf ++), stdout);
+    while ( *buf != 0 && buf != next)
+      putc( *(buf ++), stdout);
     printf("%s", password_str);
     printf("%s", mask);
 
     /* Ignore the password. */
-    while( *buf && *(++buf) != '\n');
+    while( *buf && *(++buf) != '\n')
+    {}
 
     if ( !opt_all)
       break;
@@ -590,7 +603,7 @@ static int encrypt_and_write_file(DYNAMI
       break;
 
     if ((enc_len= encrypt_buffer(&file_buf->str[bytes_read],
-                                 ++ len, cipher + max_cipher_store_len)) < 0)
+                                 ++ len, cipher + MAX_CIPHER_STORE_LEN)) < 0)
     {
       verbose_msg("Error! failed to encrypt the login file buffer..\n");
       goto error;
@@ -600,8 +613,8 @@ static int encrypt_and_write_file(DYNAMI
     /* Store cipher length first. */
     int4store(cipher, enc_len);
 
-    if ((my_write(fd, (const uchar *)cipher, enc_len + max_cipher_store_len,
-                  MYF(MY_WME))) != (enc_len + max_cipher_store_len))
+    if ((my_write(fd, (const uchar *)cipher, enc_len + MAX_CIPHER_STORE_LEN,
+                  MYF(MY_WME))) != (enc_len + MAX_CIPHER_STORE_LEN))
     {
       verbose_msg("Error! couldn't write to the file..\n");
       goto error;
@@ -635,12 +648,12 @@ static int read_and_decrypt_file(DYNAMIC
   DBUG_ENTER("read_and_decrypt_file");
 
   char cipher[MY_LINE_MAX], plain[MY_LINE_MAX];
-  uchar len_buf[max_cipher_store_len];
+  uchar len_buf[MAX_CIPHER_STORE_LEN];
   int cipher_len= 0, dec_len= 0, total_len= 0;
 
   /* First read the length of the cipher. */
-  while (my_read(fd, len_buf, max_cipher_store_len,
-                 MYF(MY_WME)) == max_cipher_store_len)
+  while (my_read(fd, len_buf, MAX_CIPHER_STORE_LEN,
+                 MYF(MY_WME)) == MAX_CIPHER_STORE_LEN)
   {
     cipher_len= sint4korr(len_buf);
     /* Now read 'cipher_len' bytes from the file. */

=== modified file 'extra/CMakeLists.txt'
--- a/extra/CMakeLists.txt	2012-05-17 13:22:24 +0000
+++ b/extra/CMakeLists.txt	2012-05-18 13:52:53 +0000
@@ -15,6 +15,7 @@
 
 INCLUDE_DIRECTORIES(
 ${CMAKE_SOURCE_DIR}/include 
+${CMAKE_SOURCE_DIR}/mysys_ssl
 ${ZLIB_INCLUDE_DIR}
 # Following is for perror, in case NDB is compiled in.
 ${CMAKE_SOURCE_DIR}/storage/ndb/include
@@ -29,6 +30,7 @@ SET(MYSQL_INSTALL_COMPONENT Server)
 IF(NOT CMAKE_CROSSCOMPILING)
  ADD_EXECUTABLE(comp_err comp_err.c)
  TARGET_LINK_LIBRARIES(comp_err mysys mysys_ssl)
+ SET_TARGET_PROPERTIES(comp_err PROPERTIES LINKER_LANGUAGE CXX)
 ENDIF()
 
 ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/include/mysqld_error.h 
@@ -52,13 +54,16 @@ ADD_CUSTOM_TARGET(GenError
 
 MYSQL_ADD_EXECUTABLE(my_print_defaults my_print_defaults.c)
 TARGET_LINK_LIBRARIES(my_print_defaults  mysys mysys_ssl)
+SET_TARGET_PROPERTIES(my_print_defaults PROPERTIES LINKER_LANGUAGE CXX)
 
 MYSQL_ADD_EXECUTABLE(perror perror.c)
 ADD_DEPENDENCIES(perror GenError)
 TARGET_LINK_LIBRARIES(perror mysys mysys_ssl)
+SET_TARGET_PROPERTIES(perror PROPERTIES LINKER_LANGUAGE CXX)
 
 MYSQL_ADD_EXECUTABLE(resolveip resolveip.c)
 TARGET_LINK_LIBRARIES(resolveip mysys mysys_ssl)
+SET_TARGET_PROPERTIES(resolveip PROPERTIES LINKER_LANGUAGE CXX)
 IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
   INCLUDE(CheckFunctionExists)
   INCLUDE(CheckLibraryExists)
@@ -87,8 +92,10 @@ ENDIF()
 IF(UNIX)
   MYSQL_ADD_EXECUTABLE(resolve_stack_dump resolve_stack_dump.c)
   TARGET_LINK_LIBRARIES(resolve_stack_dump mysys mysys_ssl)
+  SET_TARGET_PROPERTIES(resolve_stack_dump PROPERTIES LINKER_LANGUAGE CXX)
 
   MYSQL_ADD_EXECUTABLE(mysql_waitpid mysql_waitpid.c)
   TARGET_LINK_LIBRARIES(mysql_waitpid mysys mysys_ssl)
+  SET_TARGET_PROPERTIES(mysql_waitpid PROPERTIES LINKER_LANGUAGE CXX)
 ENDIF()
 

=== modified file 'extra/my_print_defaults.c'
--- a/extra/my_print_defaults.c	2012-05-17 13:22:24 +0000
+++ b/extra/my_print_defaults.c	2012-05-18 13:52:53 +0000
@@ -27,6 +27,7 @@
 #include <my_sys.h>
 #include <m_string.h>
 #include <my_getopt.h>
+#include "my_default.h"
 
 
 const char *config_file="my";			/* Default config file */

=== modified file 'include/my_sys.h'
--- a/include/my_sys.h	2012-05-17 13:22:24 +0000
+++ b/include/my_sys.h	2012-05-18 13:52:53 +0000
@@ -272,10 +272,6 @@ extern my_bool  my_disable_locking, my_d
                 my_disable_flush_key_blocks, my_disable_symlinks;
 extern char	wild_many,wild_one,wild_prefix;
 extern const char *charsets_dir;
-/* from default.c */
-extern const char *my_defaults_extra_file;
-extern const char *my_defaults_group_suffix;
-extern const char *my_defaults_file;
 
 extern my_bool timed_mutexes;
 
@@ -844,7 +840,6 @@ extern int get_defaults_options(int argc
                                 char **group_suffix, char **login_path);
 extern my_bool my_getopt_use_args_separator;
 extern const char* my_key;
-extern const uint max_cipher_store_len;
 extern my_bool my_getopt_is_args_separator(const char* arg);
 extern int my_load_defaults(const char *conf_file, const char **groups,
                             int *argc, char ***argv, const char ***);

=== modified file 'mysys_ssl/default.c'
--- a/mysys_ssl/default.c	2012-05-17 13:22:24 +0000
+++ b/mysys_ssl/default.c	2012-05-18 13:52:53 +0000
@@ -34,6 +34,7 @@
 ****************************************************************************/
 
 #include "../mysys/mysys_priv.h"
+#include "my_default.h"
 #include "m_string.h"
 #include "m_ctype.h"
 #include <my_dir.h>
@@ -96,12 +97,6 @@ static char my_defaults_extra_file_buffe
 
 char my_login_file[FN_REFLEN];
 const char *my_key= "..May..the..force..be..with..you..";
-/*
-  Number of byte used to store the length of
-  cipher that follows.
-*/
-const uint max_cipher_store_len= 4;
-
 static my_bool defaults_already_read= FALSE;
 
 /* Set to TRUE, if --no-defaults is found. */
@@ -1136,13 +1131,13 @@ static char *remove_end_comment(char *pt
 
 static my_bool mysql_file_getline(char *str, int size, MYSQL_FILE *file)
 {
-  uchar cipher[4096], len_buf[max_cipher_store_len];
+  uchar cipher[4096], len_buf[MAX_CIPHER_STORE_LEN];
   int length= 0, cipher_len= 0;
 
   if (is_login_file)
   {
-   if (mysql_file_fread(file, len_buf, max_cipher_store_len,
-                        MYF(MY_WME)) == max_cipher_store_len)
+   if (mysql_file_fread(file, len_buf, MAX_CIPHER_STORE_LEN,
+                        MYF(MY_WME)) == MAX_CIPHER_STORE_LEN)
    {
      cipher_len= sint4korr(len_buf);
      if (cipher_len > size)

=== added file 'mysys_ssl/my_default.h'
--- a/mysys_ssl/my_default.h	1970-01-01 00:00:00 +0000
+++ b/mysys_ssl/my_default.h	2012-05-18 13:52:53 +0000
@@ -0,0 +1,29 @@
+/* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+
+   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; version 2 of the License.
+
+   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., 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA */
+
+#ifndef MY_DEFAULT_INCLUDED
+#define MY_DEFAULT_INCLUDED
+
+/*
+  Number of byte used to store the length of
+  cipher that follows.
+*/
+#define MAX_CIPHER_STORE_LEN 4U
+
+extern const char *my_defaults_extra_file;
+extern const char *my_defaults_group_suffix;
+extern const char *my_defaults_file;
+
+#endif  // MY_DEFAULT_INCLUDED

=== modified file 'storage/myisam/CMakeLists.txt'
--- a/storage/myisam/CMakeLists.txt	2012-05-17 13:22:24 +0000
+++ b/storage/myisam/CMakeLists.txt	2012-05-18 13:52:53 +0000
@@ -35,19 +35,23 @@ TARGET_LINK_LIBRARIES(myisam mysys)
 
 MYSQL_ADD_EXECUTABLE(myisam_ftdump myisam_ftdump.c)
 TARGET_LINK_LIBRARIES(myisam_ftdump myisam mysys_ssl)
+SET_TARGET_PROPERTIES(myisam_ftdump PROPERTIES LINKER_LANGUAGE CXX)
 
 MYSQL_ADD_EXECUTABLE(myisamchk myisamchk.c)
 TARGET_LINK_LIBRARIES(myisamchk myisam mysys_ssl)
+SET_TARGET_PROPERTIES(myisamchk PROPERTIES LINKER_LANGUAGE CXX)
 
 MYSQL_ADD_EXECUTABLE(myisamlog myisamlog.c)
 TARGET_LINK_LIBRARIES(myisamlog myisam)
 
 MYSQL_ADD_EXECUTABLE(myisampack myisampack.c)
 TARGET_LINK_LIBRARIES(myisampack myisam mysys_ssl)
+SET_TARGET_PROPERTIES(myisampack PROPERTIES LINKER_LANGUAGE CXX)
 
 IF(WITH_UNIT_TESTS AND FALSE)
   ADD_EXECUTABLE(mi_test1 mi_test1.c)
   TARGET_LINK_LIBRARIES(mi_test1 myisam mysys_ssl)
+  SET_TARGET_PROPERTIES(mi_test1 PROPERTIES LINKER_LANGUAGE CXX)
 
   ADD_EXECUTABLE(mi_test2 mi_test2.c)
   TARGET_LINK_LIBRARIES(mi_test2 myisam)

=== modified file 'unittest/gunit/CMakeLists.txt'
--- a/unittest/gunit/CMakeLists.txt	2012-05-07 12:05:48 +0000
+++ b/unittest/gunit/CMakeLists.txt	2012-05-18 13:52:53 +0000
@@ -201,8 +201,10 @@ ADD_LIBRARY(gunit_large STATIC
   gunit_test_main_server.cc test_utils.cc tap_event_listener.cc thread_utils.cc)
 ADD_DEPENDENCIES(gunit_small GenError)
 ADD_DEPENDENCIES(gunit_large GenError)
-TARGET_LINK_LIBRARIES(gunit_small mysys mytap dbug strings ${GTEST_LIBRARIES})
-TARGET_LINK_LIBRARIES(gunit_large mysys mytap dbug strings ${GTEST_LIBRARIES})
+TARGET_LINK_LIBRARIES(gunit_small
+  mysys mysys_ssl mytap dbug strings ${GTEST_LIBRARIES})
+TARGET_LINK_LIBRARIES(gunit_large
+  mysys mysys_ssl mytap dbug strings ${GTEST_LIBRARIES})
 MESSAGE(STATUS "GTEST_LIBRARIES:${GTEST_LIBRARIES}")
 
 # Add some defines.

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (tor.didriksen:3865 to 3866) WL#5603Tor Didriksen20 May