I was able to solve this by specifying userdb use the passwd-file in addition
to passdb using bsdauth:

userdb {
  args = username_format=%u /etc/passwd
  default_fields = quota_rule=*:storage=1G
  driver = passwd-file
}

This is combined with:

passdb {
  driver = bsdauth
}

This may be an ugly solution but it does seem to work and only requires me
maintain a single passwd file.

--
Aaron Lin
j...@ircnow.org
IRCNow (https://ircnow.org)

On Mon, Aug 04, 2025 at 07:32:55PM -0700, j...@ircnow.org wrote:
> I am now trying to use bsdauth instead of passwd-file:
> 
> passdb {
>   driver = bsdauth
> }
> 
> When I attempt to login via IMAP, dovecot reports this error:
> 
> Aug  4 19:19:43 jrmu dovecot: imap(77561): Error: Couldn't drop privileges: 
> User is missing UID (see mail_uid setting)
> 
> Below is the output of dovecot -n:
> 
> # dovecot -n
> # 2.3.21.1 (d492236fa0): /etc/dovecot/dovecot.conf
> # OS: OpenBSD 7.7 amd64  ffs
> # Hostname: jrmu.host.nastycode.com
> auth_debug = yes
> auth_debug_passwords = yes
> auth_verbose = yes
> auth_verbose_passwords = sha1
> first_valid_uid = 1000
> listen = 104.167.242.227, 2602:fccf:1:2227::
> mail_debug = yes
> mail_location = maildir:/home/%u/Maildir
> mbox_write_locks = fcntl
> mmap_disable = yes
> namespace inbox {
>   inbox = yes
>   location =
>   mailbox Drafts {
>     special_use = \Drafts
>   }
>   mailbox Junk {
>     special_use = \Junk
>   }
>   mailbox Sent {
>     special_use = \Sent
>   }
>   mailbox "Sent Messages" {
>     special_use = \Sent
>   }
>   mailbox Trash {
>     special_use = \Trash
>   }
>   prefix =
> }
> passdb {
>   driver = bsdauth
> }
> ssl_cert = </etc/ssl/jrmu.host.nastycode.com.crt
> ssl_key = # hidden, use -P to show it
> verbose_ssl = yes
> 
> dovecot will properly drop privileges work if I hard code mail_uid and
> mail_gid:
> 
> mail_uid = 1001
> mail_gid = 1001
> 
> But shouldn't dovecot be allowed to drop to any user that logs in, and not get
> hard coded to a single uid?
> 
> -- 
> Aaron Lin
> j...@ircnow.org
> IRCNow (https://ircnow.org)
> 
> On Mon, Aug 04, 2025 at 07:50:54AM +0300, Aki Tuomi wrote:
> > 
> > > On 04/08/2025 01:30 EEST jrmu--- via dovecot <dovecot@dovecot.org> wrote:
> > > 
> > >  
> > > Greetings Dovecot team/users,
> > > 
> > > I am trying to use Dovecot to serve Maildir files. The users' email is
> > > located in ~/Maildir (in each user's home directory). I tried specifying
> > > 
> > > mail_location = maildir:~/Maildir
> > > 
> > > but I get this error:
> > > 
> > > Aug  4 00:06:34 ch dovecot: imap(username): Error: Relative home 
> > > directory paths not supported: 0
> > > 
> > > Are relative home directory paths not supported?
> > > 
> > > Here is the output of dovecot -n:
> > > 
> > > # dovecot -n
> > >   driver = passwd-file
> > > }
> > > verbose_ssl = yes
> > > 
> > > 1375 bytes received in 0.00 seconds (5.18 MB/s)
> > > 
> > > -- 
> > > Aaron Lin
> > > j...@ircnow.org
> > > IRCNow (https://ircnow.org)
> > > _______________________________________________
> > > dovecot mailing list -- dovecot@dovecot.org
> > > To unsubscribe send an email to dovecot-le...@dovecot.org
> > 
> > 
> > Either add
> > 
> > mail_home = /path/to/home/%u (or something like this)
> > 
> > or your passwd-file needs to returns home directory.
> > 
> > Aki
> > 
> > 
_______________________________________________
dovecot mailing list -- dovecot@dovecot.org
To unsubscribe send an email to dovecot-le...@dovecot.org

Reply via email to