Hello, i have problems configuring the last_login plugin with mysql. I have extended the postfixadmin database with a new field, configured the plugin as described in the wiki. Finally i got errors: table is not writable, INSERT failed. Why is the insert required? The plugin should only UPDATE the column for existing rows. Or am i missing some configuration options? Here is my dictionary config: map { pattern = shared/last-login/$user table = mailbox value_field = x_last_login value_type = uint fields { username = $user } } Dovecot: 2.2.27 (c0f36b0) Kind regards, Thomas
On 23.09.2018 19:20, Thomas Hooge wrote:> Hello, > > i have problems configuring the last_login plugin with mysql. > > I have extended the postfixadmin database with a new field, > configured the plugin as described in the wiki. > > Finally i got errors: table is not writable, INSERT failed. > > Why is the insert required? The plugin should only UPDATE > the column for existing rows. > Or am i missing some configuration options? > Here is my dictionary config: > > map { > pattern = shared/last-login/$user > table = mailbox > value_field = x_last_login > value_type = uint > > fields { > username = $user > } > } > > > Dovecot: 2.2.27 (c0f36b0) > > Kind regards, > Thomaslast_login plugin uses dict interface, which does not support "update", it only supports get, set, unset and atomic inc. Set is implemented with 'INSERT INTO foo ... ON DUPLICATE UPDATE'. There is no configuration setting to change this, as dict cannot know without performing a SELECT that a value already exists. Aki
Hello,> last_login plugin uses dict interface, which does not support "update", > it only supports get, set, unset and atomic inc. Set is implemented > with > 'INSERT INTO foo ... ON DUPLICATE UPDATE'. There is no configuration > setting to change this, as dict cannot know without performing a SELECT > that a value already exists.Ok, now i understand the dict behaviour. Some clarification in the last-login wiki page would be nice: * needed Database rights * Example of last_login in separate table In my special case i wanted to use the last_login field inside the mailbox table of postfixadmin. From the security point of view i don't want dovecot to be able to insert records in that table. So the only additional right should be update on the last_login field. In the case of the last_login plugin there ist a very high probability the dict key exists because of the previous successfull login which uses the same table. If the key does not exist there is a serious problem :-) Perhaps there shoud be a feature of different types of dicts: * normal dict (as implemented) * immutable dict (read only) * dict with immutable keys (only value writeable) Kind regards, Thomas