Bug 46454 - create policy/mailquota removal script
create policy/mailquota removal script
Status: CLOSED FIXED
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:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

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
'/var/log/univention/remove_mail_quota_policy.log'.
-------------------------------------------------------------------------------

[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~4.3.0.201803010914.dsc
+++ apt/ucs_4.3-0-errata4.3-0/source/univention-mail-postfix_12.0.0-19A~4.3.0.201803271143.dsc
@@ -1,6 +1,14 @@
-12.0.0-17A~4.3.0.201803010914 [Thu, 01 Mar 2018 09:14:58 +0100] Univention builddaemon <buildd@univention.de>:
+12.0.0-19A~4.3.0.201803271143 [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.
    UsersContainerQuota
        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'.
    User1Quota
        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'.
        done.
    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>
    qr.remove_policies()
  File "./remove_mail_quota_policy", line 151, in remove_policies
    obj.modify()
  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
    self.ready()
  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:
primaryGroup
root@master41:~# lsb_release -r
Release:        4.3-0 errata0
root@master41:~#
Comment 6 Sönke Schwardt-Krummrich univentionstaff 2018-06-05 21:50:20 CEST
After
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~4.3.0.201806052141
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
<http://errata.software-univention.de/ucs/4.3/99.html>