Return extra fields from passwd userdb

Michele Petrella petrella at AFASystems.it
Thu Jul 20 11:45:11 EEST 2017


Hi,
thanks for your helpful reply.

I understand that default_fields is not my solution.

To be more accurate, all users in ldap db need to use mail, but some 
users in /etc/passwd file use mail too.
For this reason I set up "driver=passwd" in userdb section and in 
/etc/nsswitch.conf I set up "passwd:         files ldap".
Now I want to use dovecot per user quota to limit ldap users mailbox 
size. I need quota only for ldap users, no need for users in /etc/passwd 
file.

Which is the correct configuration to do this?
I understand that I need to use extra fields to obtain user quota from 
users db. But you said "the userdb section cannot merge two databases 
together". So I can not use dovecot per user quota with "driver=passwd" 
in userdb section? I could use only global quota?

Thanks in advance

Michele

P.S.
1) I use dovecot-lda as delivery agent.

2) I send again my dovecot configuration:

# 2.2.29.1 (e0b76e3): /var/etc/dovecot/dovecot.conf
# Pigeonhole version 0.4.18 (29cc74d)
# OS: Linux 3.10.55-gentoo i686 SuSE Linux 7.1 (i386)
debug_log_path = /var/log/dovecot/dovecot_debug.log
disable_plaintext_auth = no
info_log_path = /var/log/state.mail/dovecot.pipe
log_path = /var/log/dovecot/dovecot.log
mail_debug = yes
mail_gid = users
mail_location = maildir:~/.maildir
mail_plugins = acl quota
mail_shared_explicit_inbox = yes
mail_uid = vmail
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope 
encoded-character vacation subaddress comparator-i;ascii-numeric 
relational regex imap4flags copy include variables body enotify 
environment mailbox date index ihave duplicate mime foreverypart 
extracttext
namespace {
   list = yes
   location = maildir:/data/home/vmail/public
   prefix = Public/
   separator = /
   subscriptions = no
   type = public
}
namespace {
   list = children
   location = maildir:/data/home/%%n/.maildir:INDEX=~/.maildir/shared/%%u
   prefix = Shared/%%u/
   separator = /
   subscriptions = no
   type = shared
}
namespace inbox {
   inbox = yes
   list = yes
   location =
   mailbox Cestino {
     special_use = \Trash
   }
   mailbox Drafts {
     special_use = \Drafts
   }
   mailbox Junk {
     special_use = \Junk
   }
   mailbox "Posta inviata" {
     special_use = \Sent
   }
   mailbox Sent {
     special_use = \Sent
   }
   mailbox "Sent Messages" {
     special_use = \Sent
   }
   mailbox Trash {
     special_use = \Trash
   }
   prefix =
   separator = /
   subscriptions = yes
   type = private
}
passdb {
   args = /etc/dovecot/passwd.masterusers
   driver = passwd-file
   master = yes
}
passdb {
   driver = pam
}
plugin {
   acl = vfile:/etc/dovecot/acl:cache_secs=300
   acl_shared_dict = file:/var/lib/dovecot-dict/shared-mailboxes
   quota = maildir:User quota
   quota_rule = *:storage=5M
   quota_rule2 = Trash:storage=+100M
   quota_rule3 = SPAM:ignore
   sieve = ~/.dovecot.sieve
   sieve_before = /var/etc/dovecot/sieve/general/
   sieve_dir = ~/sieve
   sieve_execute_bin_dir = /usr/local/bin/dovecot/sieve-execute
   sieve_filter_bin_dir = /usr/local/bin/dovecot/sieve-filter
   sieve_global_dir = /var/etc/dovecot/sieve/global/
   sieve_global_extensions = +vnd.dovecot.execute +vnd.dovecot.filter 
+vnd.dovecot.pipe +editheader
   sieve_pipe_bin_dir = /usr/local/bin/dovecot/sieve-pipe
   sieve_plugins = sieve_extprograms
}
protocols = imap pop3 lmtp sieve
service auth {
   unix_listener auth-userdb {
     group = users
   }
}
service imap-postlogin {
   executable = script-login /usr/local/bin/imap-postlogin.sh
   user = $default_internal_user
}
service imap {
   executable = imap imap-postlogin
}
ssl = no
ssl_cert = </conf/etc/cert/certs/services/imap_pop/majornet.crt
ssl_key =  # hidden, use -P to show it
userdb {
   driver = passwd
}
protocol lda {
   info_log_path = /var/log/dovecot/dovecot-lda.log
   log_path = /var/log/dovecot/dovecot-lda.log
   mail_plugins = acl quota sieve
}
protocol imap {
   mail_max_userip_connections = 20
   mail_plugins = acl quota imap_acl imap_quota
}


>> userdb {
>>  default_fields = quota_rule=*:bytes=%$
>>  driver = passwd
>> }
>
>> I have problems in return extra fields from passwd userdb. My users 
>> are partially in passwd files and partially in LDAP. Users who use 
>> mail are in LDAP db.
>
>> If I use "default_fields = quota_rule=*:bytes=100M" in userdb,
>
>> if I use "default_fields = quota_rule=*:bytes=%{userdb:quotabytes}" 
>> in userdb,
>
> 1) default_fields supplies default values, if the userdb does not 
> return them. Hence, you cannot reference a LDAP result.
>
> 2) the userdb section cannot merge two databases together. You said 
> "Users who use mail are in LDAP db", so you would one userdb with 
> driver ldap.

-- 
AFA Systems Srl
Via G.Pastore
Zona Industriale B
86039 Termoli (CB) - Italia
tel.: +39 0875 724104
fax.: +39 0875 726084
www.afasystems.it



More information about the dovecot mailing list