Bug in conditionals to assign values to variables?
Hi,
According to https://wiki2.dovecot.org/Variables you could use
conditionals to assign values to a varible. The syntax is:
%{if;value1;operator;value2;value-if-true;value-if-false}
where any of the fields can refer to another field using %v or %{value}
syntax.
The problem is that when I use a config like:
user_attrs = ...,=relpath=%{if;%u;eq;somevalue;valuetrue;valuefalse}
it works without any problem. But when I use:
user_attrs = ...,=relpath=%{if;%{user};eq;somevalue;valuetrue;valuefalse}
then it reports in logs:
Sep 28 14:23:22 myotis60 dovecot: auth: Error: var_expand_long(if;%{user}) failed: if: requires four or five parameters, got 1
anyway, the variable is correctly initialized, but I get the log.
Is this a bug?
PS: I'm running dovecot 2.2.33
-- Angel L. Mateo Martínez Sección de Telemática Área de Tecnologías de la Información y las Comunicaciones Aplicadas (ATICA) http://www.um.es/atica Tfo: 868889150 Fax: 868888337
On 28 Sep 2018, at 15.25, Angel L. Mateo <amateo@um.es> wrote:
user_attrs = ...,=relpath=%{if;%{user};eq;somevalue;valuetrue;valuefalse}
then it reports in logs:
Sep 28 14:23:22 myotis60 dovecot: auth: Error: var_expand_long(if;%{user}) failed: if: requires four or five parameters, got 1
anyway, the variable is correctly initialized, but I get the log.
Is this a bug?
PS: I'm running dovecot 2.2.33
I can't seem to be able to reproduce this, not even with v2.2.33. It simply works without logging any errors.
I can't seem to be able to reproduce this, not even with v2.2.33. It simply works without logging any errors.
I've made a lot of changes now. I can't neither reproduce it anymore :-(.
If I could, I'll send the complete configuration.
-- Angel L. Mateo Martínez Sección de Telemática Área de Tecnologías de la Información y las Comunicaciones Aplicadas (ATICA) http://www.um.es/atica Tfo: 868889150 Fax: 868888337
Sorry for my last mail. I didn't save the file before reloading dovecot.
passdb { args = /etc/dovecot/dovecot-ldap.conf.ext driver = ldap }
userdb { driver = prefetch } userdb { args = /etc/dovecot/dovecot-ldap-userdb.conf.ext driver = ldap }
auth_debug =yes auth_verbose =yes
In dovecot-ldap-userdb.conf.ext I have:
user_attrs = =user=%{ldap:mail},=quota_rule=%{ldap:quota:*:storage=10G},=home_prefix=/mail/mailboxes/%L{domain},=index_prefix=/mail/indexes/%L{domain},=relpath=%{if;%{username};~;^.+;%2L{username}/%L{username};other_value}
In dovecot-ldap.conf.ext I have:
pass_attrs = =userdb_user=%{ldap:mail},=userdb_quota_rule=%{ldap:quota:*:storage=10G},=userdb_home_prefix=/mail/mailboxes/%L{domain},=userdb_index_prefix=/mail/indexes/%L{domain},=userdb_relpath=%{if;%{username};~;^.+;%2L{username}/%L{username};other_value}
And this the log I have for a "doveadm user angel.luis@um.es" command:
Oct 2 09:59:49 myotis60 dovecot: auth: Debug: Loading modules from directory: /usr/lib/dovecot/modules/auth Oct 2 09:59:49 myotis60 dovecot: auth: Debug: Module loaded: /usr/lib/dovecot/modules/auth/lib20_auth_var_expand_crypt.so Oct 2 09:59:49 myotis60 dovecot: auth: Debug: Loading modules from directory: /usr/lib/dovecot/modules/auth Oct 2 09:59:49 myotis60 dovecot: auth: Debug: Module loaded: /usr/lib/dovecot/modules/auth/libauthdb_ldap.so Oct 2 09:59:49 myotis60 dovecot: auth: Debug: Read auth token secret from /var/run/dovecot/auth-token-secret.dat Oct 2 09:59:49 myotis60 dovecot: auth: Debug: master in: USER#0111#011angel.luis@um.es#011service=doveadm#011debug Oct 2 09:59:49 myotis60 dovecot: auth: Debug: prefetch(angel.luis@um.es): passdb didn't return userdb entries, trying the next userdb Oct 2 09:59:49 myotis60 dovecot: auth: Error: var_expand_long(if;%{username}) failed: if: requires four or five parameters, got 1 Oct 2 09:59:49 myotis60 dovecot: auth: Debug: ldap(angel.luis@um.es): userdb cache miss Oct 2 09:59:49 myotis60 dovecot: auth: Debug: ldap(angel.luis@um.es): user search: base=ou=Usuarios,dc=Telematica scope=subtree filter=(&(objectClass=CourierMailAccount)(irisUserStatus=urn:mace:rediris.es:um.es:userstatus:correo:estado:activo)(irisMailhost=popimapclu11.um.es)(|(uid=angel.luis@um.es)(mail=angel.luis@um.es))) fields=mail,quota Oct 2 09:59:49 myotis60 dovecot: auth: Debug: ldap(angel.luis@um.es): result: mail=angel.luis@um.es quota=*:storage=10G; mail,quota unused Oct 2 09:59:49 myotis60 dovecot: auth: Debug: ldap(angel.luis@um.es): result: mail=angel.luis@um.es quota=*:storage=10G Oct 2 09:59:49 myotis60 dovecot: auth: Error: var_expand_long(if;%{username}) failed: if: requires four or five parameters, got 1 Oct 2 09:59:49 myotis60 dovecot: auth: Debug: userdb out: USER#0111#011angel.luis@um.es#011quota_rule=*:storage=10G#011home_prefix=/mail/mailboxes/um.es#011index_prefix=/mail/indexes/um.es#011relpath=an/angel.luis
-- Angel L. Mateo Martínez Sección de Telemática Área de Tecnologías de la Información y las Comunicaciones Aplicadas (ATICA) http://www.um.es/atica Tfo: 868889150 Fax: 868888337
participants (2)
-
Angel L. Mateo
-
Timo Sirainen