Revision 5886f568 image_creator/os_type/unix.py

b/image_creator/os_type/unix.py
48 48
        '.thunderbird'
49 49
    ]
50 50

  
51
    def get_metadata(self):
52
        meta = super(Unix, self).get_metadata()
53
        meta["USERS"] = " ".join(self.get_passworded_users())
54
        return meta
51
    def __init__(self, rootdev, ghandler):
52
        super(Unix, self).__init__(rootdev, ghandler)
55 53

  
56
    def get_passworded_users(self):
54
        self.meta["USERS"] = " ".join(self._get_passworded_users())
55

  
56
    def _get_passworded_users(self):
57 57
        users = []
58 58
        regexp = re.compile('(\S+):((?:!\S+)|(?:[^!*]\S+)|):(?:\S*:){6}')
59 59

  
......
80 80
        # Remove users from /etc/passwd
81 81
        passwd = []
82 82
        removed_users = {}
83
        metadata_users = self.meta['USERS'].split()
83 84
        for line in self.g.cat('/etc/passwd').splitlines():
84 85
            fields = line.split(':')
85 86
            if int(fields[2]) > 1000:
86 87
                removed_users[fields[0]] = fields
88
                # remove it from the USERS metadata too
89
                if fields[0] in metadata_users:
90
                    metadata_users.remove(fields[0])
87 91
            else:
88 92
                passwd.append(':'.join(fields))
89 93

  
94
        self.meta['USERS'] = " ".join(metadata_users)
90 95
        self.g.write('/etc/passwd', '\n'.join(passwd) + '\n')
91 96

  
92 97
        # Remove the corresponding /etc/shadow entries

Also available in: Unified diff