import logging
+import os
from cStringIO import StringIO
from teuthology.exceptions import SELinuxError
+from teuthology.misc import get_archive_dir
from teuthology.orchestra.cluster import Cluster
from . import Task
def teardown(self):
self.restore_modes()
+ self.archive_log()
self.get_new_denials()
def restore_modes(self):
args=['sudo', '/usr/sbin/setenforce', mode],
)
+ def archive_log(self):
+ if not hasattr(self.ctx, 'archive') or not self.ctx.archive:
+ return
+ archive_dir = get_archive_dir(self.ctx)
+ audit_archive = os.path.join(archive_dir, 'audit')
+ mkdir_cmd = "mkdir {audit_archive}"
+ cp_cmd = "sudo cp /var/log/audit/audit.log {audit_archive}"
+ chown_cmd = "sudo chown $USER {audit_archive}/audit.log"
+ gzip_cmd = "gzip {audit_archive}/audit.log"
+ full_cmd = " && ".join((mkdir_cmd, cp_cmd, chown_cmd, gzip_cmd))
+ self.cluster.run(
+ args=full_cmd.format(audit_archive=audit_archive)
+ )
+
def get_new_denials(self):
"""
Determine if there are any new denials in the audit log