1/* Copyright (C) 2013 Sergei Golubchik and Monty Program Ab
2
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public License as
5 published by the Free Software Foundation; version 2 of the
6 License.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16
17/**
18 @file
19
20 auth plugin that uses old structures as of
21 MYSQL_AUTHENTICATION_INTERFACE_VERSION 0x0100
22
23 To test the old version support.
24 It intentionally uses no constants like CR_OK ok PASSWORD_USED_YES.
25*/
26
27#include <mysql/plugin.h>
28#include <string.h>
29#include <stdio.h>
30#include <stdlib.h>
31
32#if 0
33#include <mysql/plugin_auth.h>
34#else
35#define MYSQL_AUTHENTICATION_INTERFACE_VERSION 0x0100
36typedef void MYSQL_PLUGIN_VIO; /* we don't use it here */
37
38typedef struct st_mysql_server_auth_info
39{
40 char *user_name;
41 unsigned int user_name_length;
42 const char *auth_string;
43 unsigned long auth_string_length;
44 char authenticated_as[49];
45 char external_user[512];
46 int password_used;
47 const char *host_or_ip;
48 unsigned int host_or_ip_length;
49} MYSQL_SERVER_AUTH_INFO;
50
51struct st_mysql_auth
52{
53 int interface_version;
54 const char *client_auth_plugin;
55 int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info);
56};
57#endif
58
59static int do_auth_0x0100(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info)
60{
61 info->password_used= 1;
62 strcpy(info->authenticated_as, "zzzzzzzzzzzzzzzz");
63 memset(info->external_user, 'o', 510);
64 info->external_user[510]='.';
65 info->external_user[511]=0;
66 return vio ? -1 : 0; /* use vio to avoid the 'unused' warning */
67}
68
69static struct st_mysql_auth auth_0x0100_struct=
70{
71 MYSQL_AUTHENTICATION_INTERFACE_VERSION, 0, do_auth_0x0100
72};
73
74maria_declare_plugin(auth_0x0100)
75{
76 MYSQL_AUTHENTICATION_PLUGIN,
77 &auth_0x0100_struct,
78 "auth_0x0100",
79 "Sergei Golubchik",
80 "Test for API 0x0100 support",
81 PLUGIN_LICENSE_GPL,
82 NULL,
83 NULL,
84 0x0100,
85 NULL,
86 NULL,
87 "1.0",
88 MariaDB_PLUGIN_MATURITY_EXPERIMENTAL,
89}
90maria_declare_plugin_end;
91
92