diff options
author | Sergei Golubchik <sergii@pisem.net> | 2011-11-03 19:17:05 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2011-11-03 19:17:05 +0100 |
commit | 0e007344eae972b9be7d88ca43373cb33662ac1c (patch) | |
tree | 7b3561cb3ea2ad24d013e847680ec165f406387e /plugin/win_auth_client | |
parent | 3794110f0215f0631107c2694dc0f1675a4bb520 (diff) | |
parent | 681476255147dacac7e3674b6cd2ae770fee2208 (diff) | |
download | mariadb-git-0e007344eae972b9be7d88ca43373cb33662ac1c.tar.gz |
mysql-5.5.18 merge
Diffstat (limited to 'plugin/win_auth_client')
-rw-r--r-- | plugin/win_auth_client/common.cc | 18 | ||||
-rw-r--r-- | plugin/win_auth_client/common.h | 14 | ||||
-rw-r--r-- | plugin/win_auth_client/handshake_client.cc | 27 | ||||
-rw-r--r-- | plugin/win_auth_client/log_client.cc | 50 |
4 files changed, 76 insertions, 33 deletions
diff --git a/plugin/win_auth_client/common.cc b/plugin/win_auth_client/common.cc index 1d1f2938969..9544e7734f5 100644 --- a/plugin/win_auth_client/common.cc +++ b/plugin/win_auth_client/common.cc @@ -22,6 +22,24 @@ template <> void error_log_print<error_log_level::INFO>(const char *fmt, ...); template <> void error_log_print<error_log_level::WARNING>(const char *fmt, ...); template <> void error_log_print<error_log_level::ERROR>(const char *fmt, ...); +/** + Option indicating desired level of logging. Values: + + 0 - no logging + 1 - log only error messages + 2 - additionally log warnings + 3 - additionally log info notes + 4 - also log debug messages + + Value of this option should be taken into account in the + implementation of error_log_vprint() function (see + log_client.cc). + + Note: No error or debug messages are logged in production code + (see logging macros in common.h). +*/ +int opt_auth_win_log_level= 2; + /** Connection class **************************************************/ diff --git a/plugin/win_auth_client/common.h b/plugin/win_auth_client/common.h index ff0f7153664..7f7aa1d2dff 100644 --- a/plugin/win_auth_client/common.h +++ b/plugin/win_auth_client/common.h @@ -41,13 +41,15 @@ struct error_log_level typedef enum {INFO, WARNING, ERROR} type; }; +extern "C" int opt_auth_win_log_level; +unsigned int get_log_level(void); +void set_log_level(unsigned int); + /* If DEBUG_ERROR_LOG is defined then error logging happens only in debug-copiled code. Otherwise ERROR_LOG() expands to - error_log_print() even in production code. Note that in client - plugin, error_log_print() will print nothing if opt_auth_win_clinet_log - is 0. + error_log_print() even in production code. Note: Macro ERROR_LOG() can use printf-like format string like this: @@ -57,8 +59,6 @@ struct error_log_level to fprintf() (see error_log_vprint() function). */ -extern "C" int opt_auth_win_client_log; - #if defined(DEBUG_ERROR_LOG) && defined(DBUG_OFF) #define ERROR_LOG(Level, Msg) do {} while (0) #else @@ -67,7 +67,7 @@ extern "C" int opt_auth_win_client_log; void error_log_vprint(error_log_level::type level, - const char *fmt, va_list args); + const char *fmt, va_list args); template <error_log_level::type Level> void error_log_print(const char *fmt, ...) @@ -96,7 +96,7 @@ const char* get_last_error_message(Error_message_buf); #define DBUG_PRINT_DO(Keyword, Msg) \ do { \ - if (2 > opt_auth_win_client_log) break; \ + if (4 > get_log_level()) break; \ fprintf(stderr, "winauth: %s: ", Keyword); \ debug_msg Msg; \ } while (0) diff --git a/plugin/win_auth_client/handshake_client.cc b/plugin/win_auth_client/handshake_client.cc index 7e89fc92ae7..02e5483da29 100644 --- a/plugin/win_auth_client/handshake_client.cc +++ b/plugin/win_auth_client/handshake_client.cc @@ -161,6 +161,21 @@ int Handshake_client::write_packet(Blob &data) keep all the data. */ unsigned block_count= data.len()/512 + ((data.len() % 512) ? 1 : 0); + +#if !defined(DBUG_OFF) && defined(WINAUTH_USE_DBUG_LIB) + + /* + For testing purposes, use wrong block count to see how server + handles this. + */ + DBUG_EXECUTE_IF("winauth_first_packet_test",{ + block_count= data.len() == 601 ? 0 : + data.len() == 602 ? 1 : + block_count; + }); + +#endif + DBUG_ASSERT(block_count < (unsigned)0x100); saved_byte= data[254]; data[254] = block_count; @@ -323,13 +338,13 @@ int win_auth_handshake_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) int opt_val= opt ? atoi(opt) : 0; if (opt && !opt_val) { - if (!strncasecmp("on", opt, 2)) opt_val= 1; - if (!strncasecmp("yes", opt, 3)) opt_val= 1; - if (!strncasecmp("true", opt, 4)) opt_val= 1; - if (!strncasecmp("debug", opt, 5)) opt_val= 2; - if (!strncasecmp("dbug", opt, 4)) opt_val= 2; + if (!strncasecmp("on", opt, 2)) opt_val= 2; + if (!strncasecmp("yes", opt, 3)) opt_val= 2; + if (!strncasecmp("true", opt, 4)) opt_val= 2; + if (!strncasecmp("debug", opt, 5)) opt_val= 4; + if (!strncasecmp("dbug", opt, 4)) opt_val= 4; } - opt_auth_win_client_log= opt_val; + set_log_level(opt_val); } ERROR_LOG(INFO, ("Authentication handshake for account %s", mysql->user)); diff --git a/plugin/win_auth_client/log_client.cc b/plugin/win_auth_client/log_client.cc index df4ce4f9c2a..8a49c4220bb 100644 --- a/plugin/win_auth_client/log_client.cc +++ b/plugin/win_auth_client/log_client.cc @@ -16,36 +16,32 @@ #include <my_global.h> #include "common.h" -/** - This option is set in win_auth_handshake_client() function - in handshake_client.cc. - - Values: - 0 - no logging - 1 - log error/warning/info messages - 2 - also log debug messages - - Note: No error or debug messages are logged in production code - (see logging macros in common.h). -*/ -int opt_auth_win_client_log= 0; - // Client-side logging function void error_log_vprint(error_log_level::type level, const char *fmt, va_list args) { - if (0 == opt_auth_win_client_log) - return; - const char *level_string= ""; + int log_level= get_log_level(); switch (level) { - case error_log_level::INFO: level_string= "Note"; break; - case error_log_level::WARNING: level_string= "Warning"; break; - case error_log_level::ERROR: level_string= "ERROR"; break; + case error_log_level::INFO: + if (3 > log_level) + return; + level_string= "Note"; + break; + case error_log_level::WARNING: + if (2 > log_level) + return; + level_string= "Warning"; + break; + case error_log_level::ERROR: + if (1 > log_level) + return; + level_string= "ERROR"; + break; } fprintf(stderr, "Windows Authentication Plugin %s: ", level_string); @@ -53,3 +49,17 @@ void error_log_vprint(error_log_level::type level, fputc('\n', stderr); fflush(stderr); } + + +// Trivial implementation of log-level setting storage. + +void set_log_level(unsigned int level) +{ + opt_auth_win_log_level= level; +} + + +unsigned int get_log_level(void) +{ + return opt_auth_win_log_level; +} |