Changeset 2393
- Timestamp:
- 07/28/05 17:58:30 (19 years ago)
- Location:
- pykota/trunk
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r2389 r2393 227 227 (bcode, clienthost) = self.getJobInfosFromPageLog(cupsdconf, printer.Name, user.Name, self.jobid) 228 228 self.logdebug("Client Hostname : %s" % (clienthost or "Unknown")) 229 230 bcode = self.overwrittenBillingCode or bcode 229 231 self.logdebug("Billing Code : %s" % (bcode or "None")) 230 232 … … 299 301 billingcode = None 300 302 303 # Should we cancel the job in any case (because job ticket 304 # was overwritten) ? 305 if self.mustDeny : 306 action = "DENY" 307 301 308 # exports some new environment variables 302 309 os.environ["PYKOTAACTION"] = action -
pykota/trunk/NEWS
r2390 r2393 22 22 PyKota NEWS : 23 23 24 - 1.23alpha20 : 25 26 - Added the overwrite_jobticket directive. See pykota.conf.sample 27 for how to use it. 28 24 29 - 1.23alpha19 : 25 30 -
pykota/trunk/pykota/tool.py
r2347 r2393 665 665 self.username = self.username or pwd.getpwuid(os.geteuid())[0] # use CUPS' user when printing test page from CUPS web interface, otherwise username is empty 666 666 667 (newusername, newbillingcode, newaction) = self.overwriteJobTicket() 668 if newusername : 669 self.printInfo(_("Job ticket overwritten : new username = [%s]") % newusername) 670 self.username = newusername 671 if newbillingcode : 672 self.printInfo(_("Job ticket overwritten : new billing code = [%s]") % newbillingcode) 673 self.overwrittenBillingCode = newbillingcode 674 else : 675 self.overwrittenBillingCode = None 676 if newaction : 677 self.printInfo(_("Job ticket overwritten : job will be denied (but a bit later).")) 678 self.mustDeny = 1 679 else : 680 self.mustDeny = 0 681 667 682 # do we want to strip out the Samba/Winbind domain name ? 668 683 separator = self.config.getWinbindSeparator() … … 696 711 self.logdebug("Capturing SIGTERM events.") 697 712 signal.signal(signal.SIGTERM, self.sigterm_handler) 713 714 def overwriteJobTicket(self) : 715 """Should we overwrite the job's ticket (username and billingcode) ?""" 716 jobticketcommand = self.config.getOverwriteJobTicket(self.printername) 717 if jobticketcommand is not None : 718 username = billingcode = action = None 719 self.logdebug("Launching subprocess [%s] to overwrite the job's ticket." % jobticketcommand) 720 inputfile = os.popen(jobticketcommand, "r") 721 for line in inputfile.xreadlines() : 722 line = line.strip() 723 if line == "DENY" : 724 self.logdebug("Seen DENY command.") 725 action = "DENY" 726 elif line.startswith("USERNAME=") : 727 username = line.split("=", 1)[1].strip() 728 self.logdebug("Seen new username [%s]" % username) 729 action = None 730 elif line.startswith("BILLINGCODE=") : 731 billingcode = line.split("=", 1)[1].strip() 732 self.logdebug("Seen new billing code [%s]" % billingcode) 733 action = None 734 inputfile.close() 735 return (username, billingcode, action) 736 else : 737 return (None, None, None) 698 738 699 739 def sendBackChannelData(self, message, level="info") : -
pykota/trunk/pykota/version.py
r2389 r2393 22 22 # 23 23 24 __version__ = "1.23alpha 19_unofficial"24 __version__ = "1.23alpha20_unofficial" 25 25 26 26 __doc__ = "PyKota : a complete Printing Quota Solution for CUPS and LPRng." -
pykota/trunk/TODO
r2376 r2393 33 33 - Add the listing of the member printers in pkprinters if the printer 34 34 is a printer group. 35 36 - Add a new external hook to allow the overwriting of the job's ticket37 (mainly username and billing code) at startup time :38 39 1 - hook is launched and can do whatever it wants, like asking40 the user for username+password or billing code41 42 2 - hook prints any (or all) of :43 44 USER:some_username45 BILLING:some_billingcode46 DENY47 48 if hook doesn't print anything, job processed as usual.49 if DENY, job is rejected.50 51 3 - if billing code or username is invalid, and if PyKota52 is configured to loop in this case, hook is launched53 again, otherwise job is rejected.54 55 4 - if billing code and/or username is valid, the job's56 billing code and/or username are overwritten with57 these values, and PyKota processes the job as usual.58 35 59 36 - Allow several levels of administrative priviledges by allowing