# $Id$ PyKota - Print Quota for CUPS (c) 2003-2004 Jerome Alet This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. ============================================================ PyKota NEWS : - 1.19alpha10 : - pykotme now uses generic PDL Analyzer directly instead of spawning a new process. - Improvements to generic PDL Analyzer. - 25% Speedup in PCL parser. Getting more of the Python version will probably be difficult, since the completely table driven parser I wrote is slower than the original algorithm. Then, the original algorithm is still used for now. Probable that more speed could be achieved using mmap, at the expense of severe memory consumption. - configuration simplifications : the "accounter" directive's 'hardware' arguments now accepts what was in the "requester" directive as it's content. The "requester" directive is not supported anymore. See sample configuration file for details. - 1.19alpha9 : - pkpgcounter is now just a wrapper around the PDLAnalyzer class - pykotaOptions LDAP attribute now accepts non-ascii characters too. - First try at cupspykota main loop rewrite - 1.19alpha8 : - 'querying' accounting method is now called 'hardware' - 'external' accounting method is now called 'software' - 'stupid' accounting method doesn't exist anymore - 'snmp' requester doesn't exist anymore - code simplifications in external requester - 1.19alpha7 : - Database schema change (both LDAP and PostgreSQL) to allow storage of the job-originating-hostname attribute. An SQL upgrade script is present. The code is not yet capable of setting/retrieving this attribute. Support for this functionnality will be added in the future. - 1.19alpha6 : - problems connecting to SMTP servers are now catched. - pykotme now uses pkpgcounter to compute the size of the job. This modification adds PCL5 and soon PCLXL (PCL6) support. You can now get quotes for PCL in addition to PostScript. - pkpgcounter now includes first try at PCLXL parser. It is currently disabled until it's finished. - 1.19alpha5 : - cupspykota polling loop fix for MacOSX (at least) - logging subsystem now logs PID too, to ease diagnosing problems under heavy load. - pkpgcounter enhancements. - pkprinters --skipexisting now tells pkprinters to not modify existing printers when --add is used. pkprinters logs a warning message whenever --add is used and a printer already exists. - LDAP schema now allows accented chars in pykotaFileName and pykotaTitle attributes. - 1.19alpha4 : - a bad copy&paste prevented pkpgcounter to work at all, this is now fixed. - improved PCL support in pkpgcounter, with the use of HP PCL/PJL Reference Set PCL5 Printer Language Technical Quick Reference Guide - pkpgcounter now uses mmap to speed things up : duration is halved with the sample 87 pages PCL document I use for testing. - 1.19alpha3 : - pkprinters now accepts the --list command line argument to list informations about printers. - 1.19alpha2 : - pkpgcounter is now included as a smart external accounter which can handle both PostScript and PCL. - 1.19alpha1 : - PYKOTALIMITBY environment variable is now exported too. - Inclusion of Michele Baldessari's work on autotools. - 1.18 : - Improved documentation - 1.18beta2 : - Fix for raw jobs with cupspykota - 1.18beta : - Small fix for new waitprinter.sh script - Better tracebacks on error conditions - Improved translations - Improved documentation - 1.18alpha15 : - waitprinter.sh replaced by a new and possibly faster and more powerful one. - Names can now begin with a digit. - Stability improvement for quotas set on printers groups. - 1.18alpha14 : - Catches more (all ?) problems with SMTP servers instead of breaking. - Italian translation added. - 1.18alpha13 : - Pre and Post hooks are now available in the pykota filter as well. - The pykota filter doesn't check last user's quota anymore when delayed hardware accounting is used : this will be done anyway the next time the last user will print again. This saves some database queries which are unneeded. - 1.18alpha12 : - Pre and Post hooks to external commands with many many environment variables available are useable from the cupspykota backend. See sample configuration file for details and help. - 1.18alpha11 : - Hopefully final fix wrt groups (users and printers) - 1.18alpha10 : - Fixed nested printer groups accounting. - Fixed user groups + printer groups problem. - 1.18alpha9 : - Fix for LDAP problem when job price was 0. - Fix for empty user groups with LDAP. - Preliminary version of the snmpprinterstatus command added. - 1.18alpha8 : - Don't retrieve data when not needed. This avoids many database queries. - 1.18alpha7 : - New experimental ldapcache directive to improve LDAP caching. - 1.18alpha6 : - New configuration directive added : maildomain to specify the domain to send mail to when user email address is not set in PyKota database. - More complete email message headers. - 1.18alpha5 : - Debian packaging specific files, contributed by Peter Hawkins are now included in the project's tree. - Preliminary work on future low-level LDAP caching to speed up modifications (at least). - 1.18alpha4 : - Applied some of the modifications suggested by Peter Hawkins, for better Debian integration. Most notably cupspykota, pykota, and the shell scripts are now installed into /usr/share/pykota instead of into /usr/bin BEWARE : double check that your symbolic link to cupspykota is correct, and that your pykota.conf file use correct path for the shell scripts like waitprinter.sh and al. - pkhint command added, to help in configuring correct accounting method for PyKota. - 1.18alpha3 : - Fixed a rare bug in cupspykota backend which gave incorrect "CUPS backend died abnormally" messages. - 1.18alpha2 : - Added the pkprinters command line tool to manage printers exclusively. - 1.18alpha1 : - Preliminary work on Relationnal Database Independance. - Sample report made from OpenOffice.org added as PDF and SXC. - 1.17 : - Finalized release. - 1.17alpha2 : - Fix stupid software accounting bug in the CUPS backend. - 1.17alpha1 : - User/Group deletion code in edpykota rewritten. - 1.16 : - Preliminary documentation on how to use OpenOffice.org to create personnalized reports for PyKota + PostgreSQL. - Spanish installation guide for CUPS+PyKota+PostgreSQL added to the documentation. Doesn't yet document v1.16 though. - Portuguese Portuguese translation replaces Brasilian Portuguese Translation. Brasilian portuguese translation is still available under the 'br' locale. - 1.16beta3 : - Swedish translation added. - Small fix in documentation. - 1.16beta2 : - Small fix for job cancelling code while job already printing in CUPS backend. - Big fix wrt printing policies for unknown users. - 1.16beta1 : - Manpages upgraded. - 1.16alpha26 : - Job price is now computed like this : SUM((NbPages * PricePerPage) + PricePerJob) For current printer and all the printers groups it is a member of, if any. This may be difficult to grasp, but offers unprecedented flexibility. - 1.16alpha25 : - Email address can be set at user creation time, using the following syntax : $ edpykota --add username/email@yourdomain.com - 1.16alpha24 : - CGI script now can show the printing history. - Bug wrt number of copies should be fixed. - Major code refactoring => It is now possible to automatically add printers on first print. - 1.16alpha23 : - Fixed potential accuracy problem if a user printed on several printers at the very same time. - 1.16alpha22 : - edpykota now allows adding printers to printer groups - 1.16alpha21 : - Allows the dot in user and printer names. - Printer groups are now cached too. - 1.16alpha20 : - Fixed several small bugs with the help of PyChecker. - 1.16alpha19 : - Fixed a bug in PostgreSQL backend's code. - 1.16alpha18 : - Initial code for printer groups support. Printer groups have to be added with external tools like psql or gq for example. Printer groups seems to work fine with users. Untested with user groups for now. - Several minor visual problems fixed in reports. - Fixed a bug in LDAP date handling. - Fix for LDAP problem with some combination of OpenLDAP + Python-LDAP + some particular settings. - mailandpopup.sh shell script added. See sample configuration file for details. - Several environment variables are now exported when executing external commands (accounters, requesters, mailers) : PYKOTAUSERNAME => user who is printing PYKOTAPRINTERNAME => printer on which the job is being sent PYKOTATITLE => Job's title PYKOTAFILENAME => Job's filename PYKOTACOPIES => number of copies asked PYKOTAOPTIONS => print command options (-o with CUPS) - 1.16alpha17 : - Added portugues translation. - Major code refactoring in accounters. - 1.16alpha16 : - Code refactoring, and addition of a real HTML reporter, to have nice looking and useful web based reports (in the future). - Added utolower configuration option to convert all usernames to lowercase during printing. - 1.15alpha15 : - Now includes the papwaitprinter.sh shell script to wait for AppleTalk enabled printers. - 1.16alpha14 : - Now printing on a printer not defined in the Quota Storage, results in the job being cancelled or stopped, depending on the printing system. - 1.16alpha13 : - Small bugfix wrt Python v2.1 - If username is an empty string, user root is assumed. - 'postgresql' is not recognized anymore as a storage backend, you have to use 'pgstorage' instead. 'postgresql' used to be supported for compatibility with very old PyKota versions, this is not the case anymore. - 1.16alpha12 : - Job price added to job history, to keep accounting correct if a printer price per page or per job is modified and the history is not reset : the history would have given a false amount of money charged before the printer's prices were modified, this addition solves the problem. - 1.16alpha11 : - Some preliminary modifications to the database structure for PostgreSQL and OpenLDAP. A script to upgrade a PostgreSQL database is now provided. LDAP attributes now support eq, pres and sub indexes. - Job history now contains additional informations : number of copies, filename, title and print options. - 1.16alpha10 : - Some modifications done to external policy handling. See sample configuration file for details. - Spanish translation added. - 1.16alpha9 : - mailto can be set to external(...) to warn users above quota with any command of your choice (e.g. linpopup). Several parameters are available, see sample configuration file for details. - 1.16alpha8 : - Now cupspykota transmits SIGTERMS to the original backend when the user deletes a job being processed. - The documentation is now licensed under the terms of the GNU GPL too. - 1.16alpha7 : - The CUPS backend is now fully functionnal (it seems). - From now on, the use of the pykota filter with CUPS is deprecated. The pykota filter still has to be used with LPRng though. - 1.16alpha6 : - Bug fixed : when edpykota was used to add a printer with no user or group name, a bad user/group name "*" was added to the database. - 1.16alpha5 : - New CUPS backend supports device enumeration ! This means that NO manual CUPS configuration has to be done. All can now be done from CUPS web interface. - 1.16alpha4 : - New CUPS backend added. - 1.16alpha3 : - Minimal FAQ document added. - 1.16alpha2 : - CGI script now partially supports browser's language preference - 1.16alpha1 : - Ensures that the LDAP connection is really closed at end. - More complete error messages in case of LDAP operation failure. - 1.15 : - Documentation improved. - 1.15beta : - Command line tools now accept multiple printer names or wildcards, separated with commas. - 1.15alpha9 : - External policy can be used to auto-add unknown users and any other interesting things you may want to do. WARNING : You can't auto-add printers for now. They have to be created manually before. Look at sample configuration file for examples. - 1.15alpha8 : - Job history can be disabled if needed. This feature may be useful for people who use the LDAP backend and don't want their LDAP tree to grow out of control. - 1.15alpha7 : - More work done on caching wrt groups. - 1.15alpha6 : - Performance bottleneck with LDAP solved. - 1.15alpha5 : - Caching mechanism for all database queries. - 1.15alpha4 : - Problem with Python 2.3 fixed. Needs some definitive modification. - 1.15alpha3 : - CGI script now tries to restrict view when the REMOTE_USER environment variable is set. This allows people to protect its use with .htaccess files. When unprotected, or if REMOTE_USER is 'root', then unrestricted access is granted. NB : REMOTE_USER is automatically set by the web server (e.g. Apache) when a page with restricted access is viewed. - 1.15alpha2 : - Better detection of LPRng. - Outputs a warning if printing system is unknown. - 1.15alpha1 : - Bug fix in SQL code. - 1.14 : - The PostgreSQL database connection is now always closed before exit. The LDAP database connection too, but it didn't suffer from the problem anyway, AFAICT. - 1.14beta2 : - An LDAP-specific configuration field was introduced, usermail. Use it to specify which LDAP attribute contains a valid email address for the user. See sample configuration file for details. - 1.14beta : - Two new LDAP-specific configuration fields were introduced, newuser and newgroup. Use them to specify if you want to add quota information to existing entries or elsewhere. See sample configuration file for details. - 1.14alpha9 : - Documentation improved. - pykotme now also prints the user's account balance value if the user is registered in the Quota Storage and his limiting factor is "balance". - 1.14alpha8 : - bin/waitprinter.sh is now included to wait for SNMP enabled printers to be idle again before asking for their internal page counter. See sample configuration file for details. - 1.14alpha7 : - edpykota now doesn't check if the user/group is above quota. The check is only done at print time. This prevents the sending of email messages when creating user quotas if quota is already reached at creation time. - 1.14alpha6 : - Configuration file split and moved to /etc/pykota/pykota.conf and /etc/pykota/pykotadmin.conf to prevent simple users to have Read/Write access to the Quota Database. Don't forget to : $ chmod 640 /etc/pykota/pykotadmin.conf - storageuser and storageuserpw configuration fields reintroduced for the same reason. - Code cleaning for future implementation of email addresses support in the PostgreSQL and LDAP backends. - 1.14alpha5 : - Big bug fixed when changing the prices for a printer - 1.14alpha4 : - When adding an user, the user itself and its account balance are now added in the same LDAP entry. Before they were added as two different LDAP entries. - 1.14alpha3 : - Email field added to PostgreSQL database. An upgrade script is included in initscripts/postgresql. - 1.14alpha2 : - Typo fixed when using the --prototype option to edpykota - 1.14alpha1 : - Poor man's treshold included : users with a low account balance (below 1.0 by default, configurable) are sent a warning message. - All warning messages to users are now configurable. NB : Warning messages to the administrator are not. - 1.13 : - Some small fixes wrt group handling. - The whole module code was passed through PyChecker and several small code inconsistencies were fixed, as well as a bug in the groups code. - 1.13alpha1 : - Bug fix wrt LDAP. - 1.12 : - More complete test added in edpykota. - 1.12alpha2 : - The previous bug fix was incomplete. This is corrected. - 1.12alpha1 : - Small bug fix. - 1.11 : - Now includes the pykotme command line tool, to produce printing quotes for users. - 1.10 : - Bug fixed wrt quota reports when print limiting is by account balance. - 1.09 : - Translations finalized. - Manpages updated. - Installation documentation improved wrt LDAP support. - 1.09beta2 : - The CGI script for quota reports works again, and is much more powerful. - 1.09beta : - edpykota finalized - 1.09alpha2 : - LDAP schema modified a bit. Please upgrade. - LDAP backend works ! - repykota and warnpykota allow the root user to pass users or groups names on the command line. Users and groups names may contain wildcards. - repykota and warnpykota only reports or warns the current user when launched by non-root users. - Minor bug fixes. - 1.09alpha1 : - More work on LDAP storage backend. Many options were added to /etc/pykota.conf to give some hints to the LDAP storage backend. - Severe database access optimizations were done by rewriting most of the Quota Storage backends drivers. - 1.08 : - Major bug fix wrt LPRng support for remote jobs. - Major bug fix wrt increase/decrease account balances. - 1.08alpha8 : - Code refactoring. - A single user/password pair is used to connect to the database backend. The storageuser configuration field, and its associated passwords storageuserpw, are not used anymore. - You can now set PyKota in debug mode, see sample configuration file for details. WARNING : only Quota Storage backend queries are logged in debug mode, for now. - 1.08alpha7 : - Very latest LDAP schema. - Code enhancement wrt easy pluggability of PyKota attributes and object classes into an existing LDAP directory. - 1.08alpha6 : - Minor bug corrections - More work on LDAP : new schema - 1.08alpha5 : - More good work on LDAP storage. repykota now works reasonably well with the sample LDAP directory. - 1.08alpha4 : - LDAP schema included. THIS IS JUST FOR PEOPLE TO DISCUSS ABOUT THIS. LDAP SUPPORT DOESN'T WORK YET, AND THE SCHEMA MAY CHANGE IN THE FUTURE. PLEASE TELL US WHAT YOU THINK ABOUT THIS SCHEMA ON THE MAILING LIST. - 1.08alpha3 : - External accounting methods were partly rewritten : - No more "broken pipe" should happen. - They now take care of the number of copies This may be unneeded though, if the postscript file already does this, because this would overcharge users (number of copies counted two times). NEEDS MORE TESTING. - The sample configuration file now contains an external accounting method example which should work with all DSC compliant Postscript files. - Some small bugs were fixed. - 1.08alpha2 : - Now works with net-snmp v5.0 and above. It already worked, but the sample configuration file didn't contain appropriate values... - 1.07 : Release of the Shame ! - The external accounting methods driver was left out of the CVS tree. Nobody could use it since it wasn't included ! - 1.06 : - Severe bug fixed : if you had a printer in power saving state which couldn't answer immediately, a bug was triggered. It was caused by a bad copy/paste which forgot to import a Python module at run time. - 1.05 : - External accounters are finally available ! This means that you can plug any page accounting method you like by setting the appropriate 'accounter' field in /etc/pykota.conf See the sample conf/pykota.conf.sample to learn how to do. NB : Both 'external' and 'stupid' accounting methods account a job size just before *this* job is sent to the printer. The original 'querying' method accounts a job size just before *the next* job is sent to the printer. - 1.05alpha3 : - A 'stupid' and unreliable accounting method was implemented to serve as an example on how to do this sort of things. This method only counts the 'showpage' statements in the input data. See sample configuration file for details. Pluggable accounting methods work, but I advise you TO NOT USE THIS ONE WHICH IS JUST AN EXAMPLE. It is not reliable enough to be used. Use the 'querying' accounting method instead. - 1.05alpha2 : - Pluggable accounting methods. - Better error handling. - 1.05alpha1 : - SECURITY file added to help improve PyKota's security. - Extracting the printer's internal page counter is now tried several times, waiting several seconds between two tries. This lets the time to warm up for some printers which don't answer when they are sleeping (my Apple LaserWriter 16/600 PS is in this case, maybe others too) - Small display bug fixed in repykota - 1.04 : - Default print policy for users/groups unknown from the print quota system is now DENY instead of ALLOW, since ALLOW can generate inaccurate results (incorrect job sizes charged to the wrong persons) - LPRng support works ! - A bug was introduced some time ago wrt printers' default policy for unknown users. It is now corrected. - repykota now displays prices per job and per page for each printer, if they are defined. - Minor display bug fixed in repykota. - Problem when running repykota with an empty database was fixed. - 1.03 : - Upgrade script included for earlier versions. Please look inside the initscripts subdirectory. THE DATABASE SCHEMA HAS CHANGED, PLEASE UPGRADE. - repykota now reports account balances too. - PyKota now has a nice logo, see the logos subdirectory. - Manual pages were finally updated. - Group quotas seem to work now ! - The new database schema allows to keep an history of all jobs as well as charge users per page and/or per job, and track users' account balance. - edpykota now accepts much more command line options to use the new functionnalities. See edpykota --help for details. - The installation script now allows to install the sample configuration file during first installation. - More group quota code works, but still not finished. - The CGI script displays a link to PyKota's website. - The job history is now kept, this will allow per-period reports in the future. - After having modified the quota for an user with edpykota, a quota check is done to eventually warn the user/admin about a quota which is too low to print. - A workaround is provided for HP Printers : their internal page counter is only saved to NVRAM in a 10 increment, so if you switch them off and then on, the reported page counter may be lower than the real number of pages printed. See http://web.mit.edu/source/third/lprng/doc/LPRng-HOWTO-15.html We unconditionnally set the last job's page count to abs(int((10 - abs(lastcounter(snmp) - lastcounter(storage)) / 2)) in this case. For a more accurate accounting, never switch your HP printers off. - A fix is provided for printers which only have a volatile page counter (reset to 0 every time you switch the printer on) This should allow PyKota to work reasonably fine with HP Laserjet 4L/5L/6L, not perfect, but better than nothing. See http://web.mit.edu/source/third/lprng/doc/LPRng-HOWTO-15.html For a more accurate accounting, never switch your HP printers off. This is untested, please report any problem. - A bug was fixed when edpykota --add was used with users who already had a quota on the specified printer. - A small display bug in repykota was introduced in preliminary 1.03 versions, and fixed later on. - Some minor bugs which happened in rare situations were fixed. - Support for AppleTalk printers was added, see sample configuration file for details. - Users and group printing can now be controlled (limited) either by print quota or by account balance. - 1.02 : - The installation script now checks for software availability and in case a software is missing asks the user if he wants to continue with the installation or abort it. - The configuration file pykota.conf is now expected to be found in /etc instead of in /etc/cups The installation script prompts the user to see if he wants to move an old configuration file to the new location if needed. - Improved documentation. - You can now set the tcp/ip port on which the Quota Storage Server is listening, see sample configuration file for details. - Better general error handling. - Upgrade script for pre 1.01 PostgreSQL database schema is now included as well. - 1.01 : - The configuration file now accepts an option to choose the recipient(s) of the email messages : - DevNull means no one will receive them. - User means only the user will receive them. - Admin means only the admin will receive them. - Both means the User and the Admin will receive them. - The configuration file now uses hard-coded default values when an option is not set. See sample configuration file for details. - Manual pages are included since 1.00, but I forgot to add this information to this file. - Redistribution terms for the official package have softened and are now fully GPL compatible : unrestricted modification is now allowed even for the version number. - 1.00 : - edpykota now accepts a --noquota option. This disable quota checking while still doing page accounting. This is really useful for people who don't want to limit their users but want to know how much pages they print. - Some untested scripts were added to retrieve the life time page counter of non-SNMP printers. - Every directory now has a specific README file. - 0.99 : - Under some circumstances while the user wasn't allowed to print, he didn't receive any email message. It is now fixed. - When an user wasn't allowed to print, the quota for the previous user wasn't updated. This is now fixed. - 0.98 : - Correctly handle the case where the printer is switched off. - Small bug wrt syslog fixed. - 0.97 : - edpykota accepts wildcards on its command line for users/groups too if the --add option is not set, e.g. : $ edpykota --printer lp --softlimit 50 --hardlimit 100 "jer*" - If no user name is passed at all, then a default wildcard of "*" which means apply the command on ALL users for this printer is used. - Small bug fixes. - 0.96 : - Options requester, policy, admin, adminmail and gracedelay can now be set either globally or per printer. The printer option has priority if both are defined. - More powerful configuration parser. - If all options are defined globally, there's no need to define a section for each printer in the configuration file anymore. Just define a [global] section and it's ok. - 0.95 : - External requesters for printers finally added. - Full internationalization (english and french are supported) - More complete quota usage report - CGI script to access to the quota usage report - Several bugs fixed. - 0.9 : - First public version