Skip to content

Commit 85325bc

Browse files
committed
Added clear_text plugin for pam authentication. To use the clear text plugin
pam-use-cleartext-plugin setting must be enabled in MariaDB server.
1 parent cd16280 commit 85325bc

File tree

4 files changed

+85
-3
lines changed

4 files changed

+85
-3
lines changed

plugins/auth/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,20 @@ INSTALL(TARGETS
1111
RUNTIME DESTINATION "${PLUGIN_INSTALL_DIR}"
1212
LIBRARY DESTINATION "${PLUGIN_INSTALL_DIR}"
1313
ARCHIVE DESTINATION "${PLUGIN_INSTALL_DIR}")
14+
15+
# Cleartext
16+
# Dialog plugin
17+
SET(CTEXT_SOURCES mariadb_cleartext.c)
18+
IF(WIN32)
19+
SET(CTEXT ${CTEXT_SOURCES} ${CMAKE_SOURCE_DIR}/plugins/plugin.def)
20+
ENDIF()
21+
ADD_LIBRARY(mysql_clear_password SHARED ${CTEXT_SOURCES})
22+
SET_TARGET_PROPERTIES(mysql_clear_password PROPERTIES PREFIX "")
23+
24+
INSTALL(TARGETS
25+
mysql_clear_password
26+
RUNTIME DESTINATION "${PLUGIN_INSTALL_DIR}"
27+
LIBRARY DESTINATION "${PLUGIN_INSTALL_DIR}"
28+
ARCHIVE DESTINATION "${PLUGIN_INSTALL_DIR}")
29+
30+
# Cleartext

plugins/auth/dialog.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
License along with this library; if not see <http://www.gnu.org/licenses>
1616
or write to the Free Software Foundation, Inc.,
1717
51 Franklin St., Fifth Floor, Boston, MA 02110, USA
18-
19-
Part of this code includes code from the PHP project which
20-
is freely available from http://www.php.net
2118
*************************************************************************************/
2219
#ifndef _WIN32
2320
#define _GNU_SOURCE 1

plugins/auth/mariadb_cleartext.c

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/************************************************************************************
2+
Copyright (C) 2014 MariaDB Corporation AB
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Library General Public
6+
License as published by the Free Software Foundation; either
7+
version 2 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
Library General Public License for more details.
13+
14+
You should have received a copy of the GNU Library General Public
15+
License along with this library; if not see <http://www.gnu.org/licenses>
16+
or write to the Free Software Foundation, Inc.,
17+
51 Franklin St., Fifth Floor, Boston, MA 02110, USA
18+
*************************************************************************************/
19+
#include <my_global.h>
20+
#include <mysql.h>
21+
#include <mysql/client_plugin.h>
22+
#include <string.h>
23+
24+
/* clear text plugin submits the password without opening a dialog.
25+
This will be the case if pam-use-cleartext-plugin option is
26+
enabled on server side */
27+
28+
/* {{{ auth_send_plain_password() */
29+
/*
30+
sends an unencrypted password to server
31+
32+
SYNOPSIS
33+
auth_send_plain_password()
34+
vio pointer to vio structure
35+
mysql connection handle
36+
37+
DESCRIPTION
38+
sends an unencrypted password (which was specified either in
39+
mysql_real_connect or mysql_change_user) to server.
40+
41+
RETURN
42+
CR_OK
43+
CR_ERROR if an error occured
44+
*/
45+
static int clear_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql)
46+
{
47+
if (!vio || !mysql || !mysql->passwd)
48+
return CR_ERROR;
49+
50+
return vio->write_packet(vio, (const unsigned char *) mysql->passwd, strlen(mysql->passwd)) ?
51+
CR_ERROR : CR_OK;
52+
}
53+
/* }}} */
54+
55+
mysql_declare_client_plugin(AUTHENTICATION)
56+
"mysql_clear_password",
57+
"Georg Richter",
58+
"MariaDB clear password authentication plugin",
59+
{0,1,0},
60+
NULL,
61+
NULL,
62+
clear_password_auth_client
63+
mysql_end_client_plugin;
64+
65+

win/packaging/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ IF (WITH_SIGNCODE)
4040
COMMAND signtool sign ${SIGN_OPTIONS} ${CLIENT_DBG_DIR}/mariadbclient.lib)
4141
EXECUTE_PROCESS(
4242
COMMAND signtool sign ${SIGN_OPTIONS} ${CMAKE_BINARY_DIR}/plugins/auth/${CMAKE_BUILD_TYPE}/dialog.dll)
43+
EXECUTE_PROCESS(
44+
COMMAND signtool sign ${SIGN_OPTIONS} ${CMAKE_BINARY_DIR}/plugins/auth/${CMAKE_BUILD_TYPE}/mysql_clear_password.dll)
4345
ENDIF()
4446

4547
SET(MARIADB_PLUGINS "${MARIADB_PLUGINS} <File Id=\"dialog.dll\" Name=\"dialog.dll\" DiskId=\"1\" Source=\"${CMAKE_BINARY_DIR}/plugins/auth/${CMAKE_BUILD_TYPE}/dialog.dll\"/>\n")
48+
SET(MARIADB_PLUGINS "${MARIADB_PLUGINS} <File Id=\"mysql-clear-password.dll\" Name=\"mysql-clear-password.dll\" DiskId=\"1\" Source=\"${CMAKE_BINARY_DIR}/plugins/auth/${CMAKE_BUILD_TYPE}/mysql-clear-password.dll\"/>\n")
4649

4750

4851
FOREACH(src ${MARIADB_CLIENT_INCLUDES})

0 commit comments

Comments
 (0)