8.2. Web based Print Quota reports

PyKota also features a CGI script to remotely access to print quota reports with a web browser, it is called printquota.cgi and you can put it in your web server's cgi-bin directory if a web server is installed on any machine on which PyKota is also installed and configured correctly.

You may also want to copy the CSS stylesheets which are present in the stylesheets/ directory to your web server's DocumentRoot (e.g. /var/lib/www) so that the CGI script can find them to present a nicer web interface.

You can find printquota.cgi in the pykota/cgi-bin directory. Here's how to install it, provided that your web server's cgi-bin directory is /usr/lib/cgi-bin :

      
port50-2:/home/jerome/pykota$ cp cgi-bin/printquota.cgi /usr/lib/cgi-bin
port50-2:/home/jerome/pykota$ chmod 755 /usr/lib/cgi-bin/printquota.cgi

NoteNote
 

Please ensure that the user your web server is run as, for example www-data under Debian, is allowed to read ~pykota/pykota.conf but for security reasons you must ensure that this user is not allowed to read ~pykota/pykotadmin.conf

If you install the CGI script as described above, any user will be allowed to view the complete print quota report, for all users, groups and printers. This is then a different behavior compared to when a normal user wants a print quota report from the command line through repykota. If you find this disturbing, then the best is to ask for user authentication whenever the printquota.cgi CGI script is accessed. This CGI script will then automatically behave as expected, showing in the print quota report only what the authenticated user is allowed to see, just like when he launches repykota from the command line. As a special case, if the user authenticates using the root username, then there's no restriction on what may appear on the print quota report.

To automatically ask for an authentication dialog whenever the CGI script is accessed, you have to configure your web server to do so. If your webserver is Apache, then it's relatively easy. First you have to put printquota.cgi in its own subdirectory below your web server's cgi-bin directory, for example in cgi-bin/PyKota/. Then use the htpasswd command line tool to create a file which contains usernames and passwords for all your users allowed to see the print quota report from a web browser, and put this file outside of the directories served by Apache so that nobody could retrieve it. Finally create a file named .htaccess in cgi-bin/PyKota/ with appropriate content in it. This file should tell Apache to automatically ask for an authentication whenever something from this directory is accessed, and to use the password file previously created to match usernames and passwords. You may also have to tweak Apache's default configuration to allow the authentication mechanism.

The detailed procedure to do all this is out of the scope of the present document, please refer to Apache's documentation for all the gory details.