~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/authentication.cc

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

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