sb-md5 and postgresql-socket

Alan Caulkins <[email protected]> Sun, 19 Mar 2006 22:55:12 -0600
Newsgroups gmane.lisp.clsql.devel
Message-ID <[email protected]>
I think I found a problem with md5 authentication in postgresql-socket.
I don't remember seeing anything about it on the mailing lists or in the
docs, but it seems like it would be a show-stopper, so I'm not sure if
my setup is wierd, or if people just don't like to use md5 with PostgreSQL.

md5sum-sequence barfs in postgresql-socket-package.lisp. The
error says that the password, username concatenation passed to
md5sum-sequence "is not of type (VECTOR (UNSIGNED-BYTE 8))". I found that
using sb-md5:md5sum-string instead md5sum-sequence solved the problem.

This brings me to my second question... The definition for the
postgresql-socket package contains the following:

	(:use #:cl #-sbcl md5 #+sbcl sb-md5)

So, am I correct in concluding that when running under sbcl, pg-sock
doesn't require cl-md5, but uses sbcl's md5 package instead? They're both
written by Pierre Mai, and md5sum-sequence barfs in both, only sb-md5
contains md5sum-string, so this fix leaves non-sbcl users out in the
cold. Maybe my low-level lisp skills aren't up to par, but I couldn't
get the password-user string to coerce to an 8-bit byte vector... maybe
it has something to do with unicode?

I have attached a patch, but it will probably break pg-sock compilation
on non-sbcl lisps until md5sum-string is added to cl-md5.

Ideas?
-A

-- 
Maxint Consulting

			Linux: The ultimate video game.

_______________________________________________
CLSQL-Devel mailing list
[email protected]
http://lists.b9.com/mailman/listinfo/clsql-devel
clsql.patch (text/plain, 714 B)
diff -ur clsql-3.5.5/db-postgresql-socket/postgresql-socket-api.lisp clsql-3.5.5.mod/db-postgresql-socket/postgresql-socket-api.lisp
--- clsql-3.5.5/db-postgresql-socket/postgresql-socket-api.lisp	2006-01-16 15:46:14.000000000 -0600
+++ clsql-3.5.5.mod/db-postgresql-socket/postgresql-socket-api.lisp	2006-03-19 22:48:16.000000000 -0600
@@ -448,7 +448,7 @@
 (defun encrypt-md5 (plaintext salt)
   (string-downcase
    (format nil "~{~2,'0X~}"
-	   (coerce (md5sum-sequence (concatenate 'string plaintext salt)) 'list))))
+	   (coerce (md5sum-string (concatenate 'string plaintext salt)) 'list))))
 
 (defun reopen-postgresql-connection (connection)
   "Reopen the given PostgreSQL connection.  Closes any existing