Show
Ignore:
Timestamp:
02/27/06 23:28:01 (18 years ago)
Author:
jerome
Message:

Make pkusers --list behave like edpykota --list : allowed to normal users,
but restricted in what can be seen.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/tool.py

    r2692 r2762  
    220220                    return True 
    221221            return False 
     222         
     223    def sanitizeNames(self, options, names) : 
     224        """Ensures that an user can only see the datas he is allowed to see, by modifying the list of names.""" 
     225        if not self.config.isAdmin : 
     226            username = pwd.getpwuid(os.geteuid())[0] 
     227            if not options["list"] : 
     228                raise PyKotaCommandLineError, "%s : %s" % (username, _("You're not allowed to use this command.")) 
     229            else : 
     230                if options["groups"] : 
     231                    user = self.storage.getUser(username) 
     232                    if user.Exists : 
     233                        return [ g.Name for g in self.storage.getUserGroups(user) ] 
     234                return [ username ] 
     235        elif not names :         
     236            return ["*"] 
     237        else :     
     238            return names 
    222239         
    223240    def display_version_and_quit(self) :