diff -urN aaa/cyrus-sasl-2.1.22/cmulocal/berkdb.m4 cyrus-sasl-2.1.22/cmulocal/berkdb.m4
--- aaa/cyrus-sasl-2.1.22/cmulocal/berkdb.m4	2005-04-26 21:14:07.000000000 +0200
+++ cyrus-sasl-2.1.22/cmulocal/berkdb.m4	2006-10-02 20:36:17.137852392 +0200
@@ -213,7 +213,7 @@
 	fi
 
 	saved_LIBS=$LIBS
-        for dbname in db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db-4.0 db4.0 db-4 db40 db4 db-3.3 db3.3 db33 db-3.2 db3.2 db32 db-3.1 db3.1 db31 db-3 db30 db3 db
+        for dbname in db-5.1 db-5.0 db-4.8 db-4.7 db-4.6 db-4.5 db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db-4.0 db4.0 db-4 db40 db4 db-3.3 db3.3 db33 db-3.2 db3.2 db32 db-3.1 db3.1 db31 db-3 db30 db3 db
           do
 	    LIBS="$saved_LIBS -l$dbname"
 	    AC_TRY_LINK([#include <db.h>],
--- cyrus-sasl-2.1.23/sasldb/db_berkeley.c.orig	2009-04-28 17:09:18.000000000 +0200
+++ cyrus-sasl-2.1.23/sasldb/db_berkeley.c	2010-05-18 21:02:20.418940098 +0200
@@ -100,7 +100,7 @@
     ret = db_create(mbdb, NULL, 0);
     if (ret == 0 && *mbdb != NULL)
     {
-#if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1
+#if (DB_VERSION_MAJOR > 4) || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
 	ret = (*mbdb)->open(*mbdb, NULL, path, NULL, DB_HASH, flags, 0660);
 #else
 	ret = (*mbdb)->open(*mbdb, path, NULL, DB_HASH, flags, 0660);
--- cyrus-sasl-2.1.23/utils/dbconverter-2.c.orig	2003-02-13 20:56:17.000000000 +0100
+++ cyrus-sasl-2.1.23/utils/dbconverter-2.c	2010-05-18 21:11:09.982932556 +0200
@@ -214,7 +214,7 @@
     ret = db_create(mbdb, NULL, 0);
     if (ret == 0 && *mbdb != NULL)
     {
-#if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1
+#if (DB_VERSION_MAJOR > 4) || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
 	ret = (*mbdb)->open(*mbdb, NULL, path, NULL, DB_HASH, DB_CREATE, 0664);
 #else
 	ret = (*mbdb)->open(*mbdb, path, NULL, DB_HASH, DB_CREATE, 0664);