gdbm_close of >=sys-libs/gdbm-1.17 also sets gdbm_errno. This overlays a value that is used for returning a lookup failure. archlinux bug: https://bugs.archlinux.org/task/59873 upstream patch: https://github.com/cyrusimap/cyrus-sasl/pull/554
Created attachment 563674 [details, diff] copy the correct errno value to check against later patch fixing the issue, also submitted upstream: https://github.com/cyrusimap/cyrus-sasl/pull/554
Can confirm that the patch works and restores the ability to migrate cyrus-sasl from berkdb to gdbm (which otherwise fails with very misleading auth errors). My system is now completely berkdb-free. Thank You!
FWIW, this patch did actually get added at some point: https://gitweb.gentoo.org/repo/gentoo.git/commit/dev-libs/cyrus-sasl?id=0ea0e5c7d34102447316e0ec3e9a4aa82e4523bf