Show
Ignore:
Timestamp:
05/05/05 23:52:49 (20 years ago)
Author:
jerome
Message:

Improved stability in pykotme and pykotme.cgi
Now uses real userid instead of effective userid in pykotme and pykosd,
to allow user root to check his own account instead of user pykota's one
(since we drop priviledges early).
Better setup instructions for pykotme.cgi

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pykotme

    r2216 r2232  
    104104                self.printInfo(msg) 
    105105             
    106         # get current user 
    107         username = pwd.getpwuid(os.geteuid())[0] 
     106        printers = self.storage.getMatchingPrinters(options["printer"]) 
     107        if not printers : 
     108            raise PyKotaToolError, _("There's no printer matching %s") % options["printer"] 
     109             
     110        username = pwd.getpwuid(os.getuid())[0] 
    108111        user = self.storage.getUser(username) 
    109112        if user.Exists and user.LimitBy and (user.LimitBy.lower() == "balance"): 
    110113            print _("Your account balance : %.2f") % (user.AccountBalance or 0.0) 
    111114             
    112         printers = self.storage.getMatchingPrinters(options["printer"]) 
    113         if not printers : 
    114             raise PyKotaToolError, _("There's no printer matching %s") % options["printer"] 
    115              
    116115        print _("Job size : %i pages") % totalsize     
    117         for printer in printers : 
    118             userpquota = self.storage.getUserPQuota(user, printer) 
    119             cost = userpquota.computeJobPrice(totalsize) 
    120             print _("Cost on printer %s : %.2f") % (printer.Name, cost) 
     116        if user.Exists : 
     117            for printer in printers : 
     118                userpquota = self.storage.getUserPQuota(user, printer) 
     119                if userpquota.Exists : 
     120                    cost = userpquota.computeJobPrice(totalsize) 
     121                    print _("Cost on printer %s : %.2f") % (printer.Name, cost) 
    121122             
    122123if __name__ == "__main__" :