~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/auth_pam/auth_pam.cc

Added code necessary for building plugins dynamically.
Merged in changes from lifeless to allow autoreconf to work.
Touching plugin.ini files now triggers a rebuid - so config/autorun.sh is no
longer required to be run after touching those.
Removed the duplicate plugin names - also removed the issue that getting them
different would silently fail weirdly later.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
  @TODO: License?
23
23
*/
24
24
 
25
 
#include "config.h"
26
 
 
 
25
#include <drizzled/server_includes.h>
 
26
#include <drizzled/session.h>
 
27
#include <drizzled/plugin/authentication.h>
27
28
#include <security/pam_appl.h>
28
29
#if !defined(__sun) && !defined(__FreeBSD__)
29
30
#include <security/pam_misc.h>
30
31
#endif
31
32
 
32
 
#include "drizzled/security_context.h"
33
 
#include "drizzled/plugin/authentication.h"
34
 
 
35
 
using namespace drizzled;
36
 
 
37
33
typedef struct {
38
34
    const char *name;
39
35
    const char *password;
106
102
public:
107
103
  Auth_pam(std::string name_arg)
108
104
    : drizzled::plugin::Authentication(name_arg) {}
109
 
  virtual bool authenticate(const SecurityContext &sctx,
110
 
                            const std::string &password)
 
105
  virtual bool authenticate(Session *session, const char *password)
111
106
  {
112
107
    int retval;
113
108
    auth_pam_userinfo userinfo= { NULL, NULL };
114
109
    struct pam_conv conv_info= { &auth_pam_talker, (void*)&userinfo };
115
110
    pam_handle_t *pamh= NULL;
116
111
 
117
 
    userinfo.name= sctx.getUser().c_str();
118
 
    userinfo.password= password.c_str();
 
112
    userinfo.name= session->security_ctx.user.c_str();
 
113
    userinfo.password= password;
119
114
 
120
115
    retval= pam_start("check_user", userinfo.name, &conv_info, &pamh);
121
116
 
134
129
 
135
130
static Auth_pam *auth= NULL;
136
131
 
137
 
static int initialize(drizzled::plugin::Context &context)
 
132
static int initialize(drizzled::plugin::Registry &registry)
138
133
{
139
134
  auth= new Auth_pam("auth_pam");
140
 
  context.add(auth);
141
 
  return 0;
142
 
}
143
 
 
144
 
DRIZZLE_DECLARE_PLUGIN
145
 
{
146
 
  DRIZZLE_VERSION_ID,
 
135
  registry.add(auth);
 
136
  return 0;
 
137
}
 
138
 
 
139
static int finalize(drizzled::plugin::Registry &registry)
 
140
{
 
141
 
 
142
  if (auth)
 
143
  {
 
144
    registry.remove(auth);
 
145
    delete auth;
 
146
  }
 
147
 
 
148
  return 0;
 
149
}
 
150
 
 
151
drizzle_declare_plugin
 
152
{
147
153
  "pam",
148
154
  "0.1",
149
155
  "Brian Aker",
150
156
  "PAM based authenication.",
151
157
  PLUGIN_LICENSE_GPL,
152
158
  initialize, /* Plugin Init */
 
159
  finalize, /* Plugin Deinit */
 
160
  NULL,   /* status variables */
153
161
  NULL,   /* system variables */
154
162
  NULL    /* config options */
155
163
}
156
 
DRIZZLE_DECLARE_PLUGIN_END;
 
164
drizzle_declare_plugin_end;