1 .\" $Id: man.cgi.8,v 1.18 2016/07/07 14:34:41 schwarze Exp $
3 .\" Copyright (c) 2014, 2015, 2016 Ingo Schwarze <schwarze@openbsd.org>
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 .Dd $Mdocdate: July 7 2016 $
22 .Nd CGI program to search and display manual pages
26 CGI program searches for manual pages on a WWW server
27 and displays them to HTTP clients,
28 providing functionality equivalent to the
33 It can use multiple manual trees in parallel.
34 .Ss HTML search interface
35 At the top of each generated HTML page,
37 displays a search form containing these elements:
40 An input box for search queries, expecting
41 either a name of a manual page or an
43 using the syntax described in the
45 manual; filling this in is required for each search.
47 The expression is broken into words at whitespace.
48 Whitespace characters and backslashes can be escaped
49 by prepending a backslash.
50 The effect of prepending a backslash to another character is undefined;
51 in the current implementation, it has no effect.
56 The string in the input box is interpreted as the name of a manual page.
61 The string in the input box is interpreted as a search
64 A dropdown menu to optionally select a manual section.
65 If one is provided, it has the same effect as the
71 Otherwise, pages from all sections are shown.
73 A dropdown menu to optionally select an architecture.
74 If one is provided, it has the same effect as the
80 By default, pages for all architectures are shown.
82 A dropdown menu to select a manual tree.
83 If the configuration file
84 .Pa /var/www/man/manpath.conf
85 contains only one manpath, the dropdown menu is not shown.
86 By default, the first manpath given in the file is used.
91 program generates five kinds of output pages:
94 This is returned when calling
100 It serves as a starting point for using the program
101 and shows the search form only.
103 Lists are returned when searches match more than one manual page.
104 The first column shows the names and section numbers of manuals
106 The second column shows the one-line descriptions of the manuals.
108 This output format is used when a search matches exactly one
109 manual page, or when a link on a list page or an
111 link on another manual page is followed.
112 .It A no-result page.
113 This is shown when a search request returns no results -
114 eiher because it violates the query syntax, or because
115 the search does not match any manual pages.
117 This cannot happen by merely clicking the
119 button, but only by manually entering an invalid URI.
120 It does not show the search form, but only an error message
121 and a link back to the index page.
124 For each manual tree, create one first-level subdirectory below
126 The name of one of these directories is called a
130 Create a single ASCII text file
131 .Pa /var/www/man/manpath.conf
132 containing the names of these directories, one per line.
133 The directory given first is used as the default manpath.
135 Inside each of these directories, use the same directory and file
136 structure as found below
138 that is, second-level subdirectories
139 .Pa /var/www/man/*/man1 , /var/www/man/*/man2
140 etc. containing source
144 manuals with file name extensions matching the section numbers,
145 second-level subdirectories
146 .Pa /var/www/man/*/cat1 , /var/www/man/*/cat2
147 etc. containing preformatted manuals with the file name extension
149 and optional third-level subdirectories for architectures.
154 database inside each manpath.
156 Configure your web server to execute CGI programs located in
163 proxy daemon is needed to translate FastCGI requests to plain old CGI.
171 and edit it according to your needs.
172 It contains the following compile-time definitions:
175 Only useful for running on www.openbsd.org to deal with old URIs containing
176 .Qq "manpath=OpenBSD "
177 where the blank character has to be translated to a hyphen.
178 When compiling for other sites, this definition can be deleted.
180 An optional file system path to the directory containing the file
182 to be specified relative to the server's document root,
183 and to be specified without a trailing slash.
184 When empty, the CSS file is assumed to be in the document root.
185 Otherwise, a leading slash is needed.
186 This is used in generated HTML code.
187 .It Dv CUSTOMIZE_TITLE
188 An ASCII string to be used for the HTML <TITLE> element.
190 The FQDN of the (possibly virtual) host the HTTP server is running on.
193 headers in HTTP 303 responses.
195 A file system path to the
197 data directory relative to the web server
199 directory, to be specified with a leading slash and without a trailing slash.
200 It needs to have at least one component; the root directory cannot be used
207 are looked up in this directory.
208 It is also prepended to the manpath when opening
210 and manual page files.
212 The initial component of URIs, to be specified without leading
213 and trailing slashes.
223 and copy the files to the proper locations.
228 can help with that, but do not run it without carefully checking it
229 because the directory layouts of web servers vary greatly.
232 uniform resource identifiers are not needed for interactive use,
233 but can be useful for deep linking.
245 preceded by a slash unless empty.
247 To show a single page, a slash, the manpath, another slash,
248 and the name of the requested file, for example
249 .Pa /OpenBSD-current/man1/mandoc.1 .
250 This can be abbreviated according to the following syntax:
252 .Op / Ar manpath Oo / Cm man Ar sec Oc Op / Ar arch
253 .Pf / Ar name Op \&. Ar sec
256 For searches, a query string starting with a question mark
258 .Ar key Ns = Ns Ar value
259 pairs, separated by ampersands, for example
260 .Pa ?manpath=OpenBSD-current&query=mandoc .
274 which is a boolean parameter to select or deselect the
277 For backward compatibility with the traditional
280 is supported as an alias for
283 .Ss Restricted character set
284 For security reasons, in particular to prevent cross site scripting
285 attacks, some strings used by
287 can only contain the following characters:
289 .Bl -dash -compact -offset indent
291 lower case and upper case ASCII letters
293 the ten decimal digits
308 In particular, this applies to all manpaths and architecture names.
310 The web server may pass the following CGI variables to
314 The initial part of the URI passed from the client to the server,
315 starting after the server's host name and ending before
319 When constructing URIs for links and redirections, the
321 preprocessor constant is used instead.
323 The final part of the URI path passed from the client to the server,
326 and ending before the
330 page to acquire the manpath and filename it needs.
332 The HTTP query string passed from the client to the server.
333 It is the final part of the URI, after the question mark.
336 page to acquire the named parameters it needs.
344 All the following paths are specified relative to this directory.
345 .It Pa /cgi-bin/man.cgi
346 The usual file system path to the
348 program inside the web server
351 A different name can be chosen, but in any case, it needs to be configured in
354 The file system path to the server document root directory
355 relative to the server
358 This is part of the web server configuration and not specific to
360 .It Pa /htdocs/mandoc.css
363 HTML styling, referenced from each generated HTML page.
367 data directory containing all the manual trees.
370 .It Pa /man/mandoc/man1/apropos.1 , /man/mandoc/man8/man.cgi.8
371 Manual pages documenting
373 itself, linked from the index page.
374 .It Pa /man/manpath.conf
375 The list of available manpaths, one per line.
376 If any of the lines in this file contains a slash
378 or any character not contained in the
379 .Sx Restricted character set ,
381 reports an internal server error and exits without doing anything.
382 .It Pa /man/header.html
383 An optional file containing static HTML code to be inserted right
384 after opening the <BODY> element.
385 .It Pa /man/footer.html
386 An optional file containing static HTML code to be inserted right
387 before closing the <BODY> element.
388 .It Pa /man/OpenBSD-current/man1/mandoc.1
391 source file located below the
398 CGI program is call-compatible with queries from the traditional
400 script by Wolfram Schneider.
401 However, the output may not be quite the same.
412 first appeared in mdocml-1.12.1 (March 2012).
413 The current SQLite3-based version first appeared in
419 program was written by
420 .An Kristaps Dzonsons Aq Mt kristaps@bsd.lv
421 and ported to the SQLite3-based
424 .An Ingo Schwarze Aq Mt schwarze@openbsd.org .