Ahora las funciones se compilan usando automake y se incluyen en el paquete debian
This commit is contained in:
parent
66c8a0eed3
commit
2b839cc637
|
@ -0,0 +1,7 @@
|
|||
.anjuta/
|
||||
.anjuta_sym_db.db
|
||||
aclocal.m4
|
||||
build/
|
||||
configure
|
||||
debian/build/
|
||||
vn-mysql.anjuta
|
|
@ -17,5 +17,6 @@ AC_CONFIG_FILES([
|
|||
Makefile
|
||||
src/Makefile
|
||||
src/proxy-auth/Makefile
|
||||
src/functions/Makefile
|
||||
])
|
||||
AC_OUTPUT
|
||||
|
|
|
@ -2,7 +2,7 @@ Source: vn-mysql
|
|||
Section: misc
|
||||
Priority: extra
|
||||
Maintainer: Alejandro T. Colombini Gómez <atcolombini@verdnatura.es>
|
||||
Build-Depends: debhelper (>= 8.0.0), autotools-dev, libglib2.0-dev, libmysqld-dev
|
||||
Build-Depends: build-essential, dh-autoreconf, devscripts, libglib2.0-dev, libmysqld-dev
|
||||
Standards-Version: 3.9.4
|
||||
Homepage: http://www.verdnatura.es
|
||||
|
||||
|
|
|
@ -6,5 +6,5 @@ chmod u=rw,go-rwx /etc/mysql/proxy-auth.sql
|
|||
chown mysql:mysql /etc/mysql/proxy-auth.ini
|
||||
chmod u=rw,go-rwx /etc/mysql/proxy-auth.ini
|
||||
|
||||
service mysql restart
|
||||
#service mysql restart
|
||||
exit 0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#! /bin/sh
|
||||
|
||||
service mysql restart
|
||||
#service mysql restart
|
||||
exit 0
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
mysql --enable-cleartext-plugin -u test-user --password=1234 < query.sql
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
I=0
|
||||
NATTEMPS=$1
|
||||
|
||||
while [ $I -lt $NATTEMPS ];
|
||||
do
|
||||
I=$((I+1))
|
||||
./command.sh
|
||||
done
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
CONCURRENCY=400
|
||||
NATTEMPS=40
|
||||
|
||||
I=0
|
||||
|
||||
while [ $I -lt $CONCURRENCY ];
|
||||
do
|
||||
I=$((I+1))
|
||||
./connect.sh $NATTEMPS &
|
||||
done
|
|
@ -0,0 +1 @@
|
|||
SELECT USER() user, CURRENT_USER() proxy
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
CREATE SCHEMA account;
|
||||
|
||||
CREATE TABLE account.user
|
||||
SELECT 'proxy' mysql_user, 'test-user' user, '1234' password;
|
||||
-- SELECT mysql_user FROM user WHERE user = #user AND password = #pass
|
||||
|
||||
CREATE USER ''@'%' IDENTIFIED WITH proxy_auth;
|
||||
GRANT USAGE ON *.* TO ''@'%';
|
||||
|
||||
CREATE USER 'proxy'@'%' IDENTIFIED BY '123456';
|
||||
GRANT USAGE ON *.* TO 'proxy'@'%';
|
||||
GRANT PROXY ON 'proxy'@'%' TO ''@'%';
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
INSTALL PLUGIN proxy_auth SONAME 'proxy_auth.so';
|
||||
|
||||
CREATE AGGREGATE FUNCTION minacum RETURNS INT SONAME 'minacum.so';
|
||||
CREATE AGGREGATE FUNCTION multimax RETURNS INT SONAME 'multimax.so';
|
||||
CREATE FUNCTION sql_printf RETURNS STRING SONAME 'sql_printf.so';
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
UNINSTALL PLUGIN proxy_auth;
|
||||
|
||||
DROP FUNCTION IF EXISTS minacum;
|
||||
DROP FUNCTION IF EXISTS multimax;
|
||||
DROP FUNCTION IF EXISTS sql_printf;
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
SUBDIRS = \
|
||||
proxy-auth
|
||||
proxy-auth \
|
||||
functions
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
|
||||
plugindir = $(libdir)/mysql/plugin
|
||||
|
||||
# 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)
|
||||
|
||||
# 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)
|
||||
|
||||
# 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)
|
||||
|
||||
# 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
|
||||
|
|
@ -41,7 +41,7 @@ void minacum_add (UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error)
|
|||
}
|
||||
if (ival == NULL || ival->num > num) {
|
||||
Interval* new;
|
||||
if (new = (Interval*) malloc (sizeof (Interval))) {
|
||||
if ((new = (Interval*) malloc (sizeof (Interval)))) {
|
||||
new->num = num;
|
||||
new->sum = amount;
|
||||
new->next = ival;
|
|
@ -1,14 +0,0 @@
|
|||
FILE=minacum.so
|
||||
SRC=minacum.c
|
||||
#URL=/usr/lib/$(FILE)
|
||||
URL=/usr/lib/mysql/plugin/$(FILE)
|
||||
|
||||
main: $(SRC)
|
||||
rm -f $(FILE)
|
||||
gcc -shared -o $(FILE) $(SRC) -fPIC
|
||||
install:
|
||||
cp $(FILE) $(URL)
|
||||
uninstall:
|
||||
rm -f $(URL)
|
||||
clean:
|
||||
rm -f $(FILE)
|
|
@ -1,25 +0,0 @@
|
|||
NAME=multimax
|
||||
FILE=$(NAME).so
|
||||
SRC=$(NAME).c
|
||||
URL=/usr/lib/mysql/plugin/$(FILE)
|
||||
|
||||
SQL_DROP="DROP FUNCTION IF EXISTS $(NAME);"
|
||||
|
||||
.PHONY: install uninstall clean
|
||||
|
||||
$(FILE): $(SRC)
|
||||
rm -f $@
|
||||
gcc -shared -o $@ $< -fPIC
|
||||
|
||||
install:
|
||||
cp $(FILE) $(URL)
|
||||
echo $(SQL_DROP)
|
||||
echo "CREATE AGGREGATE FUNCTION $(NAME) RETURNS INT SONAME '$(FILE)';"
|
||||
|
||||
uninstall:
|
||||
rm -f $(URL)
|
||||
echo $(SQL_DROP)
|
||||
|
||||
clean:
|
||||
rm -f $(FILE)
|
||||
|
|
@ -22,8 +22,8 @@
|
|||
#include <mysql/plugin_auth.h>
|
||||
#include <glib-unix.h>
|
||||
|
||||
#define CONFIG_FILE _CONFIG_DIR"/proxy_auth.ini"
|
||||
#define SQL_FILE _SQL_DIR"/proxy_auth.sql"
|
||||
#define CONFIG_FILE _CONFIG_DIR"/proxy-auth.ini"
|
||||
#define SQL_FILE _SQL_DIR"/proxy-auth.sql"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -79,13 +79,19 @@ proxy_auth_deinit (ProxyAuth * self)
|
|||
|
||||
if (self->regex)
|
||||
g_regex_unref (self->regex);
|
||||
if (self->conn_pool)
|
||||
g_async_queue_unref (self->conn_pool);
|
||||
|
||||
// FIXME: Connection can't be closed because mysql_close() causes MySQL
|
||||
// process crash with signal 11 when the process is shutdown.
|
||||
// MySQL version 5.5.40
|
||||
//if (self->conn_pool)
|
||||
// g_async_queue_unref (self->conn_pool);
|
||||
}
|
||||
|
||||
void
|
||||
proxy_auth_free (ProxyAuth * self)
|
||||
{
|
||||
g_return_if_fail (self != NULL);
|
||||
|
||||
proxy_auth_deinit (self);
|
||||
g_mutex_clear (&self->mutex);
|
||||
g_free (self);
|
||||
|
@ -94,6 +100,8 @@ proxy_auth_free (ProxyAuth * self)
|
|||
gboolean
|
||||
proxy_auth_init (ProxyAuth * self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, FALSE);
|
||||
|
||||
gboolean res = FALSE;
|
||||
GError * error = NULL;
|
||||
|
||||
|
@ -191,13 +199,16 @@ proxy_auth_regex_func (const GMatchInfo * info, GString * res, gpointer data)
|
|||
|
||||
if (str)
|
||||
{
|
||||
unsigned long scaped_len;
|
||||
char escaped_str[str_len * 2 + 1];
|
||||
|
||||
g_string_append_c (res, '\'');
|
||||
|
||||
// FIXME: mysql_real_escape_string() causes MySQL process crash with signal 11
|
||||
char escaped_str[str_len * 2 + 1];
|
||||
unsigned long scaped_len = mysql_escape_string (escaped_str, str, str_len);
|
||||
//scaped_len = mysql_real_escape_string (regex_data->conn, escaped_str, str, str_len);
|
||||
scaped_len = mysql_escape_string (escaped_str, str, str_len);
|
||||
|
||||
g_string_append_len (res, escaped_str, (gssize) scaped_len);
|
||||
|
||||
g_string_append_c (res, '\'');
|
||||
}
|
||||
else
|
||||
|
@ -210,6 +221,8 @@ proxy_auth_regex_func (const GMatchInfo * info, GString * res, gpointer data)
|
|||
static gboolean
|
||||
proxy_auth_reconnect (ProxyAuth * self, MYSQL * conn)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, FALSE);
|
||||
|
||||
gboolean connected = mysql_real_connect (conn,
|
||||
self->host, self->user, self->pass, self->schema, self->port, self->socket, 0) != NULL;
|
||||
guint conn_error = mysql_errno (conn);
|
||||
|
@ -226,6 +239,8 @@ proxy_auth_reconnect (ProxyAuth * self, MYSQL * conn)
|
|||
int
|
||||
proxy_auth_authenticate (ProxyAuth * self, MYSQL_PLUGIN_VIO * vio, MYSQL_SERVER_AUTH_INFO * info)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, CR_ERROR);
|
||||
|
||||
int res = CR_ERROR;
|
||||
gchar * query = NULL;
|
||||
GError * error = NULL;
|
||||
|
@ -354,12 +369,12 @@ end:
|
|||
return res;
|
||||
}
|
||||
|
||||
ProxyAuth * pauth;
|
||||
ProxyAuth * pauth = NULL;
|
||||
|
||||
static int
|
||||
proxy_auth_plugin_main (MYSQL_PLUGIN_VIO * vio, MYSQL_SERVER_AUTH_INFO * info)
|
||||
{
|
||||
return proxy_auth_authenticate (pauth, vio, info);;
|
||||
return proxy_auth_authenticate (pauth, vio, info);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[db]
|
||||
user = auth-user
|
||||
user = authentication
|
||||
pass = password
|
||||
socket = /var/run/mysqld/mysqld.sock
|
||||
schema = account
|
||||
|
|
Reference in New Issue