local sasldb = "/usr/pkg/etc/sasldb.db" function auth_passdb_lookup(req) local sasldbq = string.gsub(sasldb, "'", "'\\''") local userq = string.gsub(req.user, "'", "'\\''") local cmd = string.format("db -V hash '%s' '%s' 2>/dev/null", sasldbq, userq) local h = io.popen(cmd, "r") local pw = h:read("a") local success, status, num = h:close() if not success or status ~= "exit" or num ~= 0 then return dovecot.auth.PASSDB_RESULT_USER_UNKNOWN end pw = string.gsub(pw, "\n$", "") return dovecot.auth.PASSDB_RESULT_OK, { password = pw } end