Commit c85c33a5 authored by monty@mashka.mysql.fi's avatar monty@mashka.mysql.fi

Added CREATE TEMPORARY TABLES and LOCK TABLES to db and host tables

Fixed bug in SELECT ... ORDER BY ... LIMIT
Fixed bug in ALTER TABLE and RENAME TABLE with --lower-case-table-names
Fixed hang when using --with-openssl
parent 3a03bb1d
This diff is collapsed.
...@@ -175,7 +175,7 @@ struct st_VioSSLConnectorFd ...@@ -175,7 +175,7 @@ struct st_VioSSLConnectorFd
}; };
void sslaccept(struct st_VioSSLAcceptorFd*, Vio*, long timeout); void sslaccept(struct st_VioSSLAcceptorFd*, Vio*, long timeout);
void sslconnect(struct st_VioSSLConnectorFd*, Vio*, long timeout); int sslconnect(struct st_VioSSLConnectorFd*, Vio*, long timeout);
struct st_VioSSLConnectorFd struct st_VioSSLConnectorFd
*new_VioSSLConnectorFd(const char* key_file, const char* cert_file, *new_VioSSLConnectorFd(const char* key_file, const char* cert_file,
......
...@@ -514,6 +514,7 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups) ...@@ -514,6 +514,7 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
if (!opt_noacl) if (!opt_noacl)
(void) grant_init(); (void) grant_init();
init_max_user_conn(); init_max_user_conn();
init_update_queries();
#ifdef HAVE_DLOPEN #ifdef HAVE_DLOPEN
if (!opt_noacl) if (!opt_noacl)
......
#!/bin/sh #!/bin/sh
# Copyright (C) 1997, 1998, 1999 TCX DataKonsult AB & Monty Program KB & Detron HB # Copyright (C) 1997-2002 MySQL AB
# For a more info consult the file COPYRIGHT distributed with this file # For a more info consult the file COPYRIGHT distributed with this file
# This scripts creates the privilege tables db, host, user, tables_priv, # This scripts creates the privilege tables db, host, user, tables_priv,
...@@ -85,13 +85,15 @@ then ...@@ -85,13 +85,15 @@ then
c_d="$c_d References_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_d="$c_d References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Index_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_d="$c_d Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_d="$c_d Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d PRIMARY KEY Host (Host,Db,User)," c_d="$c_d PRIMARY KEY Host (Host,Db,User),"
c_d="$c_d KEY User (User)" c_d="$c_d KEY User (User)"
c_d="$c_d )" c_d="$c_d )"
c_d="$c_d comment='Database privileges';" c_d="$c_d comment='Database privileges';"
i_d="INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y'); i_d="INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');
INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y');" INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');"
fi fi
if test ! -f $mdata/host.frm if test ! -f $mdata/host.frm
...@@ -109,6 +111,8 @@ then ...@@ -109,6 +111,8 @@ then
c_h="$c_h References_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_h="$c_h References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Index_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_h="$c_h Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_h="$c_h Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h PRIMARY KEY Host (Host,Db)" c_h="$c_h PRIMARY KEY Host (Host,Db)"
c_h="$c_h )" c_h="$c_h )"
c_h="$c_h comment='Host privileges; Merged with database privileges';" c_h="$c_h comment='Host privileges; Merged with database privileges';"
......
...@@ -34,3 +34,27 @@ Grants for mysqltest_1@localhost ...@@ -34,3 +34,27 @@ Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE ISSUER 'MySQL AB' SUBJECT 'testsubject' CIPHER 'EDH-RSA-DES-CBC3-SHA' GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE ISSUER 'MySQL AB' SUBJECT 'testsubject' CIPHER 'EDH-RSA-DES-CBC3-SHA'
delete from mysql.user where user='mysqltest_1'; delete from mysql.user where user='mysqltest_1';
flush privileges; flush privileges;
grant CREATE TEMPORARY TABLES, LOCK TABLES on mysqltest.* to mysqltest_1@localhost;
show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost
GRANT CREATE TEMPORARY TABLES, LOCK TABLES ON `mysqltest`.* TO 'mysqltest_1'@'localhost'
flush privileges;
show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost
GRANT CREATE TEMPORARY TABLES, LOCK TABLES ON `mysqltest`.* TO 'mysqltest_1'@'localhost'
revoke CREATE TEMPORARY TABLES on mysqltest.* from mysqltest_1@localhost;
show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost
GRANT LOCK TABLES ON `mysqltest`.* TO 'mysqltest_1'@'localhost'
grant ALL PRIVILEGES on mysqltest.* to mysqltest_1@localhost with GRANT OPTION;
flush privileges;
show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost
GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_1'@'localhost' WITH GRANT OPTION
revoke LOCK TABLES, ALTER on mysqltest.* from mysqltest_1@localhost;
show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, CREATE TEMPORARY TABLES ON `mysqltest`.* TO 'mysqltest_1'@'localhost' WITH GRANT OPTION
revoke all privileges on mysqltest.* from mysqltest_1@localhost;
delete from mysql.user where user='mysqltest_1';
flush privileges;
drop table if exists t1,t2,t3;
create table T1 (id int primary key, Word varchar(40) not null, Index(Word));
INSERT INTO T1 VALUES (1, 'a'), (2, 'b'), (3, 'c');
SELECT * FROM t1;
id Word
1 a
2 b
3 c
RENAME TABLE T1 TO T2;
ALTER TABLE T2 ADD new_col int not null;
ALTER TABLE T2 RENAME T3;
show tables like 't_';
Tables_in_test (t_)
t3
drop table t3;
...@@ -20,3 +20,22 @@ revoke all privileges on mysqltest.* from mysqltest_1@localhost; ...@@ -20,3 +20,22 @@ revoke all privileges on mysqltest.* from mysqltest_1@localhost;
show grants for mysqltest_1@localhost; show grants for mysqltest_1@localhost;
delete from mysql.user where user='mysqltest_1'; delete from mysql.user where user='mysqltest_1';
flush privileges; flush privileges;
#
# Test that the new db privileges are stored/retrieved correctly
#
grant CREATE TEMPORARY TABLES, LOCK TABLES on mysqltest.* to mysqltest_1@localhost;
show grants for mysqltest_1@localhost;
flush privileges;
show grants for mysqltest_1@localhost;
revoke CREATE TEMPORARY TABLES on mysqltest.* from mysqltest_1@localhost;
show grants for mysqltest_1@localhost;
grant ALL PRIVILEGES on mysqltest.* to mysqltest_1@localhost with GRANT OPTION;
flush privileges;
show grants for mysqltest_1@localhost;
revoke LOCK TABLES, ALTER on mysqltest.* from mysqltest_1@localhost;
show grants for mysqltest_1@localhost;
revoke all privileges on mysqltest.* from mysqltest_1@localhost;
delete from mysql.user where user='mysqltest_1';
flush privileges;
#
# Test of --lower-case-table-names
#
drop table if exists t1,t2,t3;
create table T1 (id int primary key, Word varchar(40) not null, Index(Word));
INSERT INTO T1 VALUES (1, 'a'), (2, 'b'), (3, 'c');
SELECT * FROM t1;
RENAME TABLE T1 TO T2;
ALTER TABLE T2 ADD new_col int not null;
ALTER TABLE T2 RENAME T3;
show tables like 't_';
drop table t3;
...@@ -137,7 +137,7 @@ EOF ...@@ -137,7 +137,7 @@ EOF
echo "" echo ""
# #
# Change the user table to MySQL 4.0 format # Change the user,db and host tables to MySQL 4.0 format
# #
echo "Adding new fields used by MySQL 4.0.2 to the privilege tables" echo "Adding new fields used by MySQL 4.0.2 to the privilege tables"
...@@ -174,3 +174,16 @@ add max_questions int(11) NOT NULL AFTER x509_subject, ...@@ -174,3 +174,16 @@ add max_questions int(11) NOT NULL AFTER x509_subject,
add max_updates int(11) unsigned NOT NULL AFTER max_questions, add max_updates int(11) unsigned NOT NULL AFTER max_questions,
add max_connections int(11) unsigned NOT NULL AFTER max_updates; add max_connections int(11) unsigned NOT NULL AFTER max_updates;
END_OF_DATA END_OF_DATA
#
# Add Create_tmp_table_priv and Lock_tables_priv to db and host
#
@bindir@/mysql --user=root --password="$root_password" --host="$host" mysql <<END_OF_DATA
alter table db
add Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,
add Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL;
alter table host
add Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,
add Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL;
END_OF_DATA
...@@ -171,13 +171,15 @@ then ...@@ -171,13 +171,15 @@ then
c_d="$c_d References_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_d="$c_d References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Index_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_d="$c_d Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_d="$c_d Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d PRIMARY KEY Host (Host,Db,User)," c_d="$c_d PRIMARY KEY Host (Host,Db,User),"
c_d="$c_d KEY User (User)" c_d="$c_d KEY User (User)"
c_d="$c_d )" c_d="$c_d )"
c_d="$c_d comment='Database privileges';" c_d="$c_d comment='Database privileges';"
i_d="INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y'); i_d="INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');
INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y');" INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');"
fi fi
if test ! -f $mdata/host.frm if test ! -f $mdata/host.frm
...@@ -197,6 +199,8 @@ then ...@@ -197,6 +199,8 @@ then
c_h="$c_h References_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_h="$c_h References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Index_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_h="$c_h Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_h="$c_h Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h PRIMARY KEY Host (Host,Db)" c_h="$c_h PRIMARY KEY Host (Host,Db)"
c_h="$c_h )" c_h="$c_h )"
c_h="$c_h comment='Host privileges; Merged with database privileges';" c_h="$c_h comment='Host privileges; Merged with database privileges';"
......
...@@ -370,13 +370,18 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, ...@@ -370,13 +370,18 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
{ {
if (write_keys(param,sort_keys,idx,buffpek_pointers,tempfile)) if (write_keys(param,sort_keys,idx,buffpek_pointers,tempfile))
DBUG_RETURN(HA_POS_ERROR); DBUG_RETURN(HA_POS_ERROR);
idx=0; indexpos++; idx=0;
if (param->ref_length == param->sort_length && if (param->ref_length == param->sort_length &&
my_b_tell(tempfile)/param->sort_length >= param->max_rows) my_b_tell(tempfile)/param->sort_length >= param->max_rows)
{ {
/*
We are writing the result index file and have found all
rows that we need. Abort the sort and return the result.
*/
error=HA_ERR_END_OF_FILE; error=HA_ERR_END_OF_FILE;
break; /* Found enough records */ break; /* Found enough records */
} }
indexpos++;
} }
make_sortkey(param,sort_keys[idx++],ref_pos); make_sortkey(param,sort_keys[idx++],ref_pos);
} }
...@@ -391,7 +396,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, ...@@ -391,7 +396,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
file->print_error(error,MYF(ME_ERROR | ME_WAITTANG)); /* purecov: inspected */ file->print_error(error,MYF(ME_ERROR | ME_WAITTANG)); /* purecov: inspected */
DBUG_RETURN(HA_POS_ERROR); /* purecov: inspected */ DBUG_RETURN(HA_POS_ERROR); /* purecov: inspected */
} }
if (indexpos && if (indexpos && idx &&
write_keys(param,sort_keys,idx,buffpek_pointers,tempfile)) write_keys(param,sort_keys,idx,buffpek_pointers,tempfile))
DBUG_RETURN(HA_POS_ERROR); /* purecov: inspected */ DBUG_RETURN(HA_POS_ERROR); /* purecov: inspected */
DBUG_RETURN(my_b_inited(tempfile) ? DBUG_RETURN(my_b_inited(tempfile) ?
...@@ -759,7 +764,11 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file, ...@@ -759,7 +764,11 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file,
} }
buffpek->key+=sort_length; buffpek->key+=sort_length;
buffpek->mem_count--; buffpek->mem_count--;
max_rows--; if (!--max_rows)
{
error=0; /* purecov: inspected */
goto end; /* purecov: inspected */
}
queue_replaced(&queue); // Top element has been used queue_replaced(&queue); // Top element has been used
} }
else else
......
...@@ -309,6 +309,7 @@ void mysql_init_select(LEX *lex); ...@@ -309,6 +309,7 @@ void mysql_init_select(LEX *lex);
bool mysql_new_select(LEX *lex); bool mysql_new_select(LEX *lex);
void mysql_init_multi_delete(LEX *lex); void mysql_init_multi_delete(LEX *lex);
void init_max_user_conn(void); void init_max_user_conn(void);
void init_update_queries(void);
void free_max_user_conn(void); void free_max_user_conn(void);
pthread_handler_decl(handle_one_connection,arg); pthread_handler_decl(handle_one_connection,arg);
pthread_handler_decl(handle_bootstrap,arg); pthread_handler_decl(handle_bootstrap,arg);
...@@ -676,11 +677,14 @@ extern SHOW_COMP_OPTION have_isam, have_innodb, have_berkeley_db; ...@@ -676,11 +677,14 @@ extern SHOW_COMP_OPTION have_isam, have_innodb, have_berkeley_db;
extern SHOW_COMP_OPTION have_raid, have_openssl, have_symlink; extern SHOW_COMP_OPTION have_raid, have_openssl, have_symlink;
extern SHOW_COMP_OPTION have_query_cache, have_berkeley_db, have_innodb; extern SHOW_COMP_OPTION have_query_cache, have_berkeley_db, have_innodb;
#ifndef __WIN__ #ifndef __WIN__
extern pthread_t signal_thread; extern pthread_t signal_thread;
#endif #endif
#ifdef HAVE_OPENSSL
extern struct st_VioSSLAcceptorFd * ssl_acceptor_fd;
#endif /* HAVE_OPENSSL */
MYSQL_LOCK *mysql_lock_tables(THD *thd,TABLE **table,uint count); MYSQL_LOCK *mysql_lock_tables(THD *thd,TABLE **table,uint count);
void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock); void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock);
void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock); void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock);
......
...@@ -2049,6 +2049,7 @@ int main(int argc, char **argv) ...@@ -2049,6 +2049,7 @@ int main(int argc, char **argv)
if (!opt_noacl) if (!opt_noacl)
(void) grant_init(); (void) grant_init();
init_max_user_conn(); init_max_user_conn();
init_update_queries();
#ifdef HAVE_DLOPEN #ifdef HAVE_DLOPEN
if (!opt_noacl) if (!opt_noacl)
......
...@@ -114,32 +114,6 @@ static void update_hostname(acl_host_and_ip *host, const char *hostname); ...@@ -114,32 +114,6 @@ static void update_hostname(acl_host_and_ip *host, const char *hostname);
static bool compare_hostname(const acl_host_and_ip *host, const char *hostname, static bool compare_hostname(const acl_host_and_ip *host, const char *hostname,
const char *ip); const char *ip);
extern char uc_update_queries[SQLCOM_END];
static void init_update_queries(void)
{
uc_update_queries[SQLCOM_CREATE_TABLE]=1;
uc_update_queries[SQLCOM_CREATE_INDEX]=1;
uc_update_queries[SQLCOM_ALTER_TABLE]=1;
uc_update_queries[SQLCOM_UPDATE]=1;
uc_update_queries[SQLCOM_INSERT]=1;
uc_update_queries[SQLCOM_INSERT_SELECT]=1;
uc_update_queries[SQLCOM_DELETE]=1;
uc_update_queries[SQLCOM_TRUNCATE]=1;
uc_update_queries[SQLCOM_DROP_TABLE]=1;
uc_update_queries[SQLCOM_LOAD]=1;
uc_update_queries[SQLCOM_CREATE_DB]=1;
uc_update_queries[SQLCOM_DROP_DB]=1;
uc_update_queries[SQLCOM_REPLACE]=1;
uc_update_queries[SQLCOM_REPLACE_SELECT]=1;
uc_update_queries[SQLCOM_RENAME_TABLE]=1;
uc_update_queries[SQLCOM_BACKUP_TABLE]=1;
uc_update_queries[SQLCOM_RESTORE_TABLE]=1;
uc_update_queries[SQLCOM_DELETE_MULTI]=1;
uc_update_queries[SQLCOM_DROP_INDEX]=1;
uc_update_queries[SQLCOM_MULTI_UPDATE]=1;
}
/* /*
Read grant privileges from the privilege tables in the 'mysql' database. Read grant privileges from the privilege tables in the 'mysql' database.
...@@ -214,7 +188,7 @@ my_bool acl_init(bool dont_read_acl_tables) ...@@ -214,7 +188,7 @@ my_bool acl_init(bool dont_read_acl_tables)
if (table->fields == 8) if (table->fields == 8)
{ // Without grant { // Without grant
if (host.access & CREATE_ACL) if (host.access & CREATE_ACL)
host.access|=REFERENCES_ACL | INDEX_ACL | ALTER_ACL; host.access|=REFERENCES_ACL | INDEX_ACL | ALTER_ACL | CREATE_TMP_ACL;
} }
#endif #endif
VOID(push_dynamic(&acl_hosts,(gptr) &host)); VOID(push_dynamic(&acl_hosts,(gptr) &host));
...@@ -350,7 +324,6 @@ my_bool acl_init(bool dont_read_acl_tables) ...@@ -350,7 +324,6 @@ my_bool acl_init(bool dont_read_acl_tables)
mysql_unlock_tables(thd, lock); mysql_unlock_tables(thd, lock);
initialized=1; initialized=1;
init_update_queries();
thd->version--; // Force close to free memory thd->version--; // Force close to free memory
return_val=0; return_val=0;
...@@ -1339,6 +1312,7 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo, ...@@ -1339,6 +1312,7 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
strlen(thd->lex.x509_subject)); strlen(thd->lex.x509_subject));
break; break;
case SSL_TYPE_NOT_SPECIFIED: case SSL_TYPE_NOT_SPECIFIED:
case SSL_TYPE_NONE: // Impossible
break; // Nothing to do break; // Nothing to do
} }
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#define DB_ACLS \ #define DB_ACLS \
(UPDATE_ACL | SELECT_ACL | INSERT_ACL | DELETE_ACL | CREATE_ACL | DROP_ACL | \ (UPDATE_ACL | SELECT_ACL | INSERT_ACL | DELETE_ACL | CREATE_ACL | DROP_ACL | \
GRANT_ACL | REFERENCES_ACL | INDEX_ACL | ALTER_ACL) GRANT_ACL | REFERENCES_ACL | INDEX_ACL | ALTER_ACL | CREATE_TMP_ACL | LOCK_TABLES_ACL)
#define TABLE_ACLS \ #define TABLE_ACLS \
(SELECT_ACL | INSERT_ACL | UPDATE_ACL | DELETE_ACL | CREATE_ACL | DROP_ACL | \ (SELECT_ACL | INSERT_ACL | UPDATE_ACL | DELETE_ACL | CREATE_ACL | DROP_ACL | \
...@@ -59,10 +59,21 @@ ...@@ -59,10 +59,21 @@
#define EXTRA_ACL (1L << 29) #define EXTRA_ACL (1L << 29)
#define NO_ACCESS (1L << 30) #define NO_ACCESS (1L << 30)
/* defines to change the above bits to how things are stored in tables */ /*
Defines to change the above bits to how things are stored in tables
This is needed as the 'host' and 'db' table is missing a few privileges
*/
/* Continius bit-segments that needs to be shifted */
#define DB_REL1 (RELOAD_ACL | SHUTDOWN_ACL | PROCESS_ACL | FILE_ACL)
#define DB_REL2 (GRANT_ACL | REFERENCES_ACL)
/* Privileges that needs to be reallocated (in continous chunks) */
#define DB_CHUNK1 (GRANT_ACL | REFERENCES_ACL | INDEX_ACL | ALTER_ACL)
#define DB_CHUNK2 (CREATE_TMP_ACL | LOCK_TABLES_ACL)
#define fix_rights_for_db(A) (((A) & 63) | (((A) & ~63) << 4)) #define fix_rights_for_db(A) (((A) & 63) | (((A) & DB_REL1) << 4) | (((A) & DB_REL2) << 6))
#define get_rights_for_db(A) (((A) & 63) | (((A) & ~63) >> 4)) #define get_rights_for_db(A) (((A) & 63) | (((A) & DB_CHUNK1) >> 4) | (((A) & DB_CHUNK2) >> 6))
#define fix_rights_for_table(A) (((A) & 63) | (((A) & ~63) << 4)) #define fix_rights_for_table(A) (((A) & 63) | (((A) & ~63) << 4))
#define get_rights_for_table(A) (((A) & 63) | (((A) & ~63) >> 4)) #define get_rights_for_table(A) (((A) & 63) | (((A) & ~63) >> 4))
#define fix_rights_for_column(A) (((A) & COL_ACLS) | ((A & ~COL_ACLS) << 7)) #define fix_rights_for_column(A) (((A) & COL_ACLS) | ((A & ~COL_ACLS) << 7))
......
...@@ -80,10 +80,6 @@ const char *command_name[]={ ...@@ -80,10 +80,6 @@ const char *command_name[]={
bool volatile abort_slave = 0; bool volatile abort_slave = 0;
#ifdef HAVE_OPENSSL
extern struct st_VioSSLAcceptorFd * ssl_acceptor_fd;
#endif /* HAVE_OPENSSL */
#ifdef __WIN__ #ifdef __WIN__
static void test_signal(int sig_ptr) static void test_signal(int sig_ptr)
{ {
...@@ -330,6 +326,38 @@ void free_max_user_conn(void) ...@@ -330,6 +326,38 @@ void free_max_user_conn(void)
} }
/*
Mark all commands that somehow changes a table
This is used to check number of updates / hour
*/
char uc_update_queries[SQLCOM_END];
void init_update_queries(void)
{
uc_update_queries[SQLCOM_CREATE_TABLE]=1;
uc_update_queries[SQLCOM_CREATE_INDEX]=1;
uc_update_queries[SQLCOM_ALTER_TABLE]=1;
uc_update_queries[SQLCOM_UPDATE]=1;
uc_update_queries[SQLCOM_INSERT]=1;
uc_update_queries[SQLCOM_INSERT_SELECT]=1;
uc_update_queries[SQLCOM_DELETE]=1;
uc_update_queries[SQLCOM_TRUNCATE]=1;
uc_update_queries[SQLCOM_DROP_TABLE]=1;
uc_update_queries[SQLCOM_LOAD]=1;
uc_update_queries[SQLCOM_CREATE_DB]=1;
uc_update_queries[SQLCOM_DROP_DB]=1;
uc_update_queries[SQLCOM_REPLACE]=1;
uc_update_queries[SQLCOM_REPLACE_SELECT]=1;
uc_update_queries[SQLCOM_RENAME_TABLE]=1;
uc_update_queries[SQLCOM_BACKUP_TABLE]=1;
uc_update_queries[SQLCOM_RESTORE_TABLE]=1;
uc_update_queries[SQLCOM_DELETE_MULTI]=1;
uc_update_queries[SQLCOM_DROP_INDEX]=1;
uc_update_queries[SQLCOM_MULTI_UPDATE]=1;
}
/* /*
Check if maximum queries per hour limit has been reached Check if maximum queries per hour limit has been reached
returns 0 if OK. returns 0 if OK.
...@@ -339,7 +367,6 @@ void free_max_user_conn(void) ...@@ -339,7 +367,6 @@ void free_max_user_conn(void)
a couple of queries, this isn't critical. a couple of queries, this isn't critical.
*/ */
char uc_update_queries[SQLCOM_END];
static bool check_mqh(THD *thd, uint check_command) static bool check_mqh(THD *thd, uint check_command)
{ {
......
...@@ -322,10 +322,10 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild) ...@@ -322,10 +322,10 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_NO_LOCK); file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_NO_LOCK);
net_store_data(packet, convert, file->table_type()); net_store_data(packet, convert, file->table_type());
net_store_data(packet, convert, net_store_data(packet, convert,
(table->db_options_in_use & HA_OPTION_COMPRESS_RECORD) ?
"Compressed" :
(table->db_options_in_use & HA_OPTION_PACK_RECORD) ? (table->db_options_in_use & HA_OPTION_PACK_RECORD) ?
"Dynamic" : "Dynamic" : "Fixed");
(table->db_options_in_use & HA_OPTION_COMPRESS_RECORD)
? "Compressed" : "Fixed");
net_store_data(packet, (longlong) file->records); net_store_data(packet, (longlong) file->records);
net_store_data(packet, (uint32) file->mean_rec_length); net_store_data(packet, (uint32) file->mean_rec_length);
net_store_data(packet, (longlong) file->data_file_length); net_store_data(packet, (longlong) file->data_file_length);
......
...@@ -866,7 +866,7 @@ bool close_cached_table(THD *thd,TABLE *table) ...@@ -866,7 +866,7 @@ bool close_cached_table(THD *thd,TABLE *table)
if (table) if (table)
{ {
DBUG_PRINT("enter",("table: %s", table->table_name)); DBUG_PRINT("enter",("table: %s", table->real_name));
VOID(table->file->extra(HA_EXTRA_FORCE_REOPEN)); // Close all data files VOID(table->file->extra(HA_EXTRA_FORCE_REOPEN)); // Close all data files
/* Mark all tables that are in use as 'old' */ /* Mark all tables that are in use as 'old' */
mysql_lock_abort(thd,table); // end threads waiting on lock mysql_lock_abort(thd,table); // end threads waiting on lock
...@@ -874,7 +874,7 @@ bool close_cached_table(THD *thd,TABLE *table) ...@@ -874,7 +874,7 @@ bool close_cached_table(THD *thd,TABLE *table)
#if defined(USING_TRANSACTIONS) || defined( __WIN__) || defined( __EMX__) || !defined(OS2) #if defined(USING_TRANSACTIONS) || defined( __WIN__) || defined( __EMX__) || !defined(OS2)
/* Wait until all there are no other threads that has this table open */ /* Wait until all there are no other threads that has this table open */
while (remove_table_from_cache(thd,table->table_cache_key, while (remove_table_from_cache(thd,table->table_cache_key,
table->table_name)) table->real_name))
{ {
dropping_tables++; dropping_tables++;
(void) pthread_cond_wait(&COND_refresh,&LOCK_open); (void) pthread_cond_wait(&COND_refresh,&LOCK_open);
...@@ -882,7 +882,7 @@ bool close_cached_table(THD *thd,TABLE *table) ...@@ -882,7 +882,7 @@ bool close_cached_table(THD *thd,TABLE *table)
} }
#else #else
(void) remove_table_from_cache(thd,table->table_cache_key, (void) remove_table_from_cache(thd,table->table_cache_key,
table->table_name); table->real_name);
#endif #endif
/* When lock on LOCK_open is freed other threads can continue */ /* When lock on LOCK_open is freed other threads can continue */
pthread_cond_broadcast(&COND_refresh); pthread_cond_broadcast(&COND_refresh);
...@@ -932,7 +932,7 @@ static int prepare_for_restore(THD* thd, TABLE_LIST* table, ...@@ -932,7 +932,7 @@ static int prepare_for_restore(THD* thd, TABLE_LIST* table,
{ {
char* backup_dir = thd->lex.backup_dir; char* backup_dir = thd->lex.backup_dir;
char src_path[FN_REFLEN], dst_path[FN_REFLEN]; char src_path[FN_REFLEN], dst_path[FN_REFLEN];
char* table_name = table->name; char* table_name = table->real_name;
char* db = thd->db ? thd->db : table->db; char* db = thd->db ? thd->db : table->db;
if (fn_format_relative_to_data_home(src_path, table_name, backup_dir, if (fn_format_relative_to_data_home(src_path, table_name, backup_dir,
......
...@@ -120,7 +120,6 @@ int vio_blocking(Vio * vio __attribute__((unused)), my_bool set_blocking_mode, ...@@ -120,7 +120,6 @@ int vio_blocking(Vio * vio __attribute__((unused)), my_bool set_blocking_mode,
DBUG_PRINT("enter", ("set_blocking_mode: %d old_mode: %d", DBUG_PRINT("enter", ("set_blocking_mode: %d old_mode: %d",
(int) set_blocking_mode, (int) *old_mode)); (int) set_blocking_mode, (int) *old_mode));
#if !defined(HAVE_OPENSSL)
#if !defined(___WIN__) && !defined(__EMX__) #if !defined(___WIN__) && !defined(__EMX__)
#if !defined(NO_FCNTL_NONBLOCK) #if !defined(NO_FCNTL_NONBLOCK)
if (vio->sd >= 0) if (vio->sd >= 0)
...@@ -161,7 +160,6 @@ int vio_blocking(Vio * vio __attribute__((unused)), my_bool set_blocking_mode, ...@@ -161,7 +160,6 @@ int vio_blocking(Vio * vio __attribute__((unused)), my_bool set_blocking_mode,
r= test(!(vio->fcntl_mode & O_NONBLOCK)) != set_blocking_mode; r= test(!(vio->fcntl_mode & O_NONBLOCK)) != set_blocking_mode;
#endif /* __EMX__ */ #endif /* __EMX__ */
#endif /* !defined(__WIN__) && !defined(__EMX__) */ #endif /* !defined(__WIN__) && !defined(__EMX__) */
#endif /* !defined (HAVE_OPENSSL) */
DBUG_PRINT("exit", ("%d", r)); DBUG_PRINT("exit", ("%d", r));
DBUG_RETURN(r); DBUG_RETURN(r);
} }
......
...@@ -44,28 +44,30 @@ report_errors() ...@@ -44,28 +44,30 @@ report_errors()
unsigned long l; unsigned long l;
const char* file; const char* file;
const char* data; const char* data;
int line,flags, any_ssl_error = 0; int line,flags;
DBUG_ENTER("report_errors"); DBUG_ENTER("report_errors");
while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0) while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)))
{ {
char buf[200]; char buf[512];
any_ssl_error = 1;
DBUG_PRINT("error", ("OpenSSL: %s:%s:%d:%s\n", ERR_error_string(l,buf), DBUG_PRINT("error", ("OpenSSL: %s:%s:%d:%s\n", ERR_error_string(l,buf),
file,line,(flags&ERR_TXT_STRING)?data:"")) ; file,line,(flags&ERR_TXT_STRING)?data:"")) ;
} }
if (!any_ssl_error) { DBUG_PRINT("info", ("errno: %d", socket_errno));
DBUG_PRINT("info", ("No OpenSSL errors."));
}
DBUG_PRINT("info", ("BTW, errno=%d", socket_errno));
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/*
Delete a vio object
SYNPOSIS
vio_ssl_delete()
vio Vio object. May be 0.
*/
void vio_ssl_delete(Vio * vio) void vio_ssl_delete(Vio * vio)
{ {
/* It must be safe to delete null pointers. */
/* This matches the semantics of C++'s delete operator. */
if (vio) if (vio)
{ {
if (vio->type != VIO_CLOSED) if (vio->type != VIO_CLOSED)
...@@ -74,6 +76,7 @@ void vio_ssl_delete(Vio * vio) ...@@ -74,6 +76,7 @@ void vio_ssl_delete(Vio * vio)
} }
} }
int vio_ssl_errno(Vio *vio __attribute__((unused))) int vio_ssl_errno(Vio *vio __attribute__((unused)))
{ {
return socket_errno; /* On Win32 this mapped to WSAGetLastError() */ return socket_errno; /* On Win32 this mapped to WSAGetLastError() */
...@@ -87,17 +90,12 @@ int vio_ssl_read(Vio * vio, gptr buf, int size) ...@@ -87,17 +90,12 @@ int vio_ssl_read(Vio * vio, gptr buf, int size)
DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d, ssl_=%p", DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d, ssl_=%p",
vio->sd, buf, size, vio->ssl_)); vio->sd, buf, size, vio->ssl_));
#ifndef DBUG_OFF if ((r= SSL_read(vio->ssl_, buf, size)) < 0)
errno = 0; {
#endif /* DBUG_OFF */ int err= SSL_get_error(vio->ssl_, r);
r = SSL_read(vio->ssl_, buf, size); DBUG_PRINT("error",("SSL_read(): %d SSL_get_error(): %d", r, err));
#ifndef DBUG_OFF
if ( r<= 0) {
r=SSL_get_error(vio->ssl_, r);
DBUG_PRINT("info",("SSL_get_error returned %d",r));
report_errors(); report_errors();
} }
#endif /* DBUG_OFF */
DBUG_PRINT("exit", ("%d", r)); DBUG_PRINT("exit", ("%d", r));
DBUG_RETURN(r); DBUG_RETURN(r);
} }
...@@ -109,14 +107,8 @@ int vio_ssl_write(Vio * vio, const gptr buf, int size) ...@@ -109,14 +107,8 @@ int vio_ssl_write(Vio * vio, const gptr buf, int size)
DBUG_ENTER("vio_ssl_write"); DBUG_ENTER("vio_ssl_write");
DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size)); DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
#ifndef DBUG_OFF if ((r= SSL_write(vio->ssl_, buf, size)) < 0)
errno = 0;
#endif /* DBUG_OFF */
r = SSL_write(vio->ssl_, buf, size);
#ifndef DBUG_OFF
if (r<0)
report_errors(); report_errors();
#endif /* DBUG_OFF */
DBUG_PRINT("exit", ("%d", r)); DBUG_PRINT("exit", ("%d", r));
DBUG_RETURN(r); DBUG_RETURN(r);
} }
...@@ -124,7 +116,7 @@ int vio_ssl_write(Vio * vio, const gptr buf, int size) ...@@ -124,7 +116,7 @@ int vio_ssl_write(Vio * vio, const gptr buf, int size)
int vio_ssl_fastsend(Vio * vio __attribute__((unused))) int vio_ssl_fastsend(Vio * vio __attribute__((unused)))
{ {
int r=0; int r= 0;
DBUG_ENTER("vio_ssl_fastsend"); DBUG_ENTER("vio_ssl_fastsend");
#ifdef IPTOS_THROUGHPUT #ifdef IPTOS_THROUGHPUT
...@@ -148,19 +140,18 @@ int vio_ssl_fastsend(Vio * vio __attribute__((unused))) ...@@ -148,19 +140,18 @@ int vio_ssl_fastsend(Vio * vio __attribute__((unused)))
DBUG_RETURN(r); DBUG_RETURN(r);
} }
int vio_ssl_keepalive(Vio* vio, my_bool set_keep_alive) int vio_ssl_keepalive(Vio* vio, my_bool set_keep_alive)
{ {
int r=0; int r=0;
uint opt = 0;
DBUG_ENTER("vio_ssl_keepalive"); DBUG_ENTER("vio_ssl_keepalive");
DBUG_PRINT("enter", ("sd=%d, set_keep_alive=%d", vio->sd, (int) DBUG_PRINT("enter", ("sd=%d, set_keep_alive=%d", vio->sd, (int)
set_keep_alive)); set_keep_alive));
if (vio->type != VIO_TYPE_NAMEDPIPE) if (vio->type != VIO_TYPE_NAMEDPIPE)
{ {
if (set_keep_alive) uint opt = (set_keep_alive) ? 1 : 0;
opt = 1; r= setsockopt(vio->sd, SOL_SOCKET, SO_KEEPALIVE, (char *) &opt,
r = setsockopt(vio->sd, SOL_SOCKET, SO_KEEPALIVE, (char *) &opt, sizeof(opt));
sizeof(opt));
} }
DBUG_RETURN(r); DBUG_RETURN(r);
} }
...@@ -186,10 +177,13 @@ int vio_ssl_close(Vio * vio) ...@@ -186,10 +177,13 @@ int vio_ssl_close(Vio * vio)
SSL_free(vio->ssl_); SSL_free(vio->ssl_);
vio->ssl_= 0; vio->ssl_= 0;
} }
if (shutdown(vio->sd,2)) if (vio->sd >= 0)
r= -1; {
if (closesocket(vio->sd)) if (shutdown(vio->sd, 2))
r= -1; r= -1;
if (closesocket(vio->sd))
r= -1;
}
if (r) if (r)
{ {
DBUG_PRINT("error", ("close() failed, error: %d",socket_errno)); DBUG_PRINT("error", ("close() failed, error: %d",socket_errno));
...@@ -254,6 +248,10 @@ void vio_ssl_in_addr(Vio *vio, struct in_addr *in) ...@@ -254,6 +248,10 @@ void vio_ssl_in_addr(Vio *vio, struct in_addr *in)
} }
/*
TODO: Add documentation and error handling
*/
void sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout) void sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout)
{ {
char *str; char *str;
...@@ -263,6 +261,7 @@ void sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout) ...@@ -263,6 +261,7 @@ void sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout)
DBUG_ENTER("sslaccept"); DBUG_ENTER("sslaccept");
DBUG_PRINT("enter", ("sd=%d ptr=%p", vio->sd,ptr)); DBUG_PRINT("enter", ("sd=%d ptr=%p", vio->sd,ptr));
vio_blocking(vio, 1, &unused); /* Must be called before reset */
vio_reset(vio,VIO_TYPE_SSL,vio->sd,0,FALSE); vio_reset(vio,VIO_TYPE_SSL,vio->sd,0,FALSE);
vio->ssl_=0; vio->ssl_=0;
vio->open_=FALSE; vio->open_=FALSE;
...@@ -274,7 +273,6 @@ void sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout) ...@@ -274,7 +273,6 @@ void sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout)
} }
DBUG_PRINT("info", ("ssl_=%p timeout=%ld",vio->ssl_, timeout)); DBUG_PRINT("info", ("ssl_=%p timeout=%ld",vio->ssl_, timeout));
SSL_clear(vio->ssl_); SSL_clear(vio->ssl_);
vio_blocking(vio, FALSE, &unused);
SSL_SESSION_set_timeout(SSL_get_session(vio->ssl_), timeout); SSL_SESSION_set_timeout(SSL_get_session(vio->ssl_), timeout);
SSL_set_fd(vio->ssl_,vio->sd); SSL_set_fd(vio->ssl_,vio->sd);
SSL_set_accept_state(vio->ssl_); SSL_set_accept_state(vio->ssl_);
...@@ -284,7 +282,8 @@ void sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout) ...@@ -284,7 +282,8 @@ void sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout)
DBUG_PRINT("info",("SSL_get_cipher_name() = '%s'" DBUG_PRINT("info",("SSL_get_cipher_name() = '%s'"
,SSL_get_cipher_name(vio->ssl_))); ,SSL_get_cipher_name(vio->ssl_)));
client_cert = SSL_get_peer_certificate (vio->ssl_); client_cert = SSL_get_peer_certificate (vio->ssl_);
if (client_cert != NULL) { if (client_cert != NULL)
{
DBUG_PRINT("info",("Client certificate:")); DBUG_PRINT("info",("Client certificate:"));
str = X509_NAME_oneline (X509_get_subject_name (client_cert), 0, 0); str = X509_NAME_oneline (X509_get_subject_name (client_cert), 0, 0);
DBUG_PRINT("info",("\t subject: %s", str)); DBUG_PRINT("info",("\t subject: %s", str));
...@@ -295,11 +294,12 @@ void sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout) ...@@ -295,11 +294,12 @@ void sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout)
free (str); free (str);
X509_free (client_cert); X509_free (client_cert);
} else }
else
DBUG_PRINT("info",("Client does not have certificate.")); DBUG_PRINT("info",("Client does not have certificate."));
str=SSL_get_shared_ciphers(vio->ssl_, buf, sizeof(buf)); str=SSL_get_shared_ciphers(vio->ssl_, buf, sizeof(buf));
if(str) if (str)
{ {
DBUG_PRINT("info",("SSL_get_shared_ciphers() returned '%s'",str)); DBUG_PRINT("info",("SSL_get_shared_ciphers() returned '%s'",str));
} }
...@@ -313,7 +313,7 @@ void sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout) ...@@ -313,7 +313,7 @@ void sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout)
} }
void sslconnect(struct st_VioSSLConnectorFd* ptr, Vio* vio, long timeout) int sslconnect(struct st_VioSSLConnectorFd* ptr, Vio* vio, long timeout)
{ {
char *str; char *str;
X509* server_cert; X509* server_cert;
...@@ -321,6 +321,7 @@ void sslconnect(struct st_VioSSLConnectorFd* ptr, Vio* vio, long timeout) ...@@ -321,6 +321,7 @@ void sslconnect(struct st_VioSSLConnectorFd* ptr, Vio* vio, long timeout)
DBUG_ENTER("sslconnect"); DBUG_ENTER("sslconnect");
DBUG_PRINT("enter", ("sd=%d ptr=%p ctx: %p", vio->sd,ptr,ptr->ssl_context_)); DBUG_PRINT("enter", ("sd=%d ptr=%p ctx: %p", vio->sd,ptr,ptr->ssl_context_));
vio_blocking(vio, 1, &unused); /* Must be called before reset */
vio_reset(vio,VIO_TYPE_SSL,vio->sd,0,FALSE); vio_reset(vio,VIO_TYPE_SSL,vio->sd,0,FALSE);
vio->ssl_=0; vio->ssl_=0;
vio->open_=FALSE; vio->open_=FALSE;
...@@ -328,11 +329,10 @@ void sslconnect(struct st_VioSSLConnectorFd* ptr, Vio* vio, long timeout) ...@@ -328,11 +329,10 @@ void sslconnect(struct st_VioSSLConnectorFd* ptr, Vio* vio, long timeout)
{ {
DBUG_PRINT("error", ("SSL_new failure")); DBUG_PRINT("error", ("SSL_new failure"));
report_errors(); report_errors();
DBUG_VOID_RETURN; DBUG_RETURN(1);
} }
DBUG_PRINT("info", ("ssl_=%p timeout=%ld",vio->ssl_, timeout)); DBUG_PRINT("info", ("ssl_=%p timeout=%ld",vio->ssl_, timeout));
SSL_clear(vio->ssl_); SSL_clear(vio->ssl_);
vio_blocking(vio, FALSE, &unused);
SSL_SESSION_set_timeout(SSL_get_session(vio->ssl_), timeout); SSL_SESSION_set_timeout(SSL_get_session(vio->ssl_), timeout);
SSL_set_fd (vio->ssl_, vio->sd); SSL_set_fd (vio->ssl_, vio->sd);
SSL_set_connect_state(vio->ssl_); SSL_set_connect_state(vio->ssl_);
...@@ -342,24 +342,27 @@ void sslconnect(struct st_VioSSLConnectorFd* ptr, Vio* vio, long timeout) ...@@ -342,24 +342,27 @@ void sslconnect(struct st_VioSSLConnectorFd* ptr, Vio* vio, long timeout)
DBUG_PRINT("info",("SSL_get_cipher_name() = '%s'" DBUG_PRINT("info",("SSL_get_cipher_name() = '%s'"
,SSL_get_cipher_name(vio->ssl_))); ,SSL_get_cipher_name(vio->ssl_)));
server_cert = SSL_get_peer_certificate (vio->ssl_); server_cert = SSL_get_peer_certificate (vio->ssl_);
if (server_cert != NULL) { if (server_cert != NULL)
{
DBUG_PRINT("info",("Server certificate:")); DBUG_PRINT("info",("Server certificate:"));
str = X509_NAME_oneline (X509_get_subject_name (server_cert), 0, 0); str = X509_NAME_oneline (X509_get_subject_name (server_cert), 0, 0);
DBUG_PRINT("info",("\t subject: %s", str)); DBUG_PRINT("info",("\t subject: %s", str));
free (str); free(str);
str = X509_NAME_oneline (X509_get_issuer_name (server_cert), 0, 0); str = X509_NAME_oneline (X509_get_issuer_name (server_cert), 0, 0);
DBUG_PRINT("info",("\t issuer: %s", str)); DBUG_PRINT("info",("\t issuer: %s", str));
free (str); free(str);
/* We could do all sorts of certificate verification stuff here before
* deallocating the certificate. */
/*
We could do all sorts of certificate verification stuff here before
deallocating the certificate.
*/
X509_free (server_cert); X509_free (server_cert);
} else }
else
DBUG_PRINT("info",("Server does not have certificate.")); DBUG_PRINT("info",("Server does not have certificate."));
#endif #endif
DBUG_VOID_RETURN; DBUG_RETURN(0);
} }
......
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