Remove server authenticator options
Was unused. A warning is printed if the parameter is defined. Any value is ignored.
This commit is contained in:
@ -1265,9 +1265,8 @@ from the configuration.
|
||||
|
||||
#### `authenticator_options`
|
||||
|
||||
Option string given to the authenticator module. The value of this parameter
|
||||
should be a comma-separated list of key-value pairs. See authenticator specific
|
||||
documentation for more details.
|
||||
Removed feature. Only client authenticator modules have options, in the listener
|
||||
definition. Server authenticator options in the config file are ignored.
|
||||
|
||||
### Listener
|
||||
|
||||
|
@ -149,7 +149,6 @@ typedef struct server
|
||||
long master_id; /**< Master server id of this node */
|
||||
int depth; /**< Replication level in the tree */
|
||||
// Misc fields
|
||||
char *auth_options; /**< Authenticator options, not used. TODO: Remove. */
|
||||
bool master_err_is_logged; /**< If node failed, this indicates whether it is logged. Only used
|
||||
* by rwsplit. TODO: Move to rwsplit */
|
||||
bool warn_ssl_not_enabled; /**< SSL not used for an SSL enabled server */
|
||||
@ -265,12 +264,10 @@ enum
|
||||
* @param port The port to connect to
|
||||
* @param protocol The protocol to use to connect to the server
|
||||
* @param authenticator The server authenticator module
|
||||
* @param auth_options Options for the authenticator module
|
||||
* @return The newly created server or NULL if an error occurred
|
||||
*/
|
||||
extern SERVER* server_alloc(const char *name, const char *address, unsigned short port,
|
||||
const char *protocol, const char *authenticator,
|
||||
const char *auth_options);
|
||||
const char *protocol, const char *authenticator);
|
||||
|
||||
/**
|
||||
* @brief Find a server that can be reused
|
||||
@ -280,7 +277,6 @@ extern SERVER* server_alloc(const char *name, const char *address, unsigned shor
|
||||
* @param name Name of the server
|
||||
* @param protocol Protocol used by the server
|
||||
* @param authenticator The authenticator module of the server
|
||||
* @param auth_options Options for the authenticator
|
||||
* @param address The network address of the new server
|
||||
* @param port The port of the new server
|
||||
*
|
||||
@ -288,8 +284,7 @@ extern SERVER* server_alloc(const char *name, const char *address, unsigned shor
|
||||
* found
|
||||
* @see runtime_create_server
|
||||
*/
|
||||
SERVER* server_repurpose_destroyed(const char *name, const char *protocol,
|
||||
const char *authenticator, const char *auth_options,
|
||||
SERVER* server_repurpose_destroyed(const char *name, const char *protocol, const char *authenticator,
|
||||
const char *address, const char *port);
|
||||
/**
|
||||
* @brief Serialize a server to a file
|
||||
|
@ -299,7 +299,6 @@ const char *server_params[] =
|
||||
CN_PORT,
|
||||
CN_ADDRESS,
|
||||
CN_AUTHENTICATOR,
|
||||
CN_AUTHENTICATOR_OPTIONS,
|
||||
CN_MONITORUSER,
|
||||
CN_MONITORPW,
|
||||
CN_PERSISTPOOLMAX,
|
||||
@ -338,6 +337,12 @@ const char *config_pre_parse_global_params[] =
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *deprecated_server_params[] =
|
||||
{
|
||||
CN_AUTHENTICATOR_OPTIONS,
|
||||
NULL
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize the context object used for tracking duplicate sections.
|
||||
*
|
||||
@ -3243,6 +3248,15 @@ bool is_normal_server_parameter(const char *param)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Check if parameter is deprecated
|
||||
for (int i = 0; deprecated_server_params[i]; i++)
|
||||
{
|
||||
if (strcmp(param, deprecated_server_params[i]) == 0)
|
||||
{
|
||||
MXS_WARNING("Server parameter '%s' is deprecated and will be ignored.", param);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3260,11 +3274,10 @@ int create_new_server(CONFIG_CONTEXT *obj)
|
||||
char *monuser = config_get_value(obj->parameters, CN_MONITORUSER);
|
||||
char *monpw = config_get_value(obj->parameters, CN_MONITORPW);
|
||||
char *auth = config_get_value(obj->parameters, CN_AUTHENTICATOR);
|
||||
char *auth_opts = config_get_value(obj->parameters, CN_AUTHENTICATOR_OPTIONS);
|
||||
|
||||
if (address && port && protocol)
|
||||
{
|
||||
if ((obj->element = server_alloc(obj->object, address, atoi(port), protocol, auth, auth_opts)) == NULL)
|
||||
if ((obj->element = server_alloc(obj->object, address, atoi(port), protocol, auth)) == NULL)
|
||||
{
|
||||
MXS_ERROR("Failed to create a new server, memory allocation failed.");
|
||||
error_count++;
|
||||
|
@ -137,8 +137,7 @@ bool runtime_unlink_server(SERVER *server, const char *target)
|
||||
}
|
||||
|
||||
bool runtime_create_server(const char *name, const char *address, const char *port,
|
||||
const char *protocol, const char *authenticator,
|
||||
const char *authenticator_options)
|
||||
const char *protocol, const char *authenticator)
|
||||
{
|
||||
spinlock_acquire(&crt_lock);
|
||||
bool rval = false;
|
||||
@ -163,9 +162,7 @@ bool runtime_create_server(const char *name, const char *address, const char *po
|
||||
}
|
||||
|
||||
/** First check if this service has been created before */
|
||||
SERVER *server = server_repurpose_destroyed(name, protocol, authenticator,
|
||||
authenticator_options,
|
||||
address, port);
|
||||
SERVER *server = server_repurpose_destroyed(name, protocol, authenticator, address, port);
|
||||
|
||||
if (server)
|
||||
{
|
||||
@ -174,8 +171,7 @@ bool runtime_create_server(const char *name, const char *address, const char *po
|
||||
else
|
||||
{
|
||||
MXS_DEBUG("Creating server '%s'", name);
|
||||
server = server_alloc(name, address, atoi(port), protocol,
|
||||
authenticator, authenticator_options);
|
||||
server = server_alloc(name, address, atoi(port), protocol, authenticator);
|
||||
}
|
||||
|
||||
if (server && server_serialize(server))
|
||||
@ -1316,14 +1312,13 @@ SERVER* runtime_create_server_from_json(json_t* json)
|
||||
/** Optional parameters */
|
||||
const char* protocol = get_string_or_null(json, MXS_JSON_PTR_PARAM_PROTOCOL);
|
||||
const char* authenticator = get_string_or_null(json, MXS_JSON_PTR_PARAM_AUTHENTICATOR);
|
||||
const char* authenticator_options = get_string_or_null(json, MXS_JSON_PTR_PARAM_AUTHENTICATOR_OPTIONS);
|
||||
|
||||
StringSet relations;
|
||||
|
||||
if (extract_relations(json, relations, MXS_JSON_PTR_RELATIONSHIPS_SERVICES, server_relation_is_valid) &&
|
||||
extract_relations(json, relations, MXS_JSON_PTR_RELATIONSHIPS_MONITORS, server_relation_is_valid))
|
||||
{
|
||||
if (runtime_create_server(name, address, port.c_str(), protocol, authenticator, authenticator_options))
|
||||
if (runtime_create_server(name, address, port.c_str(), protocol, authenticator))
|
||||
{
|
||||
rval = server_find_by_unique_name(name);
|
||||
ss_dassert(rval);
|
||||
|
@ -38,12 +38,11 @@ MXS_BEGIN_DECLS
|
||||
* @param port Network port
|
||||
* @param protocol Protocol module name
|
||||
* @param authenticator Authenticator module name
|
||||
* @param options Options for the authenticator module
|
||||
* @return True on success, false if an error occurred
|
||||
*/
|
||||
bool runtime_create_server(const char *name, const char *address,
|
||||
const char *port, const char *protocol,
|
||||
const char *authenticator, const char *options);
|
||||
const char *authenticator);
|
||||
|
||||
/**
|
||||
* @brief Destroy a server
|
||||
|
@ -69,7 +69,7 @@ static void server_parameter_free(SERVER_PARAM *tofree);
|
||||
|
||||
|
||||
SERVER* server_alloc(const char *name, const char *address, unsigned short port,
|
||||
const char *protocol, const char *authenticator, const char *auth_options)
|
||||
const char *protocol, const char *authenticator)
|
||||
{
|
||||
if (authenticator == NULL && (authenticator = get_default_authenticator(protocol)) == NULL)
|
||||
{
|
||||
@ -79,21 +79,14 @@ SERVER* server_alloc(const char *name, const char *address, unsigned short port,
|
||||
}
|
||||
|
||||
void *auth_instance = NULL;
|
||||
|
||||
if (!authenticator_init(&auth_instance, authenticator, auth_options))
|
||||
// Backend authenticators do not have options.
|
||||
if (!authenticator_init(&auth_instance, authenticator, NULL))
|
||||
{
|
||||
MXS_ERROR("Failed to initialize authenticator module '%s' for server '%s' ",
|
||||
authenticator, name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *my_auth_options = NULL;
|
||||
|
||||
if (auth_options && (my_auth_options = MXS_STRDUP(auth_options)) == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int nthr = config_threadcount();
|
||||
SERVER *server = (SERVER *)MXS_CALLOC(1, sizeof(SERVER));
|
||||
char *my_name = MXS_STRDUP(name);
|
||||
@ -125,7 +118,6 @@ SERVER* server_alloc(const char *name, const char *address, unsigned short port,
|
||||
server->protocol = my_protocol;
|
||||
server->authenticator = my_authenticator;
|
||||
server->auth_instance = auth_instance;
|
||||
server->auth_options = my_auth_options;
|
||||
server->port = port;
|
||||
server->status = SERVER_RUNNING;
|
||||
server->status_pending = SERVER_RUNNING;
|
||||
@ -1198,11 +1190,6 @@ static bool create_server_config(const SERVER *server, const char *filename)
|
||||
dprintf(file, "%s=%u\n", CN_PORT, server->port);
|
||||
dprintf(file, "%s=%s\n", CN_AUTHENTICATOR, server->authenticator);
|
||||
|
||||
if (server->auth_options)
|
||||
{
|
||||
dprintf(file, "%s=%s\n", CN_AUTHENTICATOR_OPTIONS, server->auth_options);
|
||||
}
|
||||
|
||||
if (*server->monpw && *server->monuser)
|
||||
{
|
||||
dprintf(file, "%s=%s\n", CN_MONITORUSER, server->monuser);
|
||||
@ -1277,8 +1264,7 @@ bool server_serialize(const SERVER *server)
|
||||
return rval;
|
||||
}
|
||||
|
||||
SERVER* server_repurpose_destroyed(const char *name, const char *protocol,
|
||||
const char *authenticator, const char *auth_options,
|
||||
SERVER* server_repurpose_destroyed(const char *name, const char *protocol, const char *authenticator,
|
||||
const char *address, const char *port)
|
||||
{
|
||||
spinlock_acquire(&server_spin);
|
||||
@ -1290,15 +1276,10 @@ SERVER* server_repurpose_destroyed(const char *name, const char *protocol,
|
||||
strcmp(server->protocol, protocol) == 0 &&
|
||||
strcmp(server->authenticator, authenticator) == 0)
|
||||
{
|
||||
if ((auth_options == NULL && server->auth_options == NULL) ||
|
||||
(auth_options && server->auth_options &&
|
||||
strcmp(server->auth_options, auth_options) == 0))
|
||||
{
|
||||
snprintf(server->address, sizeof(server->address), "%s", address);
|
||||
server->port = atoi(port);
|
||||
server->is_active = true;
|
||||
break;
|
||||
}
|
||||
snprintf(server->address, sizeof(server->address), "%s", address);
|
||||
server->port = atoi(port);
|
||||
server->is_active = true;
|
||||
break;
|
||||
}
|
||||
server = server->next;
|
||||
}
|
||||
@ -1401,11 +1382,6 @@ static json_t* server_json_attributes(const SERVER* server)
|
||||
json_object_set_new(params, CN_AUTHENTICATOR, json_string(server->authenticator));
|
||||
}
|
||||
|
||||
if (server->auth_options)
|
||||
{
|
||||
json_object_set_new(params, CN_AUTHENTICATOR_OPTIONS, json_string(server->auth_options));
|
||||
}
|
||||
|
||||
if (*server->monuser)
|
||||
{
|
||||
json_object_set_new(params, CN_MONITORUSER, json_string(server->monuser));
|
||||
|
@ -56,7 +56,7 @@ test1()
|
||||
/* Server tests */
|
||||
ss_dfprintf(stderr, "testserver : creating server called MyServer");
|
||||
set_libdir(MXS_STRDUP_A("../../modules/authenticator/NullAuthAllow/"));
|
||||
server = server_alloc("uniquename", "127.0.0.1", 9876, "HTTPD", "NullAuthAllow", NULL);
|
||||
server = server_alloc("uniquename", "127.0.0.1", 9876, "HTTPD", "NullAuthAllow");
|
||||
ss_info_dassert(server, "Allocating the server should not fail");
|
||||
mxs_log_flush_sync();
|
||||
|
||||
@ -129,8 +129,6 @@ bool test_load_config(const char *input, SERVER *server)
|
||||
TEST(strcmp(server->protocol, config_get_param(param, "protocol")->value) == 0, "Server protocols differ");
|
||||
TEST(strcmp(server->authenticator, config_get_param(param, "authenticator")->value) == 0,
|
||||
"Server authenticators differ");
|
||||
TEST(strcmp(server->auth_options, config_get_param(param, "authenticator_options")->value) == 0,
|
||||
"Server authenticator options differ");
|
||||
TEST(server->port == atoi(config_get_param(param, "port")->value), "Server ports differ");
|
||||
TEST(create_new_server(obj) == 0, "Failed to create server from loaded config");
|
||||
}
|
||||
@ -146,7 +144,7 @@ bool test_serialize()
|
||||
char old_config_name[] = "serialized-server.cnf.old";
|
||||
char *persist_dir = MXS_STRDUP_A("./");
|
||||
set_config_persistdir(persist_dir);
|
||||
SERVER *server = server_alloc(name, "127.0.0.1", 9876, "HTTPD", "NullAuthAllow", "fake=option");
|
||||
SERVER *server = server_alloc(name, "127.0.0.1", 9876, "HTTPD", "NullAuthAllow");
|
||||
TEST(server, "Server allocation failed");
|
||||
|
||||
/** Make sure the files don't exist */
|
||||
|
@ -797,8 +797,7 @@ createInstance(SERVICE *service, char **options)
|
||||
server = server_alloc("binlog_router_master_host",
|
||||
"_none_", 3306,
|
||||
"MySQLBackend",
|
||||
"MySQLBackendAuth",
|
||||
NULL);
|
||||
"MySQLBackendAuth");
|
||||
if (server == NULL)
|
||||
{
|
||||
MXS_ERROR("%s: Error for server_alloc in createInstance",
|
||||
|
@ -122,7 +122,7 @@ int main(int argc, char **argv)
|
||||
s = strtok_r(NULL, ",", &lasts);
|
||||
}
|
||||
server = server_alloc("binlog_router_master_host", "_none_", 3306,
|
||||
"MySQLBackend", "MySQLBackendAuth", NULL);
|
||||
"MySQLBackend", "MySQLBackendAuth");
|
||||
if (server == NULL)
|
||||
{
|
||||
printf("Failed to allocate 'server' object\n");
|
||||
|
@ -1140,16 +1140,15 @@ static SPINLOCK server_mod_lock = SPINLOCK_INIT;
|
||||
* @param port Server port
|
||||
* @param protocol Protocol, NULL for default (MySQLBackend)
|
||||
* @param authenticator Authenticator module, NULL for default (MySQLBackendAuth)
|
||||
* @param authenticator_options Authenticator options, NULL for no options
|
||||
*/
|
||||
static void createServer(DCB *dcb, char *name, char *address, char *port,
|
||||
char *protocol, char *authenticator, char *authenticator_options)
|
||||
char *protocol, char *authenticator)
|
||||
{
|
||||
spinlock_acquire(&server_mod_lock);
|
||||
|
||||
if (server_find_by_unique_name(name) == NULL)
|
||||
{
|
||||
if (runtime_create_server(name, address, port, protocol, authenticator, authenticator_options))
|
||||
if (runtime_create_server(name, address, port, protocol, authenticator))
|
||||
{
|
||||
dcb_printf(dcb, "Created server '%s'\n", name);
|
||||
}
|
||||
@ -1202,9 +1201,9 @@ static void createMonitor(DCB *dcb, const char *name, const char *module)
|
||||
struct subcommand createoptions[] =
|
||||
{
|
||||
{
|
||||
"server", 2, 6, (FN)createServer,
|
||||
"server", 2, 5, (FN)createServer,
|
||||
"Create a new server",
|
||||
"Usage: create server NAME HOST [PORT] [PROTOCOL] [AUTHENTICATOR] [OPTIONS]\n"
|
||||
"Usage: create server NAME HOST [PORT] [PROTOCOL] [AUTHENTICATOR]\n"
|
||||
"\n"
|
||||
"Parameters:\n"
|
||||
"NAME Server name\n"
|
||||
@ -1212,14 +1211,13 @@ struct subcommand createoptions[] =
|
||||
"PORT Server port (default 3306)\n"
|
||||
"PROTOCOL Server protocol (default MySQLBackend)\n"
|
||||
"AUTHENTICATOR Authenticator module name (default MySQLAuth)\n"
|
||||
"OPTIONS Comma separated list of options for the authenticator\n"
|
||||
"\n"
|
||||
"The first two parameters are required, the others are optional.\n"
|
||||
"\n"
|
||||
"Example: create server my-db-1 192.168.0.102 3306",
|
||||
{
|
||||
ARG_TYPE_OBJECT_NAME, ARG_TYPE_OBJECT_NAME, ARG_TYPE_OBJECT_NAME, ARG_TYPE_OBJECT_NAME,
|
||||
ARG_TYPE_OBJECT_NAME, ARG_TYPE_OBJECT_NAME
|
||||
ARG_TYPE_OBJECT_NAME
|
||||
}
|
||||
},
|
||||
{
|
||||
|
Reference in New Issue
Block a user