Despite not finding much in Google or elsewhere, I managed to find the solution to this problem. Seems logical in hindsight, but it took me a lot of running around before I got there.
- Download the source code for postgresql from Apple: PostgreSQL-23
- Open Terminal
- cd ~/Downloads
- tar xvf PostgreSQL-23.tar
- Edit the Makefile and add pgcrypto to the ContribTools parameter. It should then read "ContribTools = hstore intarray pg_upgrade pg_upgrade_support pgcrypto"
- make
- sudo make install-contrib
- sudo cp /tmp/PostgreSQL/Release/usr/lib/postgresql/pgcrypto.so /usr/lib/postgresql/
- sudo cp /tmp/PostgreSQL/Release/usr/share/postgresql/contrib/pgcrypto.sql /usr/share/postgresql/contrib/
- sudp cp /tmp/PostgreSQL/Release/usr/share/postgresql/contrib/uninstall_pgcrypto.sql /usr/share/postgresql/contrib/
- Don't know whether it was necessary, but I stopped and started postgres with serveradmin at this point. sudo serveradmin stop postgres; sudo serveradmin start postgres
- Then just update the databases where you need the crypt functionality. e.g. sudo -u _postgres psql -d template1 -f /usr/share/postgresql/contrib/pgcrypto.sql
That's it. Now when I go into the appropriate database I get the expected return on:
select crypt('thisisyourpassword', gen_salt('bf'));
crypt
--------------------------------------------------------------
$2a$06$5gTpj2O6qyCvLs4iCcnBxuB/uxEdTMBI96fbHyyGOiP.A6t7nfKzC
(1 row)
Hope that helps anyone who is looking to store passwords in their postgresql database that is installed by default with Lion Server. I just didn't want to install postgresql from source (or any other precompiled package) and end up with two independent instances of postgresql running on the same server. Seems a bit messy (and unnecessary) to me.
Cheers,
Andrew.