In case my reading of Replication with dsync is correct, the goal of syncing the folders for one user between two mail servers should be obtainable by ensuring userdb returns noreplicate for all but one user, or only sets mail_replica for the one interesting user. I've attempted doing both, as shown below.

Setting auth_debug = yes indicates these fields are getting picked up, regardless if I use sqlite or lua for the userdb. The config below, heavily inspired by Lua based authentication, is cleaner than the sqlite one and the relevant parts goes:

passdb {
  driver = pam

userdb {
  driver = lua
  args = file=/etc/dovecot/userdb.lua blocking=yes
  result_success = return-ok

userdb {
  driver = passwd
  skip = found
---@diagnostic disable: lowercase-global,undefined-global
local syncuser = "someuser"

function auth_userdb_lookup(req)
  local fields = "uid=" .. req.user .. " " ..
      "gid=mail " ..
      "home=/home/" .. req.user .. " " ..
  if req.user == syncuser then
    return dovecot.auth.USERDB_RESULT_OK, fields ..
        -- might be invalid syntax, but we're not getting this far...
        " mail_replica=remote:[email protected]"
    return dovecot.auth.USERDB_RESULT_OK, fields ..
        " noreplicate=yes"

function script_init()
  return 0

function script_deinit()

function auth_userdb_iterate()
  return {syncuser}

My expectation from the above would be that sync attempts only happened for someuser, but doveadm log errors quickly gets flooded with (for other users than someuser):

Error: doveadm(…): sync: User has no mail_replica in userdb

I would also expect doveadm user '*' to only show someuser as that is the only value returned by auth_userdb_iterate(), but it does instead give me all users on the system.

The lua code uses the recommended Dovecot Settings Types kind of boolean, as it makes most sense. I've tried lua style true and 1 too, with no difference in the outcome.

While I realize the error message comes from doveadm-dsync.c, it does seem a bit misdirected to dive that deep into the internals for something that is perhaps only a simple misconception on my side?


You must log in to answer this question.

Browse other questions tagged .