mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
cleanup: use only one callback in PAM plugin, not two
This commit is contained in:
parent
3ab445819e
commit
3742f6f9aa
3 changed files with 10 additions and 24 deletions
|
@ -109,15 +109,10 @@ static int conv(int n, const struct pam_message **msg,
|
||||||
param->buf[0] = msg[i]->msg_style == PAM_PROMPT_ECHO_ON ? 2 : 4;
|
param->buf[0] = msg[i]->msg_style == PAM_PROMPT_ECHO_ON ? 2 : 4;
|
||||||
PAM_DEBUG((stderr, "PAM: conv: send(%.*s)\n",
|
PAM_DEBUG((stderr, "PAM: conv: send(%.*s)\n",
|
||||||
(int)(param->ptr - param->buf - 1), param->buf));
|
(int)(param->ptr - param->buf - 1), param->buf));
|
||||||
if (write_packet(param, param->buf, param->ptr - param->buf - 1))
|
pkt_len= roundtrip(param, param->buf, param->ptr - param->buf - 1, &pkt);
|
||||||
|
if (pkt_len < 0)
|
||||||
return PAM_CONV_ERR;
|
return PAM_CONV_ERR;
|
||||||
|
|
||||||
pkt_len = read_packet(param, &pkt);
|
|
||||||
if (pkt_len < 0)
|
|
||||||
{
|
|
||||||
PAM_DEBUG((stderr, "PAM: conv: recv() ERROR\n"));
|
|
||||||
return PAM_CONV_ERR;
|
|
||||||
}
|
|
||||||
PAM_DEBUG((stderr, "PAM: conv: recv(%.*s)\n", pkt_len, pkt));
|
PAM_DEBUG((stderr, "PAM: conv: recv(%.*s)\n", pkt_len, pkt));
|
||||||
/* allocate and copy the reply to the response array */
|
/* allocate and copy the reply to the response array */
|
||||||
if (!((*resp)[i].resp= strndup((char*) pkt, pkt_len)))
|
if (!((*resp)[i].resp= strndup((char*) pkt, pkt_len)))
|
||||||
|
|
|
@ -26,22 +26,16 @@ struct param {
|
||||||
#include "auth_pam_tool.h"
|
#include "auth_pam_tool.h"
|
||||||
|
|
||||||
|
|
||||||
static int write_packet(struct param *param __attribute__((unused)),
|
static int roundtrip(struct param *param, const unsigned char *buf,
|
||||||
const unsigned char *buf, int buf_len)
|
int buf_len, unsigned char **pkt)
|
||||||
{
|
{
|
||||||
unsigned char b= AP_CONV;
|
unsigned char b= AP_CONV;
|
||||||
return write(1, &b, 1) < 1 ||
|
if (write(1, &b, 1) < 1 || write_string(1, buf, buf_len))
|
||||||
write_string(1, buf, buf_len);
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int read_packet(struct param *param, unsigned char **pkt)
|
|
||||||
{
|
|
||||||
*pkt= (unsigned char *) param->buf;
|
*pkt= (unsigned char *) param->buf;
|
||||||
return read_string(0, (char *) param->buf, (int) sizeof(param->buf)) - 1;
|
return read_string(0, (char *) param->buf, (int) sizeof(param->buf)) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef struct st_mysql_server_auth_info
|
typedef struct st_mysql_server_auth_info
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,14 +21,11 @@ struct param {
|
||||||
MYSQL_PLUGIN_VIO *vio;
|
MYSQL_PLUGIN_VIO *vio;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int write_packet(struct param *param, const unsigned char *buf,
|
static int roundtrip(struct param *param, const unsigned char *buf,
|
||||||
int buf_len)
|
int buf_len, unsigned char **pkt)
|
||||||
{
|
|
||||||
return param->vio->write_packet(param->vio, buf, buf_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int read_packet(struct param *param, unsigned char **pkt)
|
|
||||||
{
|
{
|
||||||
|
if (param->vio->write_packet(param->vio, buf, buf_len))
|
||||||
|
return -1;
|
||||||
return param->vio->read_packet(param->vio, pkt);
|
return param->vio->read_packet(param->vio, pkt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue