Merge branch 'hotfix-0.4.4' into develop
[snf-image-creator] / image_creator / os_type / unix.py
index 9fe2c50..7e3ba22 100644 (file)
@@ -35,8 +35,6 @@
 
 """This module hosts OS-specific code common to all Unix-like OSs."""
 
-import re
-
 from image_creator.os_type import OSBase, sysprep
 
 
@@ -87,7 +85,7 @@ class Unix(OSBase):
 
         return True
 
-    @sysprep('Removing files u)nder /var/cache')
+    @sysprep('Removing files under /var/cache')
     def cleanup_cache(self):
         """Remove all regular files under /var/cache"""
 
@@ -123,12 +121,18 @@ class Unix(OSBase):
         if self.g.is_dir('/home/'):
             homedirs += self._ls('/home/')
 
+        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 :