diff options
author | Sergei Golubchik <serg@mariadb.org> | 2019-01-12 21:36:26 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2019-02-04 15:54:10 +0100 |
commit | 3742f6f9aadc363fb83e3775066c33ba420fe97b (patch) | |
tree | ec872e4ef5b0dc686568298cecec4c245c098575 /plugin | |
parent | 3ab445819e622fb5e09baf2153db26d10f2c8a29 (diff) | |
download | mariadb-git-3742f6f9aadc363fb83e3775066c33ba420fe97b.tar.gz |
cleanup: use only one callback in PAM plugin, not two
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/auth_pam/auth_pam_base.c | 9 | ||||
-rw-r--r-- | plugin/auth_pam/auth_pam_tool.c | 14 | ||||
-rw-r--r-- | plugin/auth_pam/auth_pam_v1.c | 11 |
3 files changed, 10 insertions, 24 deletions
diff --git a/plugin/auth_pam/auth_pam_base.c b/plugin/auth_pam/auth_pam_base.c index 68be0e92b71..67a0adbeb2e 100644 --- a/plugin/auth_pam/auth_pam_base.c +++ b/plugin/auth_pam/auth_pam_base.c @@ -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; PAM_DEBUG((stderr, "PAM: conv: send(%.*s)\n", (int)(param->ptr - param->buf - 1), param->buf)); - if (write_packet(param, param->buf, param->ptr - param->buf - 1)) - return PAM_CONV_ERR; - - pkt_len = read_packet(param, &pkt); + pkt_len= roundtrip(param, param->buf, param->ptr - param->buf - 1, &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)); /* allocate and copy the reply to the response array */ if (!((*resp)[i].resp= strndup((char*) pkt, pkt_len))) diff --git a/plugin/auth_pam/auth_pam_tool.c b/plugin/auth_pam/auth_pam_tool.c index 3f7015952a0..95d47dca113 100644 --- a/plugin/auth_pam/auth_pam_tool.c +++ b/plugin/auth_pam/auth_pam_tool.c @@ -26,22 +26,16 @@ struct param { #include "auth_pam_tool.h" -static int write_packet(struct param *param __attribute__((unused)), - const unsigned char *buf, int buf_len) +static int roundtrip(struct param *param, const unsigned char *buf, + int buf_len, unsigned char **pkt) { unsigned char b= AP_CONV; - return write(1, &b, 1) < 1 || - write_string(1, buf, buf_len); -} - - -static int read_packet(struct param *param, unsigned char **pkt) -{ + if (write(1, &b, 1) < 1 || write_string(1, buf, buf_len)) + return -1; *pkt= (unsigned char *) param->buf; return read_string(0, (char *) param->buf, (int) sizeof(param->buf)) - 1; } - typedef struct st_mysql_server_auth_info { /** diff --git a/plugin/auth_pam/auth_pam_v1.c b/plugin/auth_pam/auth_pam_v1.c index ab352b1492b..95110a5e310 100644 --- a/plugin/auth_pam/auth_pam_v1.c +++ b/plugin/auth_pam/auth_pam_v1.c @@ -21,14 +21,11 @@ struct param { MYSQL_PLUGIN_VIO *vio; }; -static int write_packet(struct param *param, const unsigned char *buf, - int buf_len) -{ - return param->vio->write_packet(param->vio, buf, buf_len); -} - -static int read_packet(struct param *param, unsigned char **pkt) +static int roundtrip(struct param *param, const unsigned char *buf, + int buf_len, unsigned char **pkt) { + if (param->vio->write_packet(param->vio, buf, buf_len)) + return -1; return param->vio->read_packet(param->vio, pkt); } |