27 #include <drizzled/identifier.h>
28 #include <drizzled/plugin/authentication.h>
30 #include <security/pam_appl.h>
31 #if !defined(__sun) && !defined(__FreeBSD__)
32 #include <security/pam_misc.h>
35 using namespace drizzled;
43 int auth_pam_talker(
int num_msg,
45 struct pam_message **msg,
47 const struct pam_message **msg,
49 struct pam_response **resp,
52 int auth_pam_talker(
int num_msg,
54 struct pam_message **msg,
56 const struct pam_message **msg,
58 struct pam_response **resp,
62 struct pam_response *response = 0;
65 if(not resp || not msg || not userinfo)
69 response= (
struct pam_response*)malloc(num_msg *
sizeof(
struct pam_response));
72 for(
int x= 0; x < num_msg; x++)
75 response[x].resp_retcode= 0;
79 switch(msg[x]->msg_style)
81 case PAM_PROMPT_ECHO_ON:
83 response[x].resp = strdup(userinfo->name);
85 case PAM_PROMPT_ECHO_OFF:
86 response[x].resp = strdup(userinfo->password);
106 const std::string &password)
110 struct pam_conv conv_info= { &auth_pam_talker, (
void*)&userinfo };
111 pam_handle_t *pamh= NULL;
113 userinfo.name= sctx.username().c_str();
114 userinfo.password= password.c_str();
116 retval= pam_start(
"drizzle", userinfo.name, &conv_info, &pamh);
118 if (retval == PAM_SUCCESS)
119 retval= pam_authenticate(pamh, PAM_DISALLOW_NULL_AUTHTOK);
121 if (retval == PAM_SUCCESS)
122 retval= pam_acct_mgmt(pamh, PAM_DISALLOW_NULL_AUTHTOK);
124 pam_end(pamh, retval);
126 return (retval == PAM_SUCCESS) ?
true:
false;
140 DRIZZLE_DECLARE_PLUGIN
146 N_(
"Authenication against system user accounts using PAM"),
152 DRIZZLE_DECLARE_PLUGIN_END;
A set of Session members describing the current authenticated user.