'Identify anomalies in the password/shadow and group/gshadow data.'

def FindAnomalies(self):

    findings = []
    group_entries = {g.gid for g in self.groups.itervalues()}
    for gid in (set(self.gids) - group_entries):
        undefined = ','.join(self.gids.get(gid, []))
        findings.append(('gid    %d    assigned    without    /etc/groups    entry:    %s' % (gid, undefined)))
    if findings:
        (yield self._Anomaly('Accounts    with    invalid    gid.', findings))
    findings = []
    for (uid, names) in self.uids.iteritems():
        if (len(names) > 1):
            findings.append(('uid    %d    assigned    to    multiple    accounts:    %s' % (uid, ','.join(sorted(names)))))
    if findings:
        (yield self._Anomaly('Accounts    with    shared    uid.', findings))
    findings = []
    root_grp = self.groups.get('root')
    if root_grp:
        root_members = sorted([m for m in root_grp.members if (m != 'root')])
        if root_members:
            findings.append(("Accounts    in    'root'    group:    %s" % ','.join(root_members)))
    if findings:
        (yield self._Anomaly('Privileged    group    with    unusual    members.', findings))
    diffs = self.MemberDiff(self.entry, 'passwd', self.shadow, 'shadow')
    if diffs:
        (yield self._Anomaly('Mismatched    passwd    and    shadow    files.', diffs))
