CINXE.COM

man.cgi(8) - OpenBSD manual pages

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="/mandoc.css" type="text/css" media="all"> <title>man.cgi(8) - OpenBSD manual pages</title> </head> <body> <header> <section> <h1><a href="https://www.openbsd.org/">OpenBSD</a> manual page server</h1> </section> <form role="search" action="/" method="get" autocomplete="off" autocapitalize="none"> <fieldset> <legend>Manual Page Search Parameters</legend> <label>Search query: <input type="search" name="query" value="man.cgi" size="40"> </label> <button type="submit" name="apropos" value="0">man</button> <button type="submit" name="apropos" value="1">apropos</button> <br/> <select name="sec" aria-label="Manual section"> <option value="0">All Sections</option> <option value="1">1 - General Commands</option> <option value="2">2 - System Calls</option> <option value="3">3 - Library Functions</option> <option value="3p">3p - Perl Library</option> <option value="4">4 - Device Drivers</option> <option value="5">5 - File Formats</option> <option value="6">6 - Games</option> <option value="7">7 - Miscellaneous Information</option> <option value="8" selected="selected">8 - System Manager's Manual</option> <option value="9">9 - Kernel Developer's Manual</option> </select> <select name="arch" aria-label="CPU architecture"> <option value="default" selected="selected">All Architectures</option> <option>amd64</option> <option>alpha</option> <option>armv7</option> <option>arm64</option> <option>hppa</option> <option>i386</option> <option>landisk</option> <option>loongson</option> <option>luna88k</option> <option>macppc</option> <option>mips64</option> <option>octeon</option> <option>powerpc64</option> <option>riscv64</option> <option>sparc64</option> <option>amiga</option> <option>arc</option> <option>armish</option> <option>arm32</option> <option>atari</option> <option>aviion</option> <option>beagle</option> <option>cats</option> <option>hppa64</option> <option>hp300</option> <option>ia64</option> <option>mac68k</option> <option>mvme68k</option> <option>mvme88k</option> <option>mvmeppc</option> <option>palm</option> <option>pc532</option> <option>pegasos</option> <option>pmax</option> <option>powerpc</option> <option>sgi</option> <option>socppc</option> <option>solbourne</option> <option>sparc</option> <option>sun3</option> <option>vax</option> <option>wgrisc</option> <option>x68k</option> <option>zaurus</option> </select> <select name="manpath" aria-label="Manual path"> <option selected="selected">OpenBSD-current</option> <option>OpenBSD-7.6</option> <option>OpenBSD-7.5</option> <option>OpenBSD-7.4</option> <option>OpenBSD-7.3</option> <option>OpenBSD-7.2</option> <option>OpenBSD-7.1</option> <option>OpenBSD-7.0</option> <option>OpenBSD-6.9</option> <option>OpenBSD-6.8</option> <option>OpenBSD-6.7</option> <option>OpenBSD-6.6</option> <option>OpenBSD-6.5</option> <option>OpenBSD-6.4</option> <option>OpenBSD-6.3</option> <option>OpenBSD-6.2</option> <option>OpenBSD-6.1</option> <option>OpenBSD-6.0</option> <option>OpenBSD-5.9</option> <option>OpenBSD-5.8</option> <option>OpenBSD-5.7</option> <option>OpenBSD-5.6</option> <option>OpenBSD-5.5</option> <option>OpenBSD-5.4</option> <option>OpenBSD-5.3</option> <option>OpenBSD-5.2</option> <option>OpenBSD-5.1</option> <option>OpenBSD-5.0</option> <option>OpenBSD-4.9</option> <option>OpenBSD-4.8</option> <option>OpenBSD-4.7</option> <option>OpenBSD-4.6</option> <option>OpenBSD-4.5</option> <option>OpenBSD-4.4</option> <option>OpenBSD-4.3</option> <option>OpenBSD-4.2</option> <option>OpenBSD-4.1</option> <option>OpenBSD-4.0</option> <option>OpenBSD-3.9</option> <option>OpenBSD-3.8</option> <option>OpenBSD-3.7</option> <option>OpenBSD-3.6</option> <option>OpenBSD-3.5</option> <option>OpenBSD-3.4</option> <option>OpenBSD-3.3</option> <option>OpenBSD-3.2</option> <option>OpenBSD-3.1</option> <option>OpenBSD-3.0</option> <option>OpenBSD-2.9</option> <option>OpenBSD-2.8</option> <option>OpenBSD-2.7</option> <option>OpenBSD-2.6</option> <option>OpenBSD-2.5</option> <option>OpenBSD-2.4</option> <option>OpenBSD-2.3</option> <option>OpenBSD-2.2</option> </select> </fieldset> </form> </header> <hr> <div class="head" role="doc-pageheader" aria-label="Manual header line"><span class="head-ltitle">MAN.CGI(8)</span> <span class="head-vol">System Manager's Manual</span> <span class="head-rtitle">MAN.CGI(8)</span></div> <main class="manual-text"> <section class="Sh"> <h2 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h2> <p class="Pp"><code class="Nm">man.cgi</code> &#x2014; <span class="Nd" role="doc-subtitle">CGI program to search and display manual pages</span></p> </section> <section class="Sh"> <h2 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h2> <p class="Pp">The <code class="Nm">man.cgi</code> CGI program searches for manual pages on a WWW server and displays them to HTTP clients, providing functionality equivalent to the <a class="Xr" href="/man.1" aria-label="man, section 1">man(1)</a> and <a class="Xr" href="/apropos.1" aria-label="apropos, section 1">apropos(1)</a> utilities. It can use multiple manual trees in parallel.</p> <section class="Ss"> <h3 class="Ss" id="HTML_search_interface"><a class="permalink" href="#HTML_search_interface">HTML search interface</a></h3> <p class="Pp">At the top of each generated HTML page, <code class="Nm">man.cgi</code> displays a search form containing these elements:</p> <ol class="Bl-enum"> <li>An input box for search queries, expecting either a name of a manual page or an <var class="Ar">expression</var> using the syntax described in the <a class="Xr" href="/apropos.1" aria-label="apropos, section 1">apropos(1)</a> manual; filling this in is required for each search. <p class="Pp">The expression is broken into words at whitespace. Whitespace characters and backslashes can be escaped by prepending a backslash. The effect of prepending a backslash to another character is undefined; in the current implementation, it has no effect.</p> </li> <li>A <a class="Xr" href="/man.1" aria-label="man, section 1">man(1)</a> submit button. The string in the input box is interpreted as the name of a manual page.</li> <li>An <a class="Xr" href="/apropos.1" aria-label="apropos, section 1">apropos(1)</a> submit button. The string in the input box is interpreted as a search <var class="Ar">expression</var>.</li> <li>A dropdown menu to optionally select a manual section. If one is provided, it has the same effect as the <a class="Xr" href="/man.1" aria-label="man, section 1">man(1)</a> and <a class="Xr" href="/apropos.1" aria-label="apropos, section 1">apropos(1)</a> <code class="Fl">-s</code> option. Otherwise, pages from all sections are shown.</li> <li>A dropdown menu to optionally select an architecture. If one is provided, it has the same effect as the <a class="Xr" href="/man.1" aria-label="man, section 1">man(1)</a> and <a class="Xr" href="/apropos.1" aria-label="apropos, section 1">apropos(1)</a> <code class="Fl">-S</code> option. By default, pages for all architectures are shown.</li> <li>A dropdown menu to select a manual tree. If the configuration file <span class="Pa">/var/www/man/manpath.conf</span> contains only one manpath, the dropdown menu is not shown. By default, the first manpath given in the file is used.</li> </ol> </section> <section class="Ss"> <h3 class="Ss" id="Program_output"><a class="permalink" href="#Program_output">Program output</a></h3> <p class="Pp">The <code class="Nm">man.cgi</code> program generates five kinds of output pages:</p> <dl class="Bl-tag"> <dt>The index page.</dt> <dd>This is returned when calling <code class="Nm">man.cgi</code> without <code class="Ev">PATH_INFO</code> and without a <code class="Ev">QUERY_STRING</code>. It serves as a starting point for using the program and shows the search form only.</dd> <dt>A list page.</dt> <dd>Lists are returned when searches match more than one manual page. The first column shows the names and section numbers of manuals as clickable links. The second column shows the one-line descriptions of the manuals. For <a class="Xr" href="/man.1" aria-label="man, section 1">man(1)</a> style searches, the content of the first manual page follows the list.</dd> <dt>A manual page.</dt> <dd>This output format is used when a search matches exactly one manual page, or when a link on a list page or an <code class="Ic">Xr</code> link on another manual page is followed.</dd> <dt>A no-result page.</dt> <dd>This is shown when a search request returns no results - either because it violates the query syntax, or because the search does not match any manual pages.</dd> <dt>An error page.</dt> <dd>This cannot happen by merely clicking the &#x201C;Search&#x201D; button, but only by manually entering an invalid URI. It does not show the search form, but only an error message and a link back to the index page.</dd> </dl> </section> <section class="Ss"> <h3 class="Ss" id="Setup"><a class="permalink" href="#Setup">Setup</a></h3> <p class="Pp">For each manual tree, create one first-level subdirectory below <span class="Pa">/var/www/man</span>. The name of one of these directories is called a &#x201C;manpath&#x201D; in the context of <code class="Nm">man.cgi</code>. Create a single ASCII text file <span class="Pa">/var/www/man/manpath.conf</span> containing the names of these directories, one per line. The directory given first is used as the default manpath.</p> <p class="Pp">Inside each of these directories, use the same directory and file structure as found below <span class="Pa">/usr/share/man</span>, that is, second-level subdirectories <span class="Pa">/var/www/man/*/man1</span>, <span class="Pa">/var/www/man/*/man2</span> etc. containing source <a class="Xr" href="/mdoc.7" aria-label="mdoc, section 7">mdoc(7)</a> and <a class="Xr" href="/man.7" aria-label="man, section 7">man(7)</a> manuals with file name extensions matching the section numbers, second-level subdirectories <span class="Pa">/var/www/man/*/cat1</span>, <span class="Pa">/var/www/man/*/cat2</span> etc. containing preformatted manuals with the file name extension &#x2018;0&#x2019;, and optional third-level subdirectories for architectures. Use <a class="Xr" href="/makewhatis.8" aria-label="makewhatis, section 8">makewhatis(8)</a> to create a <a class="Xr" href="/mandoc.db.5" aria-label="mandoc.db, section 5">mandoc.db(5)</a> database inside each manpath.</p> <p class="Pp">Configure your web server to execute CGI programs located in <span class="Pa">/cgi-bin</span>. When using <span class="Ux">OpenBSD</span> <a class="Xr" href="/httpd.8" aria-label="httpd, section 8">httpd(8)</a>, the <a class="Xr" href="/slowcgi.8" aria-label="slowcgi, section 8">slowcgi(8)</a> proxy daemon is needed to translate FastCGI requests to plain old CGI.</p> <p class="Pp">To compile <code class="Nm">man.cgi</code>, first copy <span class="Pa">cgi.h.example</span> to <span class="Pa">cgi.h</span> and edit it according to your needs. It contains the following compile-time definitions:</p> <dl class="Bl-tag"> <dt id="COMPAT_OLDURI"><a class="permalink" href="#COMPAT_OLDURI"><code class="Ev">COMPAT_OLDURI</code></a></dt> <dd>Only useful for running on www.openbsd.org to deal with old URIs containing &quot;manpath=OpenBSD &quot; where the blank character has to be translated to a hyphen. When compiling for other sites, this definition can be deleted.</dd> <dt id="CSS_DIR"><a class="permalink" href="#CSS_DIR"><code class="Dv">CSS_DIR</code></a></dt> <dd>An optional file system path to the directory containing the file <span class="Pa">mandoc.css</span>, to be specified relative to the server's document root, and to be specified without a trailing slash. When empty, the CSS file is assumed to be in the document root. Otherwise, a leading slash is needed. This is used in generated HTML code.</dd> <dt id="CUSTOMIZE_TITLE"><a class="permalink" href="#CUSTOMIZE_TITLE"><code class="Dv">CUSTOMIZE_TITLE</code></a></dt> <dd>An ASCII string to be used for the HTML &lt;TITLE&gt; element.</dd> <dt id="MAN_DIR"><a class="permalink" href="#MAN_DIR"><code class="Dv">MAN_DIR</code></a></dt> <dd>A file system path to the <code class="Nm">man.cgi</code> data directory relative to the web server <a class="Xr" href="/chroot.2" aria-label="chroot, section 2">chroot(2)</a> directory, to be specified with a leading slash and without a trailing slash. It needs to have at least one component; the root directory cannot be used for this purpose. The files <span class="Pa">manpath.conf</span>, <span class="Pa">header.html</span>, and <span class="Pa">footer.html</span> are looked up in this directory. It is also prepended to the manpath when opening <a class="Xr" href="/mandoc.db.5" aria-label="mandoc.db, section 5">mandoc.db(5)</a> and manual page files.</dd> <dt id="SCRIPT_NAME"><a class="permalink" href="#SCRIPT_NAME"><code class="Dv">SCRIPT_NAME</code></a></dt> <dd>The initial component of URIs, to be specified without leading and trailing slashes. It can be empty.</dd> </dl> <p class="Pp">After editing <span class="Pa">cgi.h</span>, run</p> <p class="Pp"></p> <div class="Bd Bd-indent"><code class="Li">make man.cgi</code></div> <p class="Pp">and copy the resulting binary to the proper location, for example using the command:</p> <p class="Pp"></p> <div class="Bd Bd-indent"><code class="Li">make installcgi</code></div> <p class="Pp">In addition to that, make sure the default manpath contains the files <span class="Pa">man1/apropos.1</span> and <span class="Pa">man8/man.cgi.8</span>, or the documentation links at the bottom of the index page will not work.</p> </section> <section class="Ss"> <h3 class="Ss" id="URI_interface"><a class="permalink" href="#URI_interface">URI interface</a></h3> <p class="Pp"><code class="Nm">man.cgi</code> uniform resource identifiers are not needed for interactive use, but can be useful for deep linking. They consist of:</p> <ol class="Bl-enum"> <li>The <code class="Cm">http://</code> or <code class="Cm">https://</code> protocol specifier.</li> <li>The host name.</li> <li>The <code class="Dv">SCRIPT_NAME</code>, preceded by a slash unless empty.</li> <li>To show a single page, a slash, the manpath, another slash, and the name of the requested file, for example <span class="Pa">/OpenBSD-current/man1/mandoc.1</span>. This can be abbreviated according to the following syntax: [/<var class="Ar">manpath</var>][/<code class="Cm">man</code><var class="Ar">sec</var>][/<var class="Ar">arch</var>]/<var class="Ar">name</var>[.<var class="Ar">sec</var>]</li> <li>For searches, a query string starting with a question mark and consisting of <var class="Ar">key</var>=<var class="Ar">value</var> pairs, separated by ampersands, for example <span class="Pa">?manpath=OpenBSD-current&amp;query=mandoc</span>. Supported keys are <code class="Cm">manpath</code>, <code class="Cm">query</code>, <code class="Cm">sec</code>, <code class="Cm">arch</code>, corresponding to <a class="Xr" href="/apropos.1" aria-label="apropos, section 1">apropos(1)</a> <code class="Fl">-M</code>, <var class="Ar">expression</var>, <code class="Fl">-s</code>, <code class="Fl">-S</code>, respectively, and <code class="Cm">apropos</code>, which is a boolean parameter to select or deselect the <a class="Xr" href="/apropos.1" aria-label="apropos, section 1">apropos(1)</a> query mode. For backward compatibility with the traditional <code class="Nm">man.cgi</code>, <code class="Cm">sektion</code> is supported as an alias for <code class="Cm">sec</code>.</li> </ol> </section> <section class="Ss"> <h3 class="Ss" id="Restricted_character_set"><a class="permalink" href="#Restricted_character_set">Restricted character set</a></h3> <p class="Pp">For security reasons, in particular to prevent cross site scripting attacks, some strings used by <code class="Nm">man.cgi</code> can only contain the following characters:</p> <p class="Pp"></p> <ul class="Bl-dash Bd-indent Bl-compact"> <li>lower case and upper case ASCII letters</li> <li>the ten decimal digits</li> <li>the dash (&#x2018;-&#x2019;)</li> <li>the dot (&#x2018;.&#x2019;)</li> <li>the slash (&#x2018;/&#x2019;)</li> <li>the underscore (&#x2018;_&#x2019;)</li> </ul> <p class="Pp">In particular, this applies to all manpaths and architecture names.</p> </section> </section> <section class="Sh"> <h2 class="Sh" id="ENVIRONMENT"><a class="permalink" href="#ENVIRONMENT">ENVIRONMENT</a></h2> <p class="Pp">The web server may pass the following CGI variables to <code class="Nm">man.cgi</code>:</p> <dl class="Bl-tag"> <dt id="SCRIPT_NAME~2"><a class="permalink" href="#SCRIPT_NAME~2"><code class="Ev">SCRIPT_NAME</code></a></dt> <dd>The initial part of the URI passed from the client to the server, starting after the server's host name and ending before <code class="Ev">PATH_INFO</code>. This is ignored by <code class="Nm">man.cgi</code>. When constructing URIs for links and redirections, the <code class="Dv">SCRIPT_NAME</code> preprocessor constant is used instead.</dd> <dt id="PATH_INFO"><a class="permalink" href="#PATH_INFO"><code class="Ev">PATH_INFO</code></a></dt> <dd>The final part of the URI path passed from the client to the server, starting after the <code class="Ev">SCRIPT_NAME</code> and ending before the <code class="Ev">QUERY_STRING</code>. It is used by the <code class="Cm">show</code> page to acquire the manpath and filename it needs.</dd> <dt id="QUERY_STRING"><a class="permalink" href="#QUERY_STRING"><code class="Ev">QUERY_STRING</code></a></dt> <dd>The HTTP query string passed from the client to the server. It is the final part of the URI, after the question mark. It is used by the <code class="Cm">search</code> page to acquire the named parameters it needs.</dd> </dl> </section> <section class="Sh"> <h2 class="Sh" id="FILES"><a class="permalink" href="#FILES">FILES</a></h2> <dl class="Bl-tag"> <dt><span class="Pa">/var/www</span></dt> <dd>Default web server <a class="Xr" href="/chroot.2" aria-label="chroot, section 2">chroot(2)</a> directory. All the following paths are specified relative to this directory.</dd> <dt><span class="Pa">/cgi-bin/man.cgi</span></dt> <dd>The usual file system path to the <code class="Nm">man.cgi</code> program inside the web server <a class="Xr" href="/chroot.2" aria-label="chroot, section 2">chroot(2)</a> directory. A different name can be chosen, but in any case, it needs to be configured in <a class="Xr" href="/httpd.conf.5" aria-label="httpd.conf, section 5">httpd.conf(5)</a>.</dd> <dt><span class="Pa">/htdocs</span></dt> <dd>The file system path to the server document root directory relative to the server <a class="Xr" href="/chroot.2" aria-label="chroot, section 2">chroot(2)</a> directory. This is part of the web server configuration and not specific to <code class="Nm">man.cgi</code>.</dd> <dt><span class="Pa">/htdocs/mandoc.css</span></dt> <dd>A style sheet for <a class="Xr" href="/mandoc.1" aria-label="mandoc, section 1">mandoc(1)</a> HTML styling, referenced from each generated HTML page.</dd> <dt><span class="Pa">/man</span></dt> <dd>Default <code class="Nm">man.cgi</code> data directory containing all the manual trees. Can be overridden by <code class="Dv">MAN_DIR</code>.</dd> <dt><span class="Pa">/man/manpath.conf</span></dt> <dd>The list of available manpaths, one per line. If any of the lines in this file contains a slash (&#x2018;/&#x2019;) or any character not contained in the <a class="Sx" href="#Restricted_character_set">Restricted character set</a>, <code class="Nm">man.cgi</code> reports an internal server error and exits without doing anything.</dd> <dt><span class="Pa">/man/header.html</span></dt> <dd>An optional file containing static HTML code to be wrapped in a &lt;HEADER&gt; element and inserted right after opening the &lt;BODY&gt; element. For example, it can contain an &lt;H1&gt; element specifying the name of the website.</dd> <dt><span class="Pa">/man/footer.html</span></dt> <dd>An optional file containing static HTML code to be wrapped in a &lt;FOOTER&gt; element and inserted right before closing the &lt;BODY&gt; element.</dd> <dt><span class="Pa">/man/OpenBSD-current/man1/mandoc.1</span></dt> <dd>An example <a class="Xr" href="/mdoc.7" aria-label="mdoc, section 7">mdoc(7)</a> source file located below the &#x201C;OpenBSD-current&#x201D; manpath.</dd> </dl> </section> <section class="Sh"> <h2 class="Sh" id="COMPATIBILITY"><a class="permalink" href="#COMPATIBILITY">COMPATIBILITY</a></h2> <p class="Pp">The <code class="Nm">man.cgi</code> CGI program is call-compatible with queries from the traditional <span class="Pa">man.cgi</span> script by Wolfram Schneider. However, the output looks quite different.</p> </section> <section class="Sh"> <h2 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE ALSO</a></h2> <p class="Pp"><a class="Xr" href="/apropos.1" aria-label="apropos, section 1">apropos(1)</a>, <a class="Xr" href="/mandoc.db.5" aria-label="mandoc.db, section 5">mandoc.db(5)</a>, <a class="Xr" href="/makewhatis.8" aria-label="makewhatis, section 8">makewhatis(8)</a>, <a class="Xr" href="/slowcgi.8" aria-label="slowcgi, section 8">slowcgi(8)</a></p> </section> <section class="Sh"> <h2 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h2> <p class="Pp">A version of <code class="Nm">man.cgi</code> based on <a class="Xr" href="/mandoc.1" aria-label="mandoc, section 1">mandoc(1)</a> first appeared in mdocml-1.12.1 (March 2012). The current <a class="Xr" href="/mandoc.db.5" aria-label="mandoc.db, section 5">mandoc.db(5)</a> database format first appeared in <span class="Ux">OpenBSD 6.1</span>.</p> </section> <section class="Sh"> <h2 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h2> <p class="Pp">The <code class="Nm">man.cgi</code> program was written by <span class="An">Kristaps Dzonsons</span> &lt;<a class="Mt" href="mailto:kristaps@bsd.lv">kristaps@bsd.lv</a>&gt; and is maintained by <span class="An">Ingo Schwarze</span> &lt;<a class="Mt" href="mailto:schwarze@openbsd.org">schwarze@openbsd.org</a>&gt;, who also designed and implemented the database format.</p> </section> </main> <div class="foot" role="doc-pagefooter" aria-label="Manual footer line"><span class="foot-left"></span><span class="foot-date">July 6, 2022</span> <span class="foot-os">OpenBSD-current</span></div> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10