summaryrefslogtreecommitdiff
path: root/libmysql
diff options
context:
space:
mode:
authorRafal Somla <rafal.somla@oracle.com>2011-09-07 20:02:35 +0200
committerRafal Somla <rafal.somla@oracle.com>2011-09-07 20:02:35 +0200
commit362709444f1caa6d98a8df7bb5cbfca369754287 (patch)
tree09892318a33437dd16a7853d61742c1b56e04d60 /libmysql
parent5acc7cacae5be0153487092dc47869a07f70da14 (diff)
downloadmariadb-git-362709444f1caa6d98a8df7bb5cbfca369754287.tar.gz
Bug#12873214 WINDOWS AUTHENTICATION PLUGIN PRODUCES EXCESSIVE RECORDS IN SERVER ERROR LOG
Changed semantics of AUTHENTICATION_WIN_LOG environment variable recognized by client library to accept the following values which are levels of logging done during Windows authentication handshake: 0 - no logging 1 - log only error messages 2 - additionally log warnings 3 - additionally log info notes 4 - also log debug messages Setting it to 'on', 'yes' or 'true' will request log level 2 and setting it to 'debug' or 'dbug' will request log level 4.
Diffstat (limited to 'libmysql')
-rw-r--r--libmysql/authentication_win/common.cc18
-rw-r--r--libmysql/authentication_win/common.h14
-rw-r--r--libmysql/authentication_win/handshake_client.cc12
-rw-r--r--libmysql/authentication_win/log_client.cc50
4 files changed, 61 insertions, 33 deletions
diff --git a/libmysql/authentication_win/common.cc b/libmysql/authentication_win/common.cc
index 1d1f2938969..9544e7734f5 100644
--- a/libmysql/authentication_win/common.cc
+++ b/libmysql/authentication_win/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/libmysql/authentication_win/common.h b/libmysql/authentication_win/common.h
index ff0f7153664..7f7aa1d2dff 100644
--- a/libmysql/authentication_win/common.h
+++ b/libmysql/authentication_win/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/libmysql/authentication_win/handshake_client.cc b/libmysql/authentication_win/handshake_client.cc
index 7e89fc92ae7..565726651cb 100644
--- a/libmysql/authentication_win/handshake_client.cc
+++ b/libmysql/authentication_win/handshake_client.cc
@@ -323,13 +323,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/libmysql/authentication_win/log_client.cc b/libmysql/authentication_win/log_client.cc
index df4ce4f9c2a..8a49c4220bb 100644
--- a/libmysql/authentication_win/log_client.cc
+++ b/libmysql/authentication_win/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;
+}