Bug 38840

Summary: dovecot.py listener ignores special case
Product: UCS Reporter: Sönke Schwardt-Krummrich <schwardt>
Component: Mail - DovecotAssignee: Daniel Tröder <troeder>
Status: CLOSED FIXED QA Contact: Sönke Schwardt-Krummrich <schwardt>
Severity: normal    
Priority: P5 CC: walkenhorst
Version: UCS 4.0   
Target Milestone: ---   
Hardware: Other   
OS: Linux   
What kind of report is it?: --- What type of bug is this?: ---
Who will be affected by this bug?: --- How will those affected feel about the bug?: ---
User Pain: Enterprise Customer affected?:
School Customer affected?: ISV affected?:
Waiting Support: Flags outvoted (downgraded) after PO Review:
Ticket number: Bug group (optional):
Max CVSS v3 score:
Bug Depends on:    
Bug Blocks: 34839    

Description Sönke Schwardt-Krummrich univentionstaff 2015-07-06 23:19:15 CEST
I think, the following code snippet fails to move the mailbox if
the mailHomeServer is changed from "" to the FQDN of the local system
AND the mailPrimaryAddres is changed:

is_old_home_server = oldHomeServer == "" or oldHomeServer == fqdn
is_new_home_server = newHomeServer == "" or newHomeServer == fqdn

# mailPrimaryAddress changed, but same home server
if is_old_home_server and is_new_home_server \
	and oldHomeServer == newHomeServer \
	and oldMailPrimaryAddress and newMailPrimaryAddress \
	and oldMailPrimaryAddress != newMailPrimaryAddress:
	dl.move_email_account2(dn, oldMailPrimaryAddress, newMailPrimaryAddress)
	return

is_old_home_server nad is_new_home_server already defines, that this
server is responsible for the old and the new user object. So the
comparison "oldHomeServer == newHomeServer" seems to be the culprit.
Comment 1 Daniel Tröder univentionstaff 2015-07-07 17:19:35 CEST
Good catch!
Fixed in r61853 / 0.0.0-52.
Comment 2 Sönke Schwardt-Krummrich univentionstaff 2015-07-08 00:03:04 CEST
Found another corner case:

oldMailPrimaryAddress=foo@univention.de
newMailPrimaryAddress=foo@univention.de
is_old_home_server=True
is_new_home_server=False
→ in this case, the server is no longer responsible for the mailbox and 
  dl.delete_email_account2() should have been called
→ current code:
  if oldMailPrimaryAddress and not newMailPrimaryAddress and is_old_home_server:
→ suggestion for corrected code:
  if oldMailPrimaryAddress and is_old_home_server and \
                          (not newMailPrimaryAddress or not is_new_home_server):
Comment 3 Sönke Schwardt-Krummrich univentionstaff 2015-07-08 00:12:26 CEST
Fix has been committed as:
r61857 | Bug #34839: delete mail account in case of change of home server from us to another
Comment 4 Sönke Schwardt-Krummrich univentionstaff 2015-07-08 00:41:49 CEST
Tested both cases:
1)
mailPrimaryAddress changed from foo@univention.de to foo2@univention.de
mailHomeServer changed from "" to "slave22b.univention.de"

2)
mailPrimaryAddress was set and left untouched
mailHomeServer switched to a different server slave22c.univention.de

→ OK
→ VERIFIED
Comment 5 Janek Walkenhorst univentionstaff 2015-07-09 18:15:54 CEST
<http://errata.univention.de/ucs/4.0/237.html>