99
94
virtual bool authenticate(void)
101
96
printDebug("authenticate");
102
identifier::User::shared_ptr user= identifier::User::make_shared();
103
user->setUser(username);
104
session->setUser(user);
105
return session->checkUser(password, db);
97
session->getSecurityContext().setUser(username);
98
return session->checkUser(password, strlen(password), db);
108
101
virtual bool readCommand(char **packet, uint32_t *packet_length)
276
269
class ListenConsole: public plugin::Listen
279
const std::string username;
280
const std::string password;
281
const std::string db;
284
ListenConsole(const std::string &name_arg,
285
const std::string &username_arg,
286
const std::string &password_arg,
287
const std::string &db_arg) :
288
plugin::Listen(name_arg),
289
username(username_arg),
290
password(password_arg),
274
ListenConsole(const std::string &name_arg) :
275
plugin::Listen(name_arg)
327
316
assert(read(fd, buffer, 1) == 1);
328
return new ClientConsole(username, password, db);
317
return new ClientConsole;
332
321
static int init(drizzled::module::Context &context)
334
323
const module::option_map &vm= context.getOptions();
335
const string username(vm.count("username") ? vm["username"].as<string>() : "");
336
const string password(vm.count("password") ? vm["password"].as<string>() : "");
337
const string db(vm.count("db") ? vm["db"].as<string>() : "");
338
context.registerVariable(new sys_var_bool_ptr("enable", &enabled));
339
context.registerVariable(new sys_var_bool_ptr("debug_enable", &debug_enabled));
340
context.registerVariable(new sys_var_const_string_val("username", username));
341
context.registerVariable(new sys_var_const_string_val("password", password));
342
context.registerVariable(new sys_var_const_string_val("db", db));
343
context.add(new ListenConsole("console", username, password, db));
324
/* duplicating these here means they need to be freed. They're global, so
325
we'll just have the ListenConsole object do it in its destructor */
326
if (vm.count("username"))
327
username= strdup(vm["username"].as<string>().c_str());
329
username= strdup("");
331
if (vm.count("password"))
332
password= strdup(vm["password"].as<string>().c_str());
334
password= strdup("");
337
db= strdup(vm["db"].as<string>().c_str());
341
context.add(new ListenConsole("console"));
345
static DRIZZLE_SYSVAR_BOOL(enable, enabled, PLUGIN_VAR_NOCMDARG,
346
N_("Enable the console."), NULL, NULL, false);
347
static DRIZZLE_SYSVAR_BOOL(debug, debug_enabled, PLUGIN_VAR_NOCMDARG,
348
N_("Turn on extra debugging."), NULL, NULL, false);
350
static DRIZZLE_SYSVAR_STR(username, username, PLUGIN_VAR_READONLY,
351
N_("User to use for auth."), NULL, NULL, NULL);
352
static DRIZZLE_SYSVAR_STR(password, password, PLUGIN_VAR_READONLY,
353
N_("Password to use for auth."), NULL, NULL, NULL);
354
static DRIZZLE_SYSVAR_STR(db, db, PLUGIN_VAR_READONLY,
355
N_("Default database to use."), NULL, NULL, NULL);
347
357
static void init_options(drizzled::module::option_context &context)
349
359
context("enable",