Entorno de compilacion reorganizado, bugs segfault solucionados
This commit is contained in:
parent
9b0723bf13
commit
e1d6fa5e0f
|
@ -0,0 +1,15 @@
|
|||
|
||||
mysql_LIBS = `mysql_config --libs`
|
||||
mysql_CFLAGS = `mysql_config --cflags`
|
||||
|
||||
vn_mysql_libdir = $(libdir)/mysql/plugin
|
||||
vn_mysql_CFLAGS = \
|
||||
-Wall -O3 \
|
||||
$(mysql_CFLAGS)
|
||||
vn_mysql_LDFLAGS = \
|
||||
-no-undefined \
|
||||
-module \
|
||||
-avoid-version \
|
||||
-export-dynamic \
|
||||
$(mysql_LIBS)
|
||||
|
|
@ -11,6 +11,7 @@ AM_SILENT_RULES([yes])
|
|||
|
||||
# Check for program dependencies
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
PKG_CHECK_MODULES([glib], [glib-2.0])
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
vn-mysql (1.2-deb8) unstable; urgency=low
|
||||
vn-mysql (1.4-deb8) unstable; urgency=low
|
||||
|
||||
* Initial Release.
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
I=0
|
||||
NATTEMPS=$1
|
||||
|
||||
while [ $I -lt $NATTEMPS ];
|
||||
while [ $I -lt $NATTEMPS ]
|
||||
do
|
||||
I=$((I+1))
|
||||
./command.sh
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
|
||||
CREATE SCHEMA account;
|
||||
|
||||
DROP TABLE IF EXISTS account.user;
|
||||
CREATE TABLE account.user
|
||||
SELECT 'proxy' mysql_user, 'test-user' user, '1234' password;
|
||||
-- SELECT mysql_user FROM user WHERE user = #user AND password = #pass
|
||||
|
||||
DROP USER ''@'%';
|
||||
CREATE USER ''@'%' IDENTIFIED WITH proxy_auth;
|
||||
GRANT USAGE ON *.* TO ''@'%';
|
||||
|
||||
DROP USER 'proxy'@'%';
|
||||
CREATE USER 'proxy'@'%' IDENTIFIED BY '123456';
|
||||
GRANT USAGE ON *.* TO 'proxy'@'%';
|
||||
GRANT PROXY ON 'proxy'@'%' TO ''@'%';
|
||||
|
||||
-- SELECT mysql_user FROM user WHERE user = #user AND password = #pass
|
||||
|
||||
|
|
|
@ -1,58 +1,43 @@
|
|||
|
||||
plugindir = $(libdir)/mysql/plugin
|
||||
include $(top_srcdir)/Makefile.decl
|
||||
|
||||
# minacum
|
||||
|
||||
minacum_LTLIBRARIES = minacum.la
|
||||
minacum_la_SOURCES = minacum.c
|
||||
minacum_la_LIBADD = -lmysqlclient -lz
|
||||
minacum_la_CFLAGS = -Wall -O3 -I/usr/include/mysql
|
||||
minacum_la_LDFLAGS = \
|
||||
-no-undefined \
|
||||
-module \
|
||||
-avoid-version \
|
||||
-export-dynamic \
|
||||
-lmysqlclient
|
||||
minacumdir = $(plugindir)
|
||||
minacum_la_LIBADD = $(vn_mysql_LIBS)
|
||||
minacum_la_CFLAGS = $(vn_mysql_CFLAGS)
|
||||
minacum_la_LDFLAGS = $(vn_mysql_LDFLAGS)
|
||||
minacumdir = $(vn_mysql_libdir)
|
||||
|
||||
# sql_printf
|
||||
|
||||
sql_printf_LTLIBRARIES = sql_printf.la
|
||||
sql_printf_la_SOURCES = sql_printf.c
|
||||
sql_printf_la_LIBADD = -lmysqlclient -lz
|
||||
sql_printf_la_CFLAGS = -Wall -O3 -I/usr/include/mysql
|
||||
sql_printf_la_LDFLAGS = \
|
||||
-no-undefined \
|
||||
-module \
|
||||
-avoid-version \
|
||||
-export-dynamic \
|
||||
-lmysqlclient
|
||||
sql_printfdir = $(plugindir)
|
||||
sql_printf_la_LIBADD = $(vn_mysql_LIBS)
|
||||
sql_printf_la_CFLAGS = $(vn_mysql_CFLAGS)
|
||||
sql_printf_la_LDFLAGS = $(vn_mysql_LDFLAGS)
|
||||
sql_printfdir = $(vn_mysql_libdir)
|
||||
|
||||
# multimax
|
||||
|
||||
multimax_LTLIBRARIES = multimax.la
|
||||
multimax_la_SOURCES = multimax.c
|
||||
multimax_la_LIBADD = -lmysqlclient -lz
|
||||
multimax_la_CFLAGS = -Wall -O3 -I/usr/include/mysql
|
||||
multimax_la_LDFLAGS = \
|
||||
-no-undefined \
|
||||
-module \
|
||||
-avoid-version \
|
||||
-export-dynamic \
|
||||
-lmysqlclient
|
||||
multimaxdir = $(plugindir)
|
||||
multimax_la_LIBADD = $(vn_mysql_LIBS)
|
||||
multimax_la_CFLAGS = $(vn_mysql_CFLAGS)
|
||||
multimax_la_LDFLAGS = $(vn_mysql_LDFLAGS)
|
||||
multimaxdir = $(vn_mysql_libdir)
|
||||
|
||||
# Clean
|
||||
|
||||
install-data-hook:
|
||||
rm -f $(DESTDIR)$(plugindir)/minacum.la
|
||||
rm -f $(DESTDIR)$(plugindir)/minacum.a
|
||||
rm -f $(DESTDIR)$(plugindir)/sql_printf.la
|
||||
rm -f $(DESTDIR)$(plugindir)/sql_printf.a
|
||||
rm -f $(DESTDIR)$(plugindir)/multimax.la
|
||||
rm -f $(DESTDIR)$(plugindir)/multimax.a
|
||||
rm -f $(DESTDIR)$(vn_mysql_libdir)/minacum.la
|
||||
rm -f $(DESTDIR)$(vn_mysql_libdir)/minacum.a
|
||||
rm -f $(DESTDIR)$(vn_mysql_libdir)/sql_printf.la
|
||||
rm -f $(DESTDIR)$(vn_mysql_libdir)/sql_printf.a
|
||||
rm -f $(DESTDIR)$(vn_mysql_libdir)/multimax.la
|
||||
rm -f $(DESTDIR)$(vn_mysql_libdir)/multimax.a
|
||||
|
||||
#$(FILE): $(SRC)
|
||||
# gcc -shared -o $@ $< -fPIC
|
||||
|
||||
|
||||
|
|
|
@ -1,32 +1,26 @@
|
|||
|
||||
proxy_authdir = $(libdir)/mysql/plugin
|
||||
proxy_auth_LTLIBRARIES = proxy_auth.la
|
||||
|
||||
proxy_auth_la_CPPFLAGS = \
|
||||
-DMYSQL_DYNAMIC_PLUGIN \
|
||||
$(glib_CFLAGS) \
|
||||
-D_CONFIG_DIR=\"$(proxy_auth_datadir)\" \
|
||||
-D_SQL_DIR=\"$(proxy_auth_datadir)\"
|
||||
proxy_auth_la_LIBADD = \
|
||||
$(glib_LIBS) \
|
||||
-lmysqlclient \
|
||||
-lz
|
||||
proxy_auth_la_CFLAGS = \
|
||||
-Wall -O3 \
|
||||
-I/usr/include/mysql
|
||||
proxy_auth_la_LDFLAGS = \
|
||||
-no-undefined \
|
||||
-module \
|
||||
-avoid-version \
|
||||
-export-dynamic \
|
||||
-lmysqlclient
|
||||
proxy_auth_la_SOURCES = proxy-auth.c
|
||||
include $(top_srcdir)/Makefile.decl
|
||||
|
||||
proxy_auth_datadir = $(sysconfdir)/mysql
|
||||
proxy_auth_data_DATA = \
|
||||
proxy-auth.sql \
|
||||
proxy-auth.ini
|
||||
|
||||
proxy_auth_LTLIBRARIES = proxy_auth.la
|
||||
proxy_auth_la_SOURCES = proxy-auth.c
|
||||
proxy_auth_la_LIBADD = \
|
||||
$(glib_LIBS) \
|
||||
$(vn_mysql_LIBS)
|
||||
proxy_auth_la_CFLAGS = $(vn_mysql_CFLAGS)
|
||||
proxy_auth_la_LDFLAGS = $(vn_mysql_LDFLAGS)
|
||||
proxy_auth_la_CPPFLAGS = \
|
||||
-DMYSQL_DYNAMIC_PLUGIN \
|
||||
-D_CONFIG_DIR=\"$(proxy_auth_datadir)\" \
|
||||
-D_SQL_DIR=\"$(proxy_auth_datadir)\" \
|
||||
$(glib_CFLAGS) \
|
||||
$(vn_mysql_CFLAGS)
|
||||
proxy_authdir = $(vn_mysql_libdir)
|
||||
|
||||
install-data-hook:
|
||||
rm -f $(DESTDIR)$(proxy_authdir)/proxy_auth.la
|
||||
rm -f $(DESTDIR)$(proxy_authdir)/proxy_auth.a
|
||||
rm -f $(DESTDIR)$(vn_mysql_libdir)/proxy_auth.la
|
||||
rm -f $(DESTDIR)$(vn_mysql_libdir)/proxy_auth.a
|
||||
|
|
|
@ -42,6 +42,7 @@ typedef struct
|
|||
GAsyncQueue * conn_pool;
|
||||
GMutex mutex;
|
||||
guint last_error;
|
||||
gboolean debug;
|
||||
}
|
||||
ProxyAuth;
|
||||
|
||||
|
@ -49,9 +50,9 @@ typedef struct
|
|||
{
|
||||
MYSQL * conn;
|
||||
gchar * user;
|
||||
guint user_len;
|
||||
gulong user_len;
|
||||
gchar * pass;
|
||||
guint pass_len;
|
||||
gulong pass_len;
|
||||
}
|
||||
RegexData;
|
||||
|
||||
|
@ -117,6 +118,7 @@ proxy_auth_init (ProxyAuth * self)
|
|||
self->regex = NULL;
|
||||
self->conn_pool = NULL;
|
||||
self->last_error = 0;
|
||||
self->debug = FALSE;
|
||||
|
||||
mysql_library_init (0, NULL, NULL);
|
||||
|
||||
|
@ -141,6 +143,7 @@ proxy_auth_init (ProxyAuth * self)
|
|||
self->schema = g_key_file_get_string (key_file, "db", "schema", NULL);
|
||||
self->port = (guint) g_key_file_get_integer (key_file, "db", "port", NULL);
|
||||
self->max_connections = g_key_file_get_integer (key_file, "db", "maxConnections", NULL);
|
||||
self->debug = g_key_file_get_boolean (key_file, "db", "debug", NULL);
|
||||
|
||||
// Reading the query template
|
||||
|
||||
|
@ -248,7 +251,7 @@ proxy_auth_authenticate (ProxyAuth * self, MYSQL_PLUGIN_VIO * vio, MYSQL_SERVER_
|
|||
|
||||
// Check for the username
|
||||
|
||||
guint user_len = info->user_name_length;
|
||||
int user_len = info->user_name_length;
|
||||
|
||||
if (info->user_name == NULL
|
||||
&& (user_len = vio->read_packet (vio, &pkt)) < 0)
|
||||
|
@ -259,7 +262,7 @@ proxy_auth_authenticate (ProxyAuth * self, MYSQL_PLUGIN_VIO * vio, MYSQL_SERVER_
|
|||
|
||||
// Read the password and check if it's valid
|
||||
|
||||
guint pass_len = vio->read_packet (vio, &pkt) - 1;
|
||||
int pass_len = vio->read_packet (vio, &pkt) - 1;
|
||||
|
||||
if (pass_len < 0)
|
||||
return CR_ERROR;
|
||||
|
@ -336,6 +339,9 @@ proxy_auth_authenticate (ProxyAuth * self, MYSQL_PLUGIN_VIO * vio, MYSQL_SERVER_
|
|||
}
|
||||
|
||||
// Sends the query to the database
|
||||
|
||||
if (self->debug)
|
||||
g_message ("ProxyAuth: Query: %s", query);
|
||||
|
||||
MYSQL_RES * result;
|
||||
|
||||
|
@ -350,6 +356,9 @@ proxy_auth_authenticate (ProxyAuth * self, MYSQL_PLUGIN_VIO * vio, MYSQL_SERVER_
|
|||
|
||||
if (row_len > 0 && row_len <= MYSQL_USERNAME_LENGTH)
|
||||
{
|
||||
if (self->debug)
|
||||
g_message ("ProxyAuth: Proxy user: %s", row[0]);
|
||||
|
||||
strcpy (info->external_user, info->user_name);
|
||||
strncpy (info->authenticated_as, row[0], row_len);
|
||||
res = CR_OK;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[db]
|
||||
user = authentication
|
||||
user = proxy-auth
|
||||
pass = password
|
||||
socket = /var/run/mysqld/mysqld.sock
|
||||
schema = account
|
||||
maxConnections = 4
|
||||
debug = false
|
||||
|
|
Reference in New Issue