Add "Running System" button in media selection
[snf-image-creator] / image_creator / os_type / unix.py
index 842d27f..e0f0622 100644 (file)
@@ -42,15 +42,17 @@ class Unix(OSBase):
     sensitive_userdata = [
         '.bash_history',
         '.gnupg',
-        '.ssh',
-        '.mozilla',
-        '.thunderbird'
+        '.ssh'
     ]
 
     def __init__(self, rootdev, ghandler, output):
         super(Unix, self).__init__(rootdev, ghandler, output)
 
         self.meta["USERS"] = " ".join(self._get_passworded_users())
+        # Delete the USERS metadata if empty
+        if not len(self.meta['USERS']):
+            self.out.warn("No passworded users found!")
+            del self.meta['USERS']
 
     def _get_passworded_users(self):
         users = []
@@ -77,6 +79,9 @@ class Unix(OSBase):
             self.out.output("Removing all user accounts with id greater than "
                             "1000")
 
+        if 'USERS' not in self.meta:
+            return
+
         # Remove users from /etc/passwd
         passwd = []
         removed_users = {}
@@ -92,6 +97,11 @@ class Unix(OSBase):
                 passwd.append(':'.join(fields))
 
         self.meta['USERS'] = " ".join(metadata_users)
+
+        # Delete the USERS metadata if empty
+        if not len(self.meta['USERS']):
+            del self.meta['USERS']
+
         self.g.write('/etc/passwd', '\n'.join(passwd) + '\n')
 
         # Remove the corresponding /etc/shadow entries
@@ -190,5 +200,7 @@ class Unix(OSBase):
                 fname = "%s/%s" % (homedir, data)
                 if self.g.is_file(fname):
                     self.g.scrub_file(fname)
+                elif self.g.is_dir(fname):
+                    self.foreach_file(fname, self.g.scrub_file, ftype='r')
 
 # vim: set sta sts=4 shiftwidth=4 sw=4 et ai :