~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/authentication.cc

  • Committer: Brian Aker
  • Date: 2009-03-27 22:55:28 UTC
  • mto: This revision was merged to the branch mainline in revision 968.
  • Revision ID: brian@tangent.org-20090327225528-8y76cfx8a4oemqv9
Remove ref_count

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include <drizzled/server_includes.h>
22
22
#include <drizzled/authentication.h>
23
 
#include <libdrizzle/gettext.h>
 
23
#include <drizzled/gettext.h>
 
24
#include <drizzled/errmsg_print.h>
24
25
 
25
26
static bool are_plugins_loaded= false;
26
27
 
27
 
static bool authenticate_by(THD *thd, plugin_ref plugin, void* p_data)
 
28
static bool authenticate_by(Session *session, plugin_ref plugin, void* p_data)
28
29
{
29
30
  const char *password= (const char *)p_data;
30
 
  authentication_st *auth= plugin_data(plugin, authentication_st *);
 
31
  Authentication *auth= plugin_data(plugin, Authentication *);
31
32
 
32
33
  (void)p_data;
33
34
 
34
 
  if (auth && auth->authenticate)
 
35
  if (auth)
35
36
  {
36
 
    if (auth->authenticate(thd, password))
 
37
    if (auth->authenticate(session, password))
37
38
      return true;
38
39
  }
39
40
 
40
41
  return false;
41
42
}
42
43
 
43
 
bool authenticate_user(THD *thd, const char *password)
 
44
bool authenticate_user(Session *session, const char *password)
44
45
{
45
46
  /* If we never loaded any auth plugins, just return true */
46
47
  if (are_plugins_loaded != true)
47
48
    return true;
48
49
 
49
 
  return plugin_foreach(thd, authenticate_by, DRIZZLE_AUTH_PLUGIN, (void *)password);
 
50
  return plugin_foreach(session, authenticate_by, DRIZZLE_AUTH_PLUGIN, (void *)password);
50
51
}
51
52
 
52
53
 
53
54
int authentication_initializer(st_plugin_int *plugin)
54
55
{
55
 
  authentication_st *authen;
56
 
 
57
 
  if ((authen= (authentication_st *)malloc(sizeof(authentication_st))) == 0)
58
 
      return(1);
59
 
 
60
 
  memset(authen, 0, sizeof(authentication_st));
 
56
  Authentication *authen;
 
57
 
61
58
 
62
59
  if (plugin->plugin->init)
63
60
  {
64
 
    if (plugin->plugin->init(authen))
 
61
    if (plugin->plugin->init(&authen))
65
62
    {
66
 
      sql_print_error(_("Plugin '%s' init function returned error."),
67
 
                      plugin->name.str);
 
63
      errmsg_printf(ERRMSG_LVL_ERROR,
 
64
                    _("Plugin '%s' init function returned error."),
 
65
                    plugin->name.str);
68
66
      goto err;
69
67
    }
70
68
  }
71
69
 
72
 
  plugin->data= (void *)authen;
 
70
  if (authen == NULL)
 
71
    return 1;
 
72
 
 
73
  plugin->data= static_cast<void *>(authen);
73
74
  are_plugins_loaded= true;
74
75
 
75
76
  return(0);
76
77
err:
77
 
  free(authen);
 
78
  delete authen;
78
79
  return(1);
79
80
}
80
81
 
81
82
int authentication_finalizer(st_plugin_int *plugin)
82
83
{
83
 
  authentication_st *authen= (authentication_st *)plugin->data;
 
84
  Authentication *authen= static_cast<Authentication *>(plugin->data);
84
85
 
85
86
  assert(authen);
86
87
  if (authen && plugin->plugin->deinit)
87
88
    plugin->plugin->deinit(authen);
88
89
 
89
 
  free(authen);
90
 
 
91
90
  return(0);
92
91
}