Changeset 2762 for pykota/trunk/bin

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.

Location:
pykota/trunk/bin
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/edpykota

    r2761 r2762  
    2727import sys 
    2828import os 
    29 import pwd 
    30 import grp 
    31 import time 
     29 
    3230from pykota.tool import PyKotaTool, PyKotaToolError, PyKotaCommandLineError, crashed, N_ 
    3331from pykota.config import PyKotaConfigError 
     
    174172    def main(self, names, options) : 
    175173        """Edit user or group quotas.""" 
    176         if not self.config.isAdmin : 
    177             username = pwd.getpwuid(os.geteuid())[0] 
    178             if not options["list"] : 
    179                 raise PyKotaCommandLineError, "%s : %s" % (username, _("You're not allowed to use this command.")) 
    180             else : 
    181                 names = [ username ] 
    182                 if options["groups"] : 
    183                     user = self.storage.getUser(username) 
    184                     if user.Exists : 
    185                         names = [ g.Name for g in self.storage.getUserGroups(user) ] 
    186         elif not names :         
    187             names = ["*"] 
    188              
     174        names = self.sanitizeNames(options, names) 
    189175        suffix = (options["groups"] and "Group") or "User"         
    190176        printernames = options["printer"].split(",") 
  • pykota/trunk/bin/pkusers

    r2757 r2762  
    160160    def main(self, names, options) : 
    161161        """Manage users or groups.""" 
    162         if not self.config.isAdmin : 
    163             raise PyKotaCommandLineError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command.")) 
    164              
     162        names = self.sanitizeNames(options, names) 
    165163        suffix = (options["groups"] and "Group") or "User"         
    166164         
     
    230228                self.display("\r100.00%%\r        \r%s\n" % _("Done.")) 
    231229            else :         
    232                 if not names : 
    233                     names = ["*"] 
    234230                entries = getattr(self.storage, "getMatching%ss" % suffix)(",".join(names)) 
    235231                if not entries : 
     
    407403        elif options["remove"] and not options["ingroups"] :     
    408404            raise PyKotaCommandLineError, _("You have to pass user groups names on the command line") 
    409         elif (not args) and options["add"] : 
     405        elif (not args) and (options["add"] or options["delete"]) : 
    410406            raise PyKotaCommandLineError, _("You have to pass user or group names on the command line") 
    411407        else :