Commit 5fa48d6c authored by Nikita Malyavin's avatar Nikita Malyavin

allow plugins to set flags

parent ad17a89e
......@@ -98,6 +98,9 @@ typedef struct st_mysql_xid MYSQL_XID;
#define MYSQL_AUTHENTICATION_PLUGIN 7
#define MYSQL_MAX_PLUGIN_TYPE_NUM 12 /**< The number of plugin types */
#define MYSQL_PLUGIN_TYPE_MASK ((1<<16)-1)
#define MYSQL_AUTH_CAN_BE_DEFAULT (1<<16)
/* MariaDB plugin types */
/** Client and server password validation */
#define MariaDB_PASSWORD_VALIDATION_PLUGIN 8
......@@ -565,7 +568,22 @@ struct st_mysql_plugin
struct st_maria_plugin
{
#ifdef __cplusplus
struct alignas(sizeof(int)) auth_type_t
{
int raw_version;
auth_type_t() = default;
auth_type_t(int version): raw_version(version){}
operator int() const
{ return raw_version & MYSQL_PLUGIN_TYPE_MASK; }
int flags() const
{ return raw_version & ~MYSQL_PLUGIN_TYPE_MASK; }
};
auth_type_t type; /**< the plugin type (a MYSQL_XXX_PLUGIN value) */
#else
int type; /**< the plugin type (a MYSQL_XXX_PLUGIN value) */
#endif
void *info; /**< pointer to type-specific plugin descriptor */
const char *name; /**< plugin name */
const char *author; /**< plugin author (for SHOW PLUGINS) */
......
......@@ -569,7 +569,17 @@ struct st_mysql_plugin
};
struct st_maria_plugin
{
int type;
struct alignas(sizeof(int)) auth_type_t
{
int raw_version;
auth_type_t() = default;
auth_type_t(int version): raw_version(version){}
operator int() const
{ return raw_version & ((1<<16)-1); }
int flags() const
{ return raw_version & ~((1<<16)-1); }
};
auth_type_t type;
void *info;
const char *name;
const char *author;
......
......@@ -569,7 +569,17 @@ struct st_mysql_plugin
};
struct st_maria_plugin
{
int type;
struct alignas(sizeof(int)) auth_type_t
{
int raw_version;
auth_type_t() = default;
auth_type_t(int version): raw_version(version){}
operator int() const
{ return raw_version & ((1<<16)-1); }
int flags() const
{ return raw_version & ~((1<<16)-1); }
};
auth_type_t type;
void *info;
const char *name;
const char *author;
......
......@@ -569,7 +569,17 @@ struct st_mysql_plugin
};
struct st_maria_plugin
{
int type;
struct alignas(sizeof(int)) auth_type_t
{
int raw_version;
auth_type_t() = default;
auth_type_t(int version): raw_version(version){}
operator int() const
{ return raw_version & ((1<<16)-1); }
int flags() const
{ return raw_version & ~((1<<16)-1); }
};
auth_type_t type;
void *info;
const char *name;
const char *author;
......
......@@ -569,7 +569,17 @@ struct st_mysql_plugin
};
struct st_maria_plugin
{
int type;
struct alignas(sizeof(int)) auth_type_t
{
int raw_version;
auth_type_t() = default;
auth_type_t(int version): raw_version(version){}
operator int() const
{ return raw_version & ((1<<16)-1); }
int flags() const
{ return raw_version & ~((1<<16)-1); }
};
auth_type_t type;
void *info;
const char *name;
const char *author;
......
......@@ -569,7 +569,17 @@ struct st_mysql_plugin
};
struct st_maria_plugin
{
int type;
struct alignas(sizeof(int)) auth_type_t
{
int raw_version;
auth_type_t() = default;
auth_type_t(int version): raw_version(version){}
operator int() const
{ return raw_version & ((1<<16)-1); }
int flags() const
{ return raw_version & ~((1<<16)-1); }
};
auth_type_t type;
void *info;
const char *name;
const char *author;
......
......@@ -569,7 +569,17 @@ struct st_mysql_plugin
};
struct st_maria_plugin
{
int type;
struct alignas(sizeof(int)) auth_type_t
{
int raw_version;
auth_type_t() = default;
auth_type_t(int version): raw_version(version){}
operator int() const
{ return raw_version & ((1<<16)-1); }
int flags() const
{ return raw_version & ~((1<<16)-1); }
};
auth_type_t type;
void *info;
const char *name;
const char *author;
......
......@@ -569,7 +569,17 @@ struct st_mysql_plugin
};
struct st_maria_plugin
{
int type;
struct alignas(sizeof(int)) auth_type_t
{
int raw_version;
auth_type_t() = default;
auth_type_t(int version): raw_version(version){}
operator int() const
{ return raw_version & ((1<<16)-1); }
int flags() const
{ return raw_version & ~((1<<16)-1); }
};
auth_type_t type;
void *info;
const char *name;
const char *author;
......
......@@ -294,7 +294,7 @@ static struct st_mysql_auth info =
maria_declare_plugin(auth_parsec)
{
MYSQL_AUTHENTICATION_PLUGIN,
MYSQL_AUTHENTICATION_PLUGIN|MYSQL_AUTH_CAN_BE_DEFAULT,
&info,
"parsec",
"Nikita Maliavin",
......
......@@ -2549,6 +2549,15 @@ bool acl_init(bool dont_read_acl_tables)
if (!native_password_plugin || !old_password_plugin || !default_auth_plugin)
DBUG_RETURN(1);
st_plugin_int *default_auth_int= plugin_ref_to_int(default_auth_plugin);
if (!(default_auth_int->plugin->type.flags() & MYSQL_AUTH_CAN_BE_DEFAULT))
{
sql_print_error("Error: plugin %s cannot be set as default.",
default_auth_int->name.str);
DBUG_RETURN(1);
}
if (dont_read_acl_tables)
{
DBUG_RETURN(0); /* purecov: tested */
......@@ -15362,7 +15371,8 @@ static struct st_mysql_auth old_password_handler=
maria_declare_plugin(mysql_password)
{
MYSQL_AUTHENTICATION_PLUGIN, /* type constant */
MYSQL_AUTHENTICATION_PLUGIN | MYSQL_AUTH_CAN_BE_DEFAULT,
/* type constant */
&native_password_handler, /* type descriptor */
native_password_plugin_name.str, /* Name */
"R.J.Silk, Sergei Golubchik", /* Author */
......@@ -15377,7 +15387,8 @@ maria_declare_plugin(mysql_password)
MariaDB_PLUGIN_MATURITY_STABLE /* Maturity */
},
{
MYSQL_AUTHENTICATION_PLUGIN, /* type constant */
MYSQL_AUTHENTICATION_PLUGIN | MYSQL_AUTH_CAN_BE_DEFAULT,
/* type constant */
&old_password_handler, /* type descriptor */
old_password_plugin_name.str, /* Name */
"R.J.Silk, Sergei Golubchik", /* Author */
......
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