Added fixed nested deleted homes problem

This commit is contained in:
Marc Aymerich 2016-02-16 12:04:52 +00:00
parent 4541727986
commit 84dd6f26e0
3 changed files with 31 additions and 3 deletions

View file

@ -110,7 +110,18 @@ class UNIXUserMaildirBackend(SieveFilteringMixin, ServiceController):
def delete(self, mailbox):
context = self.get_context(mailbox)
self.append('mv %(home)s %(home)s.deleted || exit_code=$?' % context)
if context['deleted_home']:
self.append(textwrap.dedent("""\
# Move home into MAILBOXES_MOVE_ON_DELETE_PATH, nesting if exists.
deleted_home="%(deleted_home)s"
while [[ -e $deleted_home ]]; do
deleted_home="${deleted_home}/$(basename ${deleted_home})"
done
mv %(home)s $deleted_home || exit_code=$?
""") % context
)
else:
self.append("rm -fr %(base_home)s" % context)
self.append(textwrap.dedent("""
nohup bash -c '{ sleep 2 && killall -u %(user)s -s KILL; }' &> /dev/null &
killall -u %(user)s || true
@ -134,6 +145,7 @@ class UNIXUserMaildirBackend(SieveFilteringMixin, ServiceController):
'initial_shell': self.SHELL,
'banner': self.get_banner(),
}
context['deleted_home'] = settings.MAILBOXES_MOVE_ON_DELETE_PATH % context
return context

View file

@ -104,7 +104,15 @@ class UNIXUserBackend(ServiceController):
""") % context
)
if context['deleted_home']:
self.append("mv %(base_home)s %(deleted_home)s || exit_code=$?" % context)
self.append(textwrap.dedent("""\
# Move home into SYSTEMUSERS_MOVE_ON_DELETE_PATH, nesting if exists.
deleted_home="%(deleted_home)s"
while [[ -e $deleted_home ]]; do
deleted_home="${deleted_home}/$(basename ${deleted_home})"
done
mv %(base_home)s $deleted_home || exit_code=$?
""") % context
)
else:
self.append("rm -fr %(base_home)s" % context)

View file

@ -42,7 +42,15 @@ class WebAppServiceMixin(object):
def delete_webapp_dir(self, context):
if context['deleted_app_path']:
self.append("mv %(app_path)s %(deleted_app_path)s || exit_code=$?" % context)
self.append(textwrap.dedent("""\
# Move app into WEBAPPS_MOVE_ON_DELETE_PATH, nesting if exists.
deleted_app_path="%(deleted_app_path)s"
while [[ -e $deleted_app_path ]]; do
deleted_app_path="${deleted_app_path}/$(basename ${deleted_app_path})"
done
mv %(app_path)s $deleted_app_path || exit_code=$?
""") % context
)
else:
self.append("rm -fr %(app_path)s" % context)