(self)
return userlist
This collects all the users with open files on the system, and filters
        based on the variables user_include and user_exclude
This collects all the users with open files on the system, and filters
        based on the variables user_include and user_exclude
This collects all the users with open files on the system and filters based on the variables user_include and user_exclude
def get_userlist(self):
        """
        This collects all the users with open files on the system, and filters
        based on the variables user_include and user_exclude
        """
    # convert user/group  lists to arrays if strings
        if isinstance(self.config['user_include'], basestring):
            self.config['user_include'] = self.config['user_include'].split()
        if isinstance(self.config['user_exclude'], basestring):
            self.config['user_exclude'] = self.config['user_exclude'].split()
        if isinstance(self.config['group_include'], basestring):
            self.config['group_include'] = self.config['group_include'].split()
        if isinstance(self.config['group_exclude'], basestring):
            self.config['group_exclude'] = self.config['group_exclude'].split()

        rawusers = os.popen("lsof | awk '{ print $3 }' | sort | uniq -d"
                            ).read().split()
        userlist = []

        # remove any not on the user include list
        if ((self.config['user_include'] is None or
             len(self.config['user_include']) == 0)):
            userlist = rawusers
        else:
            # only work with specified include list, which is added at the end
            userlist = []

        # add any user in the group include list
        addedByGroup = []
        if ((self.config['group_include'] is not None and
             len(self.config['group_include']) > 0)):
            for u in rawusers:
                self.log.info(u)
                # get list of groups of user
                user_groups = os.popen("id -Gn %s" % (u)).read().split()
                for gi in self.config['group_include']:
                    if gi in user_groups and u not in userlist:
                        userlist.append(u)
                        addedByGroup.append(u)
                        break

        # remove any user in the exclude group list
        if ((self.config['group_exclude'] is not None and
             len(self.config['group_exclude']) > 0)):
            # create tmp list to iterate over while editing userlist
            tmplist = userlist[:]
            for u in tmplist:
                # get list of groups of user
                groups = os.popen("id -Gn %s" % (u)).read().split()
                for gi in self.config['group_exclude']:
                    if gi in groups:
                        userlist.remove(u)
                        break

        # remove any that aren't within the uid limits
        # make sure uid_min/max are ints
        self.config['uid_min'] = int(self.config['uid_min'])
        self.config['uid_max'] = int(self.config['uid_max'])
        tmplist = userlist[:]
        for u in tmplist:
            if ((self.config['user_include'] is None or
                 u not in self.config['user_include'])):
                if u not in addedByGroup:
                    uid = int(os.popen("id -u %s" % (u)).read())
                    if ((uid < self.config['uid_min'] and
                         self.config['uid_min'] is not None and
                         u in userlist)):
                        userlist.remove(u)
                    if ((uid > self.config['uid_max'] and
                         self.config['uid_max'] is not None and
                         u in userlist)):
                        userlist.remove(u)

        # add users that are in the users include list
        if ((self.config['user_include'] is not None and
             len(self.config['user_include']) > 0)):
            for u in self.config['user_include']:
                if u in rawusers and u not in userlist:
                    userlist.append(u)

        # remove any that is on the user exclude list
        if ((self.config['user_exclude'] is not None and
             len(self.config['user_exclude']) > 0)):
            for u in self.config['user_exclude']:
                if u in userlist:
                    userlist.remove(u)

        return userlist
def get_userlist ( self ) : # convert user/group  lists to arrays if strings if isinstance ( self . config [ 'user_include' ] , basestring ) : self . config [ 'user_include' ] = self . config [ 'user_include' ] . split ( ) if isinstance ( self . config [ 'user_exclude' ] , basestring ) : self . config [ 'user_exclude' ] = self . config [ 'user_exclude' ] . split ( ) if isinstance ( self . config [ 'group_include' ] , basestring ) : self . config [ 'group_include' ] = self . config [ 'group_include' ] . split ( ) if isinstance ( self . config [ 'group_exclude' ] , basestring ) : self . config [ 'group_exclude' ] = self . config [ 'group_exclude' ] . split ( ) rawusers = os . popen ( "lsof | awk '{ print $3 }' | sort | uniq -d" ) . read ( ) . split ( ) userlist = [ ] # remove any not on the user include list if ( ( self . config [ 'user_include' ] is None or len ( self . config [ 'user_include' ] ) == 0 ) ) : userlist = rawusers else : # only work with specified include list, which is added at the end userlist = [ ] # add any user in the group include list addedByGroup = [ ] if ( ( self . config [ 'group_include' ] is not None and len ( self . config [ 'group_include' ] ) > 0 ) ) : for u in rawusers : self . log . info ( u ) # get list of groups of user user_groups = os . popen ( "id -Gn %s" % ( u ) ) . read ( ) . split ( ) for gi in self . config [ 'group_include' ] : if gi in user_groups and u not in userlist : userlist . append ( u ) addedByGroup . append ( u ) break # remove any user in the exclude group list if ( ( self . config [ 'group_exclude' ] is not None and len ( self . config [ 'group_exclude' ] ) > 0 ) ) : # create tmp list to iterate over while editing userlist tmplist = userlist [ : ] for u in tmplist : # get list of groups of user groups = os . popen ( "id -Gn %s" % ( u ) ) . read ( ) . split ( ) for gi in self . config [ 'group_exclude' ] : if gi in groups : userlist . remove ( u ) break # remove any that aren't within the uid limits # make sure uid_min/max are ints self . config [ 'uid_min' ] = int ( self . config [ 'uid_min' ] ) self . config [ 'uid_max' ] = int ( self . config [ 'uid_max' ] ) tmplist = userlist [ : ] for u in tmplist : if ( ( self . config [ 'user_include' ] is None or u not in self . config [ 'user_include' ] ) ) : if u not in addedByGroup : uid = int ( os . popen ( "id -u %s" % ( u ) ) . read ( ) ) if ( ( uid < self . config [ 'uid_min' ] and self . config [ 'uid_min' ] is not None and u in userlist ) ) : userlist . remove ( u ) if ( ( uid > self . config [ 'uid_max' ] and self . config [ 'uid_max' ] is not None and u in userlist ) ) : userlist . remove ( u ) # add users that are in the users include list if ( ( self . config [ 'user_include' ] is not None and len ( self . config [ 'user_include' ] ) > 0 ) ) : for u in self . config [ 'user_include' ] : if u in rawusers and u not in userlist : userlist . append ( u ) # remove any that is on the user exclude list if ( ( self . config [ 'user_exclude' ] is not None and len ( self . config [ 'user_exclude' ] ) > 0 ) ) : for u in self . config [ 'user_exclude' ] : if u in userlist : userlist . remove ( u ) return userlist