- 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 = []
- regexp = re.compile('(\S+):((?:!\S+)|(?:[^!*]\S+)|):(?:\S*:){6}')
-
- for line in self.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
-
- @sysprep(enabled=False)
- def remove_user_accounts(self, print_header=True):
- """Remove all user accounts with id greater than 1000"""
-
- if print_header:
- 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 = {}
- metadata_users = self.meta['USERS'].split()
- for line in self.g.cat('/etc/passwd').splitlines():
- fields = line.split(':')
- if int(fields[2]) > 1000:
- removed_users[fields[0]] = fields
- # remove it from the USERS metadata too
- if fields[0] in metadata_users:
- metadata_users.remove(fields[0])
+ def _mountpoints(self):
+ """Return mountpoints in the correct order.
+ / should be mounted before /boot or /usr, /usr befor /usr/bin ...
+ """
+ mps = self.image.g.inspect_get_mountpoints(self.root)
+
+ def compare(a, b):
+ if len(a[0]) > len(b[0]):
+ return 1
+ elif len(a[0]) == len(b[0]):
+ return 0