~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/auth_file/auth_file.cc

  • Committer: Andrew Hutchings
  • Date: 2010-12-15 18:59:55 UTC
  • mto: This revision was merged to the branch mainline in revision 2006.
  • Revision ID: andrew@linuxjedi.co.uk-20101215185955-q12lkja8hdnpjqg7
Make the test look for drizzleadmin failure instead of success as this test is not possible to fix for success on our FreeBSD 8.0 box

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
#include "drizzled/configmake.h"
31
31
#include "drizzled/plugin/authentication.h"
32
 
#include "drizzled/identifier.h"
 
32
#include "drizzled/security_context.h"
33
33
#include "drizzled/util/convert.h"
34
34
#include "drizzled/algorithm/sha1.h"
35
35
#include "drizzled/module/option_map.h"
71
71
  /**
72
72
   * Base class method to check authentication for a user.
73
73
   */
74
 
  bool authenticate(const identifier::User &sctx, const string &password);
 
74
  bool authenticate(const SecurityContext &sctx, const string &password);
75
75
 
76
76
  /**
77
77
   * Verify the local and remote scrambled password match using the MySQL
202
202
  return memcmp(local_scrambled_password, scrambled_password_check, SHA1_DIGEST_LENGTH) == 0;
203
203
}
204
204
 
205
 
bool AuthFile::authenticate(const identifier::User &sctx, const string &password)
 
205
bool AuthFile::authenticate(const SecurityContext &sctx, const string &password)
206
206
{
207
 
  std::map<std::string, std::string>::const_iterator user= users.find(sctx.username());
 
207
  std::map<std::string, std::string>::const_iterator user= users.find(sctx.getUser());
208
208
  if (user == users.end())
209
209
    return false;
210
210
 
211
 
  if (sctx.getPasswordType() == identifier::User::MYSQL_HASH)
 
211
  if (sctx.getPasswordType() == SecurityContext::MYSQL_HASH)
212
212
    return verifyMySQLHash(user->second, sctx.getPasswordContext(), password);
213
213
 
214
214
  if (password == user->second)
222
222
  const module::option_map &vm= context.getOptions();
223
223
 
224
224
  AuthFile *auth_file = new AuthFile("auth_file", fs::path(vm["users"].as<string>()));
225
 
  if (not auth_file->loadFile())
 
225
  if (!auth_file->loadFile())
226
226
  {
227
 
    errmsg_printf(error::ERROR, _("Could not load auth file: %s\n"),
 
227
    errmsg_printf(ERRMSG_LVL_ERROR, _("Could not load auth file: %s\n"),
228
228
                  auth_file->getError().c_str());
229
229
    delete auth_file;
230
230
    return 1;
232
232
 
233
233
  context.add(auth_file);
234
234
  context.registerVariable(new sys_var_const_string_val("users", vm["users"].as<string>()));
235
 
 
236
235
  return 0;
237
236
}
238
237