~hrvojem/percona-pam-for-mysql/theme-makefile

« back to all changes in this revision

Viewing changes to src/auth_pam.c

  • Committer: Laurynas Biveinis
  • Date: 2011-10-28 12:56:02 UTC
  • mfrom: (5.4.3 bug880344)
  • Revision ID: laurynas.biveinis@percona.com-20111028125602-7i5bfrd6j0cz7w7k
Merge fix for bug 880344

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
/** The MySQL service name for PAM configuration */
81
81
static const char* service_name= "mysqld";
82
82
 
83
 
/** The maximum length of MYSQL_SERVER_AUTH_INFO::external_user field.
84
 
    Shouldn't be hardcoded in the plugin_auth.h but it is. */
85
 
enum { max_auth_info_external_user_len = 512 };
86
 
 
87
83
static int valid_pam_msg_style (int pam_msg_style)
88
84
{
89
85
  switch (pam_msg_style)
202
198
  pam_handle_t *pam_handle;
203
199
  struct pam_conv conv_func_info= { &vio_server_conv, vio };
204
200
  int error;
205
 
  char *external_user_name;
 
201
  char *pam_mapped_user_name;
206
202
 
207
203
  /* Impossible to tell if PAM will use passwords or something else */
208
204
  info->password_used= PASSWORD_USED_NO_MENTION;
249
245
  }
250
246
 
251
247
  /* Get the authenticated user name from PAM */
252
 
  error= pam_get_item(pam_handle, PAM_USER, (void *)&external_user_name);
 
248
  error= pam_get_item(pam_handle, PAM_USER, (void *)&pam_mapped_user_name);
253
249
  if (error != PAM_SUCCESS)
254
250
  {
255
251
    pam_end(pam_handle, error);
257
253
  }
258
254
 
259
255
  /* Check if user name from PAM is the same as provided for MySQL.  If
260
 
  different, set @@external_user for the current session to the one provided by
261
 
  PAM.  */
262
 
  if (strcmp(info->user_name, external_user_name))
 
256
  different, use the new user name for MySQL authorization and as
 
257
  CURRENT_USER() value.  */
 
258
  if (strcmp(info->user_name, pam_mapped_user_name))
263
259
  {
264
 
    strncpy(info->external_user, external_user_name,
265
 
            max_auth_info_external_user_len);
 
260
    strncpy(info->authenticated_as, pam_mapped_user_name,
 
261
            MYSQL_USERNAME_LENGTH);
 
262
    info->authenticated_as[MYSQL_USERNAME_LENGTH]= '\0';
266
263
  }
267
264
 
268
265
  error= pam_end(pam_handle, error);