Skip to content
This repository was archived by the owner on Mar 1, 2026. It is now read-only.

Commit 3ea82d0

Browse files
WL#15336: Support MIT Kerberos library with authentication_kerberos_client on Windows
Description: - Added GSSAPI support for authentication_kerberos_client on Windows - Added new plugin option: plugin_authentication_kerberos_client_use_gssapi in authentication_kerberos_client plugin on Windows - Added ability to set above mentioned option in mysql and mysqldump programs on Windows - Added cmake changes to discover following kerberos libraries if WITH_KERBEROS or new option - WITH_KERBEROS_WIN is specified. - krb5_64 - gssapi64 - comerr64 - k5sprt64 - krbcc64 - xpprof64 Change-Id: I83eb68cd3bf0e6b0c736c75873fe07d964caf5de
1 parent 13dc84f commit 3ea82d0

17 files changed

Lines changed: 492 additions & 144 deletions

‎client/client_priv.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ enum options_client {
183183
OPT_SSL_SESSION_DATA,
184184
OPT_SSL_SESSION_DATA_CONTINUE_ON_FAILED_REUSE,
185185
OPT_LONG_QUERY_TIME,
186+
OPT_AUTHENTICATION_KERBEROS_CLIENT_MODE,
186187
/* Add new option above this */
187188
OPT_MAX_CLIENT_OPTION
188189
};

‎client/mysql.cc‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ static const CHARSET_INFO *charset_info = &my_charset_latin1;
234234
static char *opt_fido_register_factor = nullptr;
235235
static char *opt_oci_config_file = nullptr;
236236

237+
#include "authentication_kerberos_clientopt-vars.h"
237238
#include "caching_sha2_passwordopt-vars.h"
238239
#include "multi_factor_passwordopt-vars.h"
239240
#include "sslopt-vars.h"
@@ -1959,6 +1960,7 @@ static struct my_option my_long_options[] = {
19591960
"is ~/.oci/config and %HOME/.oci/config on Windows.",
19601961
&opt_oci_config_file, &opt_oci_config_file, nullptr, GET_STR, REQUIRED_ARG,
19611962
0, 0, 0, nullptr, 0, nullptr},
1963+
#include "authentication_kerberos_clientopt-longopts.h"
19621964
{nullptr, 0, nullptr, nullptr, nullptr, nullptr, GET_NO_ARG, NO_ARG, 0, 0,
19631965
0, nullptr, 0, nullptr}};
19641966

@@ -2085,6 +2087,8 @@ bool get_one_option(int optid, const struct my_option *opt [[maybe_unused]],
20852087
break;
20862088
#include "sslopt-case.h"
20872089

2090+
#include "authentication_kerberos_clientopt-case.h"
2091+
20882092
case 'V':
20892093
usage(1);
20902094
exit(0);
@@ -4767,6 +4771,15 @@ static bool init_connection_options(MYSQL *mysql) {
47674771
return 1;
47684772
}
47694773
}
4774+
4775+
#if defined(_WIN32)
4776+
char error[256]{0};
4777+
if (set_authentication_kerberos_client_mode(mysql, error, 255)) {
4778+
put_info(error, INFO_ERROR);
4779+
return 1;
4780+
}
4781+
#endif
4782+
47704783
return false;
47714784
}
47724785

‎client/mysqldump.cc‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ static uint my_end_arg;
162162
static char *opt_mysql_unix_port = nullptr;
163163
static char *opt_bind_addr = nullptr;
164164
static int first_error = 0;
165+
#include "authentication_kerberos_clientopt-vars.h"
165166
#include "caching_sha2_passwordopt-vars.h"
166167
#include "multi_factor_passwordopt-vars.h"
167168
#include "sslopt-vars.h"
@@ -659,6 +660,7 @@ static struct my_option my_long_options[] = {
659660
"be dumped or not.",
660661
&opt_skip_gipk, &opt_skip_gipk, nullptr, GET_BOOL, NO_ARG, 0, 0, 0,
661662
nullptr, 0, nullptr},
663+
#include "authentication_kerberos_clientopt-longopts.h"
662664
{nullptr, 0, nullptr, nullptr, nullptr, nullptr, GET_NO_ARG, NO_ARG, 0, 0,
663665
0, nullptr, 0, nullptr}};
664666

@@ -895,6 +897,8 @@ static bool get_one_option(int optid, const struct my_option *opt,
895897
break;
896898
#include "sslopt-case.h"
897899

900+
#include "authentication_kerberos_clientopt-case.h"
901+
898902
case 'V':
899903
print_version();
900904
exit(0);
@@ -1593,6 +1597,14 @@ static int connect_to_db(char *host, char *user) {
15931597
set_get_server_public_key_option(&mysql_connection);
15941598
set_password_options(&mysql_connection);
15951599

1600+
#if defined(_WIN32)
1601+
char error[256]{0};
1602+
if (set_authentication_kerberos_client_mode(&mysql_connection, error, 255)) {
1603+
fprintf(stderr, "%s", error);
1604+
return 1;
1605+
}
1606+
#endif /* _WIN32 */
1607+
15961608
if (opt_compress_algorithm)
15971609
mysql_options(&mysql_connection, MYSQL_OPT_COMPRESSION_ALGORITHMS,
15981610
opt_compress_algorithm);

0 commit comments

Comments
 (0)