Skip to content
Snippets Groups Projects
Commit ce66ae38 authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Check if scrubbing is supported

Don't try to scrub data unless the used guestfs appliance supports
it
parent ab694a5e
No related branches found
Tags v0.2
No related merge requests found
...@@ -85,6 +85,13 @@ class OSBase(object): ...@@ -85,6 +85,13 @@ class OSBase(object):
self.out = output self.out = output
self.meta = {} 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): def collect_metadata(self):
"""Collect metadata about the OS""" """Collect metadata about the OS"""
try: try:
......
...@@ -139,12 +139,17 @@ class Unix(OSBase): ...@@ -139,12 +139,17 @@ class Unix(OSBase):
self.out.output("Removing sensitive user data under %s" % self.out.output("Removing sensitive user data under %s" %
" ".join(homedirs)) " ".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 homedir in homedirs:
for data in self.sensitive_userdata: for data in self.sensitive_userdata:
fname = "%s/%s" % (homedir, data) fname = "%s/%s" % (homedir, data)
if self.g.is_file(fname): if self.g.is_file(fname):
self.g.scrub_file(fname) action(fname)
elif self.g.is_dir(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 : # vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment