Changeset 2762
- Timestamp:
- 02/27/06 23:28:01 (19 years ago)
- Location:
- pykota/trunk
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/edpykota
r2761 r2762 27 27 import sys 28 28 import os 29 import pwd 30 import grp 31 import time 29 32 30 from pykota.tool import PyKotaTool, PyKotaToolError, PyKotaCommandLineError, crashed, N_ 33 31 from pykota.config import PyKotaConfigError … … 174 172 def main(self, names, options) : 175 173 """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) 189 175 suffix = (options["groups"] and "Group") or "User" 190 176 printernames = options["printer"].split(",") -
pykota/trunk/bin/pkusers
r2757 r2762 160 160 def main(self, names, options) : 161 161 """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) 165 163 suffix = (options["groups"] and "Group") or "User" 166 164 … … 230 228 self.display("\r100.00%%\r \r%s\n" % _("Done.")) 231 229 else : 232 if not names :233 names = ["*"]234 230 entries = getattr(self.storage, "getMatching%ss" % suffix)(",".join(names)) 235 231 if not entries : … … 407 403 elif options["remove"] and not options["ingroups"] : 408 404 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"]) : 410 406 raise PyKotaCommandLineError, _("You have to pass user or group names on the command line") 411 407 else : -
pykota/trunk/NEWS
r2760 r2762 23 23 24 24 - 1.24alpha15 : 25 26 - edpykota --list is now authorized to mere mortal users, but 27 restricts the list to the current user's information. 25 26 - 'edpykota --list' and 'pkusers --list' are now authorized 27 to mere mortal users, but the list is restricted to informations 28 about the current user. 28 29 29 30 - Extended the functionnality of the 'onbackenderror' directive to -
pykota/trunk/pykota/tool.py
r2692 r2762 220 220 return True 221 221 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 222 239 223 240 def display_version_and_quit(self) :