Changeset 2232

Show
Ignore:
Timestamp:
05/05/05 23:52:49 (19 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

Location:
pykota/trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pykosd

    r2216 r2232  
    117117        savecolor = color 
    118118         
    119         uname = pwd.getpwuid(os.geteuid())[0] 
     119        uname = pwd.getpwuid(os.getuid())[0] 
    120120        while 1 : 
    121121            color = savecolor 
  • 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__" :  
  • pykota/trunk/cgi-bin/pykotme.cgi

    r2229 r2232  
    145145                try :     
    146146                    user = self.storage.getUser(remuser) 
    147                     for printer in printers : 
    148                         upquota = self.storage.getUserPQuota(user, printer) 
    149                         cost = upquota.computeJobPrice(jobsize) 
    150                         self.body += "<p>%s</p>" % (_("Cost on printer %s : %.2f") % (printer.Name, cost)) 
     147                    if user.Exists : 
     148                        for printer in printers : 
     149                            upquota = self.storage.getUserPQuota(user, printer) 
     150                            if upquota.Exists : 
     151                                cost = upquota.computeJobPrice(jobsize) 
     152                                self.body += "<p>%s</p>" % (_("Cost on printer %s : %.2f") % (printer.Name, cost)) 
    151153                except : 
    152154                    self.body += '<p><font color="red">%s</font></p>' % self.crashed("CGI Error").replace("\n", "<br />") 
  • pykota/trunk/cgi-bin/README

    r2153 r2232  
    2525Be sure to restrict access to these CGI scripts as necessary. 
    2626 
    27 For now, pykotme.cgi doesn't need any restriction. 
    28  
    2927If you protect access to printquota.cgi or dumpykota.cgi with  
    3028username+password authentication, the REMOTE_USER CGI environment variable 
     
    3533If no username+password authentication takes place, then access 
    3634is completely unrestricted. 
     35 
     36If you don't protect access to pykotme.cgi with username+password 
     37authentication, then only the job's size will be displayed 
     38to you. This is due to the cost of a print job on a particular printer 
     39depending on the user because of the overcharging factor's value.  
     40So if you want pykotme.cgi to produce complete web quotes, you must  
     41ensure that the user logs in from his web browser whenever he uses  
     42this CGI script. 
    3743 
    3844You must ensure that the user your web server runs as can read 
  • pykota/trunk/NEWS

    r2229 r2232  
    2424    - 1.22beta : 
    2525     
     26        - Improved stability in pykotme and pykotme.cgi. 
     27         
     28        - Fixed a permission problem in pykotme and pykosd. 
     29         
    2630        - Fixed an inconsitency between SQL and LDAP backends' 
    2731          behavior in edpykota.