Re: Prelude PostgreSQL Support

Ilya Kogan <[email protected]>
Newsgroups gmane.comp.security.ids.prelude.user
Message-ID <[email protected]>
Ilya Kogan wrote:
>
>>
>> A fix for this issue was checked in the SVN repository:
>> https://trac.prelude-ids.org/changeset/10144
>>
>> The patch is available here:
>> https://trac.prelude-ids.org/changeset/10144?format=diff&new=10144
>>
>>
>> Could you please report whether this solve your problem?
>>
>> Regards,
>>
>>   
> I manually hacked in the fix back when I got the reply while I waited 
> for a more "official" fix and that has been working for a while. 
> Adding the
> if around that seems to be working as well. Thanks for the quick fix.
>
> -- Ilya Kogan
>
Sorry, it seems I was incorrect. PostgreSQL 7.4 does not have the 
PQserverVersion API it seems:
prelude-manager: symbol lookup error: 
/usr/local/lib/libpreludedb/plugins/sql/pgsql.so: undefined symbol: 
PQserverVersion

It would probably be best to use "pg_config" at compile time then? 
Running "pg_config --version" gets me "PostgreSQL 7.4.19". I've created 
a small patch
that figures out the version at configure time based on "pg_config" 
which should fix the problem, though I haven't tested it on anything 8.2 
or greater.

-- Ilya Kogan

_______________________________________________
Prelude-user site list
[email protected]
http://www.prelude-ids.org/mailman/listinfo/prelude-user
postgresql_7.4_quoting.patch (text/plain, 1.8 KB)
Index: plugins/sql/pgsql/pgsql.c
===================================================================
--- plugins/sql/pgsql/pgsql.c	(revision 10145)
+++ plugins/sql/pgsql/pgsql.c	(working copy)
@@ -192,10 +192,11 @@
                 return -1;
         }
 
-        if ( PQserverVersion(session) >= 80200 )
-                ret = prelude_string_sprintf(string, "E'%s'", ptr);
-        else
-                ret = prelude_string_sprintf(string, "'%s'", ptr);
+#ifdef PGSQL_BYTEA_QUOTING
+        ret = prelude_string_sprintf(string, "E'%s'", ptr);
+#else
+        ret = prelude_string_sprintf(string, "'%s'", ptr);
+#endif
 
         free(ptr);
 
Index: configure.in
===================================================================
--- configure.in	(revision 10145)
+++ configure.in	(working copy)
@@ -181,6 +181,12 @@
    if test x$PG_CONFIG != xno; then
 	PGSQL_LIBDIR=`$PG_CONFIG --libdir`
 	PGSQL_INCLUDEDIR=`$PG_CONFIG --includedir`
+    PGSQL_VERSION=`$PG_CONFIG --version | sed 's/^PostgreSQL \([[0-9]]*\.[[0-9]]*\)\.[[0-9]]*$/\1/'`
+    
+    if test "${PGSQL_VERSION%.*}" -ge 8 && test "${PGSQL_VERSION#*.}" -ge 2;
+    then
+        AC_DEFINE([PGSQL_BYTEA_QUOTING],[1],[Should we quote binary data with E?])
+    fi
 
 	AC_CHECK_HEADER($PGSQL_INCLUDEDIR/libpq-fe.h, with_pgsql=yes)
 	if test x$with_pgsql != xyes; then
@@ -420,7 +426,7 @@
 echo "*** Dumping configuration ***"
 echo "    - Generate documentation 	: $enable_gtk_doc"
 echo "    - Enable MySQL plugin    	: $with_mysql"
-echo "    - Enable PostgreSQL plugin 	: $with_pgsql"
+echo "    - Enable PostgreSQL plugin 	: $with_pgsql, Library Version: ${PGSQL_VERSION%.*}.${PGSQL_VERSION#*.}"
 echo "    - Enable SQLite3 plugin	: $with_sqlite3"
 echo "    - Perl binding		: $with_perl"
 echo "    - Python binding		: $with_python";
signature.asc (application/pgp-signature, 249 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHqNK+Wz8XsrBu928RAgNfAJ9Z9v+wbM5tsyyxFHUAS601YkotDwCfejc+
qlEBGopQs5tx6hcm7vwC8LY=
=QgbO
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.