1 | /************************************************************************************ |
2 | Copyright (C) 2014-2018 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 <ma_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 occurred |
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 | /* write password including terminating zero character */ |
51 | return vio->write_packet(vio, (const unsigned char *) mysql->passwd, (int)strlen(mysql->passwd) + 1) ? |
52 | CR_ERROR : CR_OK; |
53 | } |
54 | /* }}} */ |
55 | |
56 | #ifndef PLUGIN_DYNAMIC |
57 | struct st_mysql_client_plugin_AUTHENTICATION mysql_clear_password_client_plugin= |
58 | #else |
59 | struct st_mysql_client_plugin_AUTHENTICATION _mysql_client_plugin_declaration_ = |
60 | #endif |
61 | { |
62 | MYSQL_CLIENT_AUTHENTICATION_PLUGIN, |
63 | MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION, |
64 | "mysql_clear_password" , |
65 | "Georg Richter" , |
66 | "MariaDB clear password authentication plugin" , |
67 | {0,1,0}, |
68 | "LGPL" , |
69 | NULL, |
70 | NULL, |
71 | NULL, |
72 | NULL, |
73 | clear_password_auth_client |
74 | }; |
75 | |
76 | |
77 | |