1*5e7646d2SAndroid Build Coastguard Worker<!DOCTYPE html> 2*5e7646d2SAndroid Build Coastguard Worker<html> 3*5e7646d2SAndroid Build Coastguard Worker<!-- SECTION: Getting Started --> 4*5e7646d2SAndroid Build Coastguard Worker <head> 5*5e7646d2SAndroid Build Coastguard Worker <title>Using CGI Programs</title> 6*5e7646d2SAndroid Build Coastguard Worker <link rel="stylesheet" type="text/css" href="../cups-printable.css"> 7*5e7646d2SAndroid Build Coastguard Worker </head> 8*5e7646d2SAndroid Build Coastguard Worker <body> 9*5e7646d2SAndroid Build Coastguard Worker <h1 class="title">Using CGI Programs</h1> 10*5e7646d2SAndroid Build Coastguard Worker 11*5e7646d2SAndroid Build Coastguard Worker <p>CUPS provides a dynamic web interface through dedicated CGI programs that are executed when users open special directories on the CUPS server. Each CGI performs administration, class, help, job, and printer functions as directed by the user, but the actual programs that are run and functions that are available are limited to those that were originally designed into the scheduler.</p> 12*5e7646d2SAndroid Build Coastguard Worker 13*5e7646d2SAndroid Build Coastguard Worker <p>CUPS also supports CGI scripts/programs for pages you want to provide, although this functionality is disabled by default. The "application/x-httpd-cgi" MIME media type is used to identify CGI content and can be associated with any filename extension. The scheduler requires CGI content to have the execute bit set, not have world or group write permissions, and any CGI scripts need to include a <tt>#!</tt> line as the first line of a script to identify the script interpreter. For example, a PHP script would look like:</p> 14*5e7646d2SAndroid Build Coastguard Worker 15*5e7646d2SAndroid Build Coastguard Worker <pre class="example"> 16*5e7646d2SAndroid Build Coastguard Worker#!/usr/bin/php -fn 17*5e7646d2SAndroid Build Coastguard Worker<?php 18*5e7646d2SAndroid Build Coastguard Worker... 19*5e7646d2SAndroid Build Coastguard Worker?> 20*5e7646d2SAndroid Build Coastguard Worker</pre> 21*5e7646d2SAndroid Build Coastguard Worker 22*5e7646d2SAndroid Build Coastguard Worker 23*5e7646d2SAndroid Build Coastguard Worker <h2><a name="CONFIG">Configuring the Server</a></h2> 24*5e7646d2SAndroid Build Coastguard Worker 25*5e7646d2SAndroid Build Coastguard Worker <p>In order to enable the corresponding type, you must create a new <var>/etc/cups/cgi.types</var> file which maps the filename extensions you use to the appropriate MIME types. For example, the following will support CGI programs/scripts with the "cgi" extension:</p> 26*5e7646d2SAndroid Build Coastguard Worker 27*5e7646d2SAndroid Build Coastguard Worker <pre class="command"> 28*5e7646d2SAndroid Build Coastguard Workerapplication/x-httpd-cgi cgi 29*5e7646d2SAndroid Build Coastguard Worker</pre> 30*5e7646d2SAndroid Build Coastguard Worker 31*5e7646d2SAndroid Build Coastguard Worker 32*5e7646d2SAndroid Build Coastguard Worker <h2><a name="LIMITS">Limitations</a></h2> 33*5e7646d2SAndroid Build Coastguard Worker 34*5e7646d2SAndroid Build Coastguard Worker <p>CUPS implements most of the CGI/1.1 specification, with the following exceptions:</p> 35*5e7646d2SAndroid Build Coastguard Worker 36*5e7646d2SAndroid Build Coastguard Worker <ul> 37*5e7646d2SAndroid Build Coastguard Worker <li>No PATH_INFO or PATH_TRANSLATED support</li> 38*5e7646d2SAndroid Build Coastguard Worker <li>Limited HTTP field support; only the Content-Length (<tt>CONTENT_LENGTH</tt>), Content-Type (<tt>CONTENT_TYPE</tt>), Cookie (<tt>HTTP_COOKIE</tt>), Referrer (<tt>HTTP_REFERRER</tt>), and User-Agent (<tt>HTTP_USER_AGENT</tt>) fields are placed in environment variables at this time</li> 39*5e7646d2SAndroid Build Coastguard Worker </ul> 40*5e7646d2SAndroid Build Coastguard Worker </body> 41*5e7646d2SAndroid Build Coastguard Worker</html> 42