Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions mysql-test/suite/plugins/r/pam.result
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ select user(), current_user(), database();
user() current_user() database()
test_pam@localhost pam_test@% test
#
# MDEV-40141 PAM authentication fails when started with --default-auth=dialog
#
[mariadb] Now, the magic number!
PIN: user() current_user()
test_pam@localhost pam_test@%
#
# athentication is unsuccessful
#
Challenge input first.
Expand Down
6 changes: 6 additions & 0 deletions mysql-test/suite/plugins/r/pam_v1.result
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ select user(), current_user(), database();
user() current_user() database()
test_pam@localhost pam_test@% test
#
# MDEV-40141 PAM authentication fails when started with --default-auth=dialog
#
[mariadb] Now, the magic number!
PIN: user() current_user()
test_pam@localhost pam_test@%
#
# athentication is unsuccessful
#
Challenge input first.
Expand Down
8 changes: 8 additions & 0 deletions mysql-test/suite/plugins/t/pam.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
let $PAM_PLUGIN_VERSION= $AUTH_PAM_SO;
if (!$DIALOG_SO) {
skip No dialog client plugin;
}
--source pam_init.inc

--write_file $MYSQLTEST_VARDIR/tmp/pam_good.txt
Expand Down Expand Up @@ -30,6 +33,11 @@ EOF
--echo #
--exec $MYSQL_TEST -u test_pam < $MYSQLTEST_VARDIR/tmp/pam_good.txt

--echo #
--echo # MDEV-40141 PAM authentication fails when started with --default-auth=dialog
--echo #
--exec echo 106 | $MYSQL --default-auth=dialog -u test_pam -psecret -e "select user(), current_user()" test

--echo #
--echo # athentication is unsuccessful
--echo #
Expand Down
8 changes: 8 additions & 0 deletions mysql-test/suite/plugins/t/pam_v1.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
let $PAM_PLUGIN_VERSION= $AUTH_PAM_V1_SO;
if (!$DIALOG_SO) {
skip No dialog client plugin;
}
--source pam_init.inc

--write_file $MYSQLTEST_VARDIR/tmp/pam_good.txt
Expand All @@ -24,6 +27,11 @@ EOF
--echo #
--exec $MYSQL_TEST -u test_pam < $MYSQLTEST_VARDIR/tmp/pam_good.txt

--echo #
--echo # MDEV-40141 PAM authentication fails when started with --default-auth=dialog
--echo #
--exec echo 106 | $MYSQL --default-auth=dialog -u test_pam -psecret -e "select user(), current_user()" test

--echo #
--echo # athentication is unsuccessful
--echo #
Expand Down
2 changes: 1 addition & 1 deletion plugin/auth_pam/auth_pam.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static int pam_auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info)
if ((buf_len= read_string(c_to_p[0], (char *) buf, sizeof(buf))) < 0)
goto error_ret;

if (!pkt || !*pkt || (buf[0] >> 1) != 2)
if (!pkt || pkt_len <= 0 || !*pkt || (buf[0] >> 1) != 2)
{
PAM_DEBUG((stderr, "PAM: sending CONV string.\n"));
if (vio->write_packet(vio, buf, buf_len))
Expand Down
2 changes: 1 addition & 1 deletion plugin/auth_pam/auth_pam_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct param {
static int roundtrip(struct param *param, const unsigned char *buf,
int buf_len, unsigned char **pkt)
{
if (param->cached && *param->cached && (buf[0] >> 1) == 2)
if (param->cached && param->cached_len > 0 && *param->cached && (buf[0] >> 1) == 2)
{
*pkt= param->cached;
param->cached= NULL;
Expand Down