00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <config.h>
00021 #include <drizzled/item.h>
00022 #include <drizzled/plugin.h>
00023 #include <drizzled/module/option_map.h>
00024 #include <boost/program_options.hpp>
00025 #include "auth_schema.h"
00026
00027 namespace po= boost::program_options;
00028
00029 using namespace std;
00030
00031 namespace drizzle_plugin {
00032 namespace auth_schema {
00033
00037 static AuthSchema *auth_schema= NULL;
00038
00039 static bool update_table(Session*, set_var* var)
00040 {
00041 if (not var->value->str_value.empty())
00042 return auth_schema->setTable(var->value->str_value.data());
00043 errmsg_printf(error::ERROR, _("auth_schema table cannot be NULL"));
00044 return true;
00045 }
00046
00047 static void init_options(module::option_context &context)
00048 {
00049 auth_schema= new AuthSchema(true);
00050
00051 context("table",
00052 po::value<string>(&auth_schema->sysvar_table)->default_value("auth.users"),
00053 N_("Database-qualified auth table name"));
00054 }
00055
00056 static int init(module::Context &context)
00057 {
00058 const module::option_map &vm= context.getOptions();
00059
00060 if (not vm["table"].as<string>().empty())
00061 auth_schema->setTable(vm["table"].as<string>());
00062
00063 context.add(auth_schema);
00064 context.registerVariable(new sys_var_bool_ptr("enabled", &auth_schema->sysvar_enabled));
00065 context.registerVariable(new sys_var_std_string("table", auth_schema->sysvar_table, NULL, &update_table));
00066
00067 return 0;
00068 }
00069
00070 }
00071 }
00072
00073 DRIZZLE_PLUGIN(
00074 drizzle_plugin::auth_schema::init,
00075 NULL,
00076 drizzle_plugin::auth_schema::init_options
00077 );