Bug 46454 - create policy/mailquota removal script
create policy/mailquota removal script
Product: UCS
Classification: Unclassified
Component: Mail
UCS 4.3
Other Linux
: P5 normal (vote)
: UCS 4.3-0-errata
Assigned To: Daniel Tröder
Sönke Schwardt-Krummrich
Depends on:
Blocks: 46102
  Show dependency treegraph
Reported: 2018-03-01 18:09 CET by Daniel Tröder
Modified: 2018-06-06 16:16 CEST (History)
0 users

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 2: Improvement: Would be a product improvement
Who will be affected by this bug?: 2: Will only affect a few installed domains
How will those affected feel about the bug?: 2: A Pain – users won’t like this once they notice it
User Pain: 0.046
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:


Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2018-03-01 18:09:25 CET
+++ This bug was initially created as a clone of Bug #46102 +++

Write a script and deliver it with univention-mail-postfix, so that it will be available on all installations.

The script should search for policies/mailquota and delete them.
It should by default do a dry-run and only if executed with "--force" actually delete.
Comment 1 Daniel Tröder univentionstaff 2018-03-05 09:27:17 CET
I pushed the WIP into branch dtroeder/46454_mailquota_removal.
Comment 2 Daniel Tröder univentionstaff 2018-03-05 09:37:44 CET
Contains code to workaround Bug #16966.
Comment 3 Daniel Tröder univentionstaff 2018-03-27 11:48:30 CEST
The script removes quote policies, references to them and the UDM module itself. It the module itself cannot be found, direct LDAP modifications are used.

# /usr/share/univention-mail-postfix/remove_mail_quota_policy -h
usage: remove_mail_quota_policy [-h] [-m] [-v]

Remove Cyrus mail quota policy references and objects from LDAP.

optional arguments:
  -h, --help     show this help message and exit
  -m, --modify   Commit changes to LDAP [default: False (dry run)].
  -v, --verbose  Enable debugging output on the console [default: False].

All output (incl. debugging statements) is written to logfile

[4.3-0] 150d7335d0 Bug #46454: WIP policy/mailquota removal script
[4.3-0] 389f01a435 Bug #46454: mailquota removal script
[4.3-0] afb0687051 Bug #46454: changelog
[4.3-0] d7fe37790a Bug #46454: actually install script
[4.3-0] 71e77d0ecb Bug #46454: changelog
[4.3-0] a99044d11e Bug #46454: advisory

univention-mail-postfix (12.0.0-19)
Comment 4 Quality Assurance univentionstaff 2018-05-04 16:44:18 CEST
--- mirror/ftp/4.3/unmaintained/4.3-0/source/univention-mail-postfix_12.0.0-17A~
+++ apt/ucs_4.3-0-errata4.3-0/source/univention-mail-postfix_12.0.0-19A~
@@ -1,6 +1,14 @@
-12.0.0-17A~ [Thu, 01 Mar 2018 09:14:58 +0100] Univention builddaemon <buildd@univention.de>:
+12.0.0-19A~ [Tue, 27 Mar 2018 11:43:43 +0200] Univention builddaemon <buildd@univention.de>:
   * UCS auto build. No patches were applied to the original source package
+12.0.0-19 [Tue, 27 Mar 2018 11:42:57 +0200] Daniel Troeder <troeder@univention.de>:
+  * Bug #46454: actually install script
+12.0.0-18 [Tue, 27 Mar 2018 11:35:30 +0200] Daniel Troeder <troeder@univention.de>:
+  * Bug #46454: add mailquota policy removal script
 12.0.0-17 [Thu, 01 Mar 2018 08:59:47 +0100] Daniel Troeder <troeder@univention.de>:
Comment 5 Sönke Schwardt-Krummrich univentionstaff 2018-06-05 21:16:43 CEST
root@master41:~# ./remove_mail_quota_policy -m
Searching Cyrus mail quota objects in LDAP.
        Quota: 1234
        DN: 'cn=UsersContainerQuota,cn=mail,cn=policies,dc=nstx,dc=local'
        referenced by 'cn=users,dc=nstx,dc=local'.
        referenced by 'uid=user5,cn=users,dc=nstx,dc=local'.
        Quota: 123
        DN: 'cn=User1Quota,cn=mail,cn=policies,dc=nstx,dc=local'
        referenced by 'uid=user1,cn=users,dc=nstx,dc=local'.
        referenced by 'uid=user4,cn=users,dc=nstx,dc=local'.
* UsersContainerQuota: removing policy references.
    removing policy reference from 'cn=users,dc=nstx,dc=local'.
    removing policy reference from 'uid=user5,cn=users,dc=nstx,dc=local'.
Traceback (most recent call last):
  File "./remove_mail_quota_policy", line 210, in <module>
  File "./remove_mail_quota_policy", line 151, in remove_policies
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/users/user.py", line 1673, in modify
    return super(object, self).modify(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 524, in modify
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 303, in ready
    raise univention.admin.uexceptions.insufficientInformation(_('The following properties are missing:\n%s') % ('\n'.join(missing),))
univention.admin.uexceptions.insufficientInformation: The following properties are missing:
root@master41:~# lsb_release -r
Release:        4.3-0 errata0
Comment 6 Sönke Schwardt-Krummrich univentionstaff 2018-06-05 21:50:20 CEST
obj = mod.lookup(None, self.lo, filter_s, base=base)[0]
no obj.open() is performed. Therefore not all attributes are initialized to be able to perform a proper obj.modify().

Fixed in 
97b9fd835b Bug #46454: fix traceback due to "un-open-ed" UDM object
7f50282401 Bug #46454: update advisory

Package: univention-mail-postfix
Version: 12.0.0-20A~
Branch: ucs_4.3-0
Scope: errata4.3-0

OK: code change
OK: functional test (4.3)
    OK: remove with existing UDM module
    OK: remove w/o existing UDM modules 
        (removed users/user, container/cn, policies/mailquota for this test)
OK: changelog
OK: advisory
Comment 7 Erik Damrose univentionstaff 2018-06-06 16:16:26 CEST