Commit ce66ae38 authored by Nikos Skalkotos's avatar Nikos Skalkotos

Check if scrubbing is supported

Don't try to scrub data unless the used guestfs appliance supports
it
parent ab694a5e
......@@ -85,6 +85,13 @@ class OSBase(object):
self.out = output
self.meta = {}
# Many guestfs compilations don't support scrub
self._scrub_support = True
try:
self.g.available(['scrub'])
except RuntimeError:
self._scrub_support = False
def collect_metadata(self):
"""Collect metadata about the OS"""
try:
......
......@@ -139,12 +139,17 @@ class Unix(OSBase):
self.out.output("Removing sensitive user data under %s" %
" ".join(homedirs))
action = self.g.rm_rf
if self._scrub_support:
action = self.g.scrub_file
else:
self.out.warn("Sensitive data won't be scrubbed (not supported)")
for homedir in homedirs:
for data in self.sensitive_userdata:
fname = "%s/%s" % (homedir, data)
if self.g.is_file(fname):
self.g.scrub_file(fname)
action(fname)
elif self.g.is_dir(fname):
self._foreach_file(fname, self.g.scrub_file, ftype='r')
self._foreach_file(fname, action, ftype='r')
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment