+ def _do_inspect(self):
+ """Run various diagnostics to check if media is supported"""
+
+ self.out.output(
+ 'Checking if the media contains logical volumes (LVM)...', False)
+
+ has_lvm = True if len(self.image.g.lvs()) else False
+
+ if has_lvm:
+ self.out.output()
+ self.image.set_unsupported('The media contains logical volumes')
+ else:
+ self.out.success('no')
+
+ def _do_collect_metadata(self):
+ """Collect metadata about the OS"""
+ super(Linux, self)._do_collect_metadata()
+ 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):
+ """Returns a list of non-locked user accounts"""
+ users = []
+ regexp = re.compile(r'(\S+):((?:!\S+)|(?:[^!*]\S+)|):(?:\S*:){6}')
+
+ for line in self.image.g.cat('/etc/shadow').splitlines():
+ match = regexp.match(line)
+ if not match:
+ continue
+
+ user, passwd = match.groups()
+ if len(passwd) > 0 and passwd[0] == '!':
+ self.out.warn("Ignoring locked %s account." % user)
+ else:
+ users.append(user)
+
+ return users
+
+ def _is_persistent(self, dev):
+ """Checks if a device name is persistent."""
+ return not self._persistent.match(dev)
+
+ def _get_uuid(self, dev):
+ """Returns the UUID corresponding to a device"""
+ if dev in self._uuid:
+ return self._uuid[dev]
+
+ uuid = self.image.g.vfs_uuid(dev)
+ assert len(uuid)
+ self._uuid[dev] = uuid
+ return uuid
+