Invalid/Unmapped Key with Last Login Plugin
OS: Ubuntu 22.04.1 Dovecot: 2.3.16 (7e2e900c1a)
Hello all! I have the last login plugin working with the IMAP service however with LMTP, it errors. I do not necessarily need / want the LMTP service and did not explicitly enable it but it is throwing an error in my logs.
Jul 17 10:22:14 lmtp(184051):Error: last_login_dict: Failed to write value: dict-server returned failure: sql dict set: Invalid/unmapped key:shared/last-login/lmtp/username@domain.com/ (reply took 0.234 secs (0.001 in dict wait, 0.033 in other ioloops, 0.030 in locks, as
ync-id reply 0.000 secs ago, started on dict-server 0.220 secs ago, took 0.000 secs))
It would be nice to get rid of this error one or another: either disable last login for LMTP or get it working.
Current Configuration from doveconf -n
# 2.3.16 (7e2e900c1a): /etc/dovecot/dovecot.conf # Pigeonhole version 0.5.16 (09c29328) # OS: Linux 6.5.0-1020-aws x86_64 Ubuntu 22.04.4 LTS nfs4 # Hostname: ec2-us-east-1a-arda-mail-001.ardaemail.com auth_mechanisms = plain login auth_worker_max_count = 5 base_dir = /var/run/dovecot debug_log_path = /var/log/dovecot/debug.log default_internal_group = ardaemail default_internal_user = ardaemail dict { quota = mysql:/etc/dovecot/inc.d/inc.quota.user.sql.conf sql = mysql:/etc/dovecot/inc.d/inc.lastlogin.sql.conf } hostname = = mail.ardaemail.com info_log_path = /var/log/dovecot/info.log instance_name = ec2-us-east-1a-arda-mail-001.ardaemail.com listen = 172.16.0.200 log_path = /var/log/dovecot/general.log login_greeting = Welcome to ArdaEmail mail_gid = ardaemail mail_location = maildir:/mnt/mail/%d/%n mail_max_userip_connections = 1000 mail_plugins = " quota mailbox_alias last_login" mail_server_admin = mailto:support@ardaemail.com mail_uid = ardaemail maildir_stat_dirs = yes namespace inbox { inbox = yes location = mailbox Archive { auto = subscribe special_use = \Archive } mailbox Drafts { auto = subscribe special_use = \Drafts } mailbox Junk { auto = subscribe autoexpunge = 90 days special_use = \Junk } mailbox Sent { auto = subscribe special_use = \Sent } mailbox Trash { auto = subscribe autoexpunge = 30 days special_use = \Trash } prefix = } passdb { args = /etc/dovecot/inc.d/inc.sql.conf driver = sql } plugin { imapsieve_mailbox1_before = file:/etc/dovecot/sieve.d/spam/learn-spam.sieve imapsieve_mailbox1_causes = COPY imapsieve_mailbox1_name = Junk imapsieve_mailbox2_before = file:/etc/dovecot/sieve.d/spam/learn-ham.sieve imapsieve_mailbox2_causes = COPY imapsieve_mailbox2_from = Junk imapsieve_mailbox2_name = * last_login_dict = proxy::sql last_login_key = # hidden, use -P to show it last_login_precision = ms mailbox_alias_new = Junk Email mailbox_alias_new2 = Junk E-mail mailbox_alias_new3 = Sent Messages mailbox_alias_new4 = Sent Items mailbox_alias_new5 = Deleted Items mailbox_alias_new6 = Junk Mail mailbox_alias_old = Junk mailbox_alias_old2 = Junk mailbox_alias_old3 = Sent mailbox_alias_old4 = Sent mailbox_alias_old5 = Trash mailbox_alias_old6 = Junk quota = dict:User Quota::proxy::quota quota_exceeded_message = Mailbox is full and cannot receive any more emails quota_status_nouser = DUNNO quota_status_success = DUNNO quota_warning = bytes=95%% quota-warning 95 %u quota_warning2 = bytes=85%% quota-warning 85 %u quota_warning3 = bytes=75%% quota-warning 75 %u recipient_delimiter = + sieve_after = /etc/dovecot/sieve.d/after/ sieve_before = /etc/dovecot/sieve.d/before/ sieve_extensions = +spamtest +spamtestplus +virustest +notify +imapflags sieve_global_extensions = +vnd.dovecot.pipe sieve_pipe_bin_dir = /etc/dovecot/sieve sieve_plugins = sieve_imapsieve sieve_extprograms sieve_quota_max_storage = 0 sieve_spamtest_max_header = X-Spamd-Result: -?[[:digit:]]+\.[[:digit:]]+ / (-?[[:digit:]]+\.[[:digit:]]) sieve_spamtest_status_header = X-Spamd-Result: (-?[[:digit:]]+\.[[:digit:]]+) / -?[[:digit:]]+\.[[:digit:]] sieve_spamtest_status_type = score } postmaster_address = postmaster@ardaemail.com protocols = imap lmtp service auth-worker { group = ardaemail user = ardaemail } service auth { group = ardaemail unix_listener /var/spool/postfix/private/auth { group = postfix mode = 0666 user = postfix } unix_listener auth-userdb { group = ardaemail mode = 0666 user = ardaemail } user = ardaemail } service imap-login { inet_listener imap { port = 0 } inet_listener imaps { port = 993 ssl = yes } process_min_avail = 8 service_count = 0 } service imap { vsz_limit = 4 G } service lmtp { unix_listener /var/spool/postfix/private/dovecot-lmtp { group = postfix mode = 0666 user = postfix } } service pop3-login { inet_listener pop3 { port = 0 } inet_listener pop3s { port = 0 } } service quota-status { executable = /usr/lib/dovecot/quota-status -p postfix unix_listener /var/spool/postfix/private/quota-status { user = postfix } } service quota-warning { executable = script /etc/dovecot/bin/quota-warning.sh unix_listener quota-warning { group = ardaemail mode = 0666 user = ardaemail } } service submission-login { inet_listener submission { port = 0 } } ssl = required ssl_cert = </etc/letsencrypt/live/mail.ardaemail.com/fullchain.pem ssl_client_ca_dir = /etc/ssl/certs ssl_dh = # hidden, use -P to show it ssl_key = # hidden, use -P to show it ssl_prefer_server_ciphers = yes userdb { args = /etc/dovecot/inc.d/inc.sql.conf driver = sql } protocol imap { mail_plugins = " quota mailbox_alias last_login imap_sieve imap_quota last_login" } protocol lmtp { mail_plugins = " quota mailbox_alias last_login sieve" }
In the configuration above, I do not have "last_login" in my actual config for "protocol lmtp", something is adding it.
Any help is appreciated.
Thank you!
Hello all! I have the last login plugin working with the IMAP service however with LMTP, it errors. I do not necessarily need / want the LMTP service and did not explicitly enable it but it is throwing an error in my logs.
Jul 17 10:22:14 lmtp(184051):Error: last_login_dict: Failed to write value: dict-server returned failure: sql dict set: Invalid/unmapped key:shared/last-login/lmtp/username@domain.com/ (reply took 0.234 secs (0.001 in dict wait, 0.033 in other ioloops, 0.030 in locks, as ync-id reply 0.000 secs ago, started on dict-server 0.220 secs ago, took 0.000 secs))
It would be nice to get rid of this error one or another: either disable last login for LMTP or get it working.
Current Configuration from doveconf -n
...
protocols = imap lmtp
service lmtp { unix_listener /var/spool/postfix/private/dovecot-lmtp { group = postfix mode = 0666 user = postfix } }
But LMTP is being explicitly enabled in your config. Remove it from the protocols= line. And optionally remove the service {...} block for it. However just taking it out of protocols should be good enough.
On 17/07/2024 16:03, dovecot--- via dovecot wrote:
Hello all! I have the last login plugin working with the IMAP service however with LMTP, it errors. I do not necessarily need / want the LMTP service and did not explicitly enable it but it is throwing an error in my logs.
Jul 17 10:22:14 lmtp(184051):Error: last_login_dict: Failed to write value: dict-server returned failure: sql dict set: Invalid/unmapped key:shared/last-login/lmtp/username@domain.com/ (reply took 0.234 secs (0.001 in dict wait, 0.033 in other ioloops, 0.030 in locks, as ync-id reply 0.000 secs ago, started on dict-server 0.220 secs ago, took 0.000 secs))
It would be nice to get rid of this error one or another: either disable last login for LMTP or get it working.
Current Configuration from doveconf -n
...
protocols = imap lmtp
service lmtp { unix_listener /var/spool/postfix/private/dovecot-lmtp { group = postfix mode = 0666 user = postfix } }
But LMTP is being explicitly enabled in your config. Remove it from the protocols= line. And optionally remove the service {...} block for it. However just taking it out of protocols should be good enough.
Hi Adam
My recommendation, before disabling lmtp, would be to investigate and maybe revise this point "I do not necessarily need / want the LMTP service and did not explicitly enable it". That error is being generated by a login to lmtp. So what is logging in despite you not needing lmtp?
If for example you are using lmtp to deliver email from postfix to dovecot, disabling lmtp will stop the flow of new email.
John
Yikes, this is my bad! I AM using the LMTP service for delivery. What I meant was that I do not necessarily need to track the logins to the LMTP service. I suppose it wouldn’t hurt to track them though. Any idea why it would be throwing this error? Which key is it expecting to be mapped? Am I missing a configuration specifically for this? Should the last login for LMTP use the same dict as the IMAP configuration?
Here’s my IMAP configuration:
protocol imap {
mail_plugins = $mail_plugins imap_sieve imap_quota last_login
}
Here’s my LMTP configuration:
protocol lmtp {
mail_plugins = $mail_plugins sieve
}
And then here’s my main mail_plugins configuration:
mail_plugins = $mail_plugins quota mailbox_alias last_login
Finally, here’s my dict for the last_login:
plugin {
last_login_dict = proxy::sql
last_login_key = last-login/%{service}/%{user}/%{remote_ip}
last_login_precision = ms
}
dict {
sql = mysql:/etc/dovecot/inc.d/inc.lastlogin.sql.conf
}
All the documentation I have seen everywhere shows that to enable a plugin, you must add it to the main mail_plugins as well as in each protocol you want the plugin enabled but it appears that the $mail_plugins is a variable and adding them there anyways. Is this correct? If so, why does most of the documentation I am reading on a daily basis show to add plugins to the main mail_plugins as well as the protocol?
Any further help is definitely appreciated so I can get this figured out.
Thank you!
------ Original Message ------ From "John Fawcett via dovecot" <dovecot@dovecot.org> To dovecot@dovecot.org Date 7/17/2024 10:23:24 AM Subject Re: Invalid/Unmapped Key with Last Login Plugin
On 17/07/2024 16:03, dovecot--- via dovecot wrote:
Hello all! I have the last login plugin working with the IMAP service however with LMTP, it errors. I do not necessarily need / want the LMTP service and did not explicitly enable it but it is throwing an error in my logs.
Jul 17 10:22:14 lmtp(184051):Error: last_login_dict: Failed to write value: dict-server returned failure: sql dict set: Invalid/unmapped key:shared/last-login/lmtp/username@domain.com/ (reply took 0.234 secs (0.001 in dict wait, 0.033 in other ioloops, 0.030 in locks, as ync-id reply 0.000 secs ago, started on dict-server 0.220 secs ago, took 0.000 secs))
It would be nice to get rid of this error one or another: either disable last login for LMTP or get it working.
Current Configuration from doveconf -n
...
protocols = imap lmtp
service lmtp { unix_listener /var/spool/postfix/private/dovecot-lmtp { group = postfix mode = 0666 user = postfix } }
But LMTP is being explicitly enabled in your config. Remove it from the protocols= line. And optionally remove the service {...} block for it. However just taking it out of protocols should be good enough.
Hi Adam
My recommendation, before disabling lmtp, would be to investigate and maybe revise this point "I do not necessarily need / want the LMTP service and did not explicitly enable it". That error is being generated by a login to lmtp. So what is logging in despite you not needing lmtp?
If for example you are using lmtp to deliver email from postfix to dovecot, disabling lmtp will stop the flow of new email.
John
dovecot mailing list -- dovecot@dovecot.org To unsubscribe send an email to dovecot-leave@dovecot.org
On 17/07/2024 22:59, Adam Miller via dovecot wrote:
Yikes, this is my bad! I AM using the LMTP service for delivery. What I meant was that I do not necessarily need to track the logins to the LMTP service. I suppose it wouldn’t hurt to track them though. Any idea why it would be throwing this error? Which key is it expecting to be mapped? Am I missing a configuration specifically for this? Should the last login for LMTP use the same dict as the IMAP configuration?
Hi Adam
not sure if you saw it but in my earlier response I gave the info about excluding last_login plugin for services where it is not needed. You have it configured globally at the moment.
John
Yes, I did see that, thank you. If I did want to get this working globally, do you know what the issue is here and how to resolve it? I think it has something to do with my database table but I am not positive what the issue is. Here’s my database table (MySQL):
CREATE TABLE mailboxLastLogin
(
email
varchar(192) NOT NULL DEFAULT ‘’,
service
varchar(16) NOT NULL DEFAULT ‘’,
timestamp
bigint(20) NOT NULL,
ipaddress
varchar(40) NOT NULL,
createdAt
datetime NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (email
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
I also have two triggers on this table so when a new row is inserted or
an existing row is updated, a new row is inserted into another tables
named mailboxHistory
. This is working fine and should not be causing
any issues with LMTP trying to query itself.
BEGIN DECLARE mailboxUuid VARCHAR(36);
SELECT uuid INTO mailboxUuid FROM mailbox WHERE email = NEW.email;
INSERT INTO mailboxHistory (`mailboxUuid`, `service`, `command`,
ipaddress
, uuid
)
VALUES (mailboxUuid, NEW.service, 'login', NEW.ipaddress, uuidv4());
END
BEGIN DECLARE mailboxUuid VARCHAR(36);
SELECT uuid INTO mailboxUuid FROM mailbox WHERE email = NEW.email;
INSERT INTO mailboxHistory (`mailboxUuid`, `service`, `command`,
ipaddress
, uuid
)
VALUES (mailboxUuid, NEW.service, 'login', NEW.ipaddress, uuidv4());
END
CREATE TABLE mailboxHistory
(
id
int(11) unsigned NOT NULL AUTO_INCREMENT,
uuid
varchar(36) DEFAULT ‘’,
mailboxUuid
varchar(36) NOT NULL DEFAULT ‘’,
service
varchar(16) NOT NULL,
command
varchar(36) DEFAULT NULL,
extra
longtext DEFAULT NULL,
ipaddress
varchar(40) NOT NULL,
createdAt
datetime NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (id
),
UNIQUE KEY UUID
(uuid
)
) ENGINE=InnoDB AUTO_INCREMENT=2047 DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_general_ci;
Thank you,
Adam
------ Original Message ------ From "John Fawcett via dovecot" <dovecot@dovecot.org> To dovecot@dovecot.org Date 7/17/2024 2:07:29 PM Subject Re: Invalid/Unmapped Key with Last Login Plugin
On 17/07/2024 22:59, Adam Miller via dovecot wrote:
Yikes, this is my bad! I AM using the LMTP service for delivery. What I meant was that I do not necessarily need to track the logins to the LMTP service. I suppose it wouldn’t hurt to track them though. Any idea why it would be throwing this error? Which key is it expecting to be mapped? Am I missing a configuration specifically for this? Should the last login for LMTP use the same dict as the IMAP configuration?
Hi Adam
not sure if you saw it but in my earlier response I gave the info about excluding last_login plugin for services where it is not needed. You have it configured globally at the moment.
John
dovecot mailing list -- dovecot@dovecot.org To unsubscribe send an email to dovecot-leave@dovecot.org
On 17/07/2024 23:35, Adam Miller via dovecot wrote:
Yes, I did see that, thank you. If I did want to get this working globally, do you know what the issue is here and how to resolve it? I think it has something to do with my database table but I am not positive what the issue is. Here’s my database table (MySQL):
CREATE TABLE
mailboxLastLogin
(service
varchar(16) NOT NULL DEFAULT ‘’,timestamp
bigint(20) NOT NULL,ipaddress
varchar(40) NOT NULL,createdAt
datetime NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (I also have two triggers on this table so when a new row is inserted or an existing row is updated, a new row is inserted into another tables named
mailboxHistory
. This is working fine and should not be causing any issues with LMTP trying to query itself.BEGIN DECLARE mailboxUuid VARCHAR(36);
SELECT uuid INTO mailboxUuid FROM mailbox WHERE email = NEW.email;
INSERT INTO mailboxHistory (
mailboxUuid
,service
,command
,ipaddress
,uuid
) VALUES (mailboxUuid, NEW.service, 'login', NEW.ipaddress, uuidv4()); ENDBEGIN DECLARE mailboxUuid VARCHAR(36);
SELECT uuid INTO mailboxUuid FROM mailbox WHERE email = NEW.email;
INSERT INTO mailboxHistory (
mailboxUuid
,service
,command
,ipaddress
,uuid
) VALUES (mailboxUuid, NEW.service, 'login', NEW.ipaddress, uuidv4()); ENDCREATE TABLE
mailboxHistory
(id
int(11) unsigned NOT NULL AUTO_INCREMENT,uuid
varchar(36) DEFAULT ‘’,mailboxUuid
varchar(36) NOT NULL DEFAULT ‘’,service
varchar(16) NOT NULL,command
varchar(36) DEFAULT NULL,extra
longtext DEFAULT NULL,ipaddress
varchar(40) NOT NULL,createdAt
datetime NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (id
), UNIQUE KEYUUID
(uuid
) ) ENGINE=InnoDB AUTO_INCREMENT=2047 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;Thank you,
Adam
Hi Adam
the solution is to change
mail_plugins = " quota mailbox_alias last_login"
to
mail_plugins = quota mailbox_alias
(without the last_login)
The last_login should be configured inside the protocols where you need it, like imap. I don't think it's useful to have the plugin setup for services different to imap, pop3 and smtp where you have users logging in. If you want to have last_login for lmtp without that error, I'd need a bit more info
What are the contents of /etc/dovecot/inc.d/inc.lastlogin.sql.conf (masking any passwords) and what is the output of doveconf plugin/last_login_key
John
On 17/07/2024 12:28, Adam Miller via dovecot wrote:
OS: Ubuntu 22.04.1 Dovecot: 2.3.16 (7e2e900c1a)
Hello all! I have the last login plugin working with the IMAP service however with LMTP, it errors. I do not necessarily need / want the LMTP service and did not explicitly enable it but it is throwing an error in my logs.
Jul 17 10:22:14 lmtp(184051):Error: last_login_dict: Failed to write value: dict-server returned failure: sql dict set: Invalid/unmapped key:shared/last-login/lmtp/username@domain.com/ (reply took 0.234 secs (0.001 in dict wait, 0.033 in other ioloops, 0.030 in locks, as
ync-id reply 0.000 secs ago, started on dict-server 0.220 secs ago, took 0.000 secs))
It would be nice to get rid of this error one or another: either disable last login for LMTP or get it working.
Current Configuration from doveconf -n
# 2.3.16 (7e2e900c1a): /etc/dovecot/dovecot.conf # Pigeonhole version 0.5.16 (09c29328) # OS: Linux 6.5.0-1020-aws x86_64 Ubuntu 22.04.4 LTS nfs4 # Hostname: ec2-us-east-1a-arda-mail-001.ardaemail.com .... mail_plugins = " quota mailbox_alias last_login" .... protocol imap { mail_plugins = " quota mailbox_alias last_login imap_sieve imap_quota last_login" } protocol lmtp { mail_plugins = " quota mailbox_alias last_login sieve" }
In the configuration above, I do not have "last_login" in my actual config for "protocol lmtp", something is adding it.
Hi Adam
maybe you do have last_login enabled for lmtp without realizing it. What is your actual setting for mail_plugins in the protocol lmtp section?
If it something like:
mail_plugins = $mail_plugins sieve
then you are adding the following definition too from the general definition
mail_plugins = " quota mailbox_alias last_login"
So it would make sense to remove last_login from the general mail_plugins setting and add it only to the protocol specific mail_plugins section for the protocols where you want it be used.
John
participants (3)
-
Adam Miller
-
dovecot@ptld.com
-
John Fawcett