1 .\" $Id: man.cgi.8,v 1.11 2014/09/14 19:44:28 schwarze Exp $
3 .\" Copyright (c) 2014 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: September 14 2014 $
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.
55 button to send a search request from the client to the server.
59 button to undo any changes to the input boxes and the dropdown menus
60 and reset them to the values contained in the
63 Radio buttons to select pages either by name like in
69 A dropdown menu to optionally select a manual section.
70 If one is provided, it has the same effect as the
76 Otherwise, pages from all sections are shown.
78 A dropdown menu to optionally select an architecture.
79 If one is provided, it has the same effect as the
85 By default, pages for all architectures are shown.
87 A dropdown menu to select a manual tree.
88 If the configuration file
89 .Pa /var/www/man/manpath.conf
90 contains only one manpath, the dropdown menu is not shown.
91 By default, the first manpath given in the file is used.
96 program generates five kinds of output pages:
99 This is returned when calling
105 It serves as a starting point for using the program
106 and shows the search form only.
108 Lists are returned when searches match more than one manual page.
109 The first column shows the names and section numbers of manuals
111 The second column shows the one-line descriptions of the manuals.
113 This output format is used when a search matches exactly one
114 manual page, or when a link on a list page or an
116 link on another manual page is followed.
117 .It A no-result page.
118 This is shown when a search request returns no results -
119 eiher because it violates the query syntax, or because
120 the search does not match any manual pages.
122 This cannot happen by merely clicking the
124 button, but only by manually entering an invalid URI.
125 It does not show the search form, but only an error message
126 and a link back to the index page.
129 For each manual tree, create one first-level subdirectory below
131 The name of one of these directories is called a
135 Create a single ASCII text file
136 .Pa /var/www/man/manpath.conf
137 containing the names of these directories, one per line.
138 The directory given first is used as the default manpath.
140 Inside each of these directories, use the same directory and file
141 structure as found below
143 that is, second-level subdirectories
144 .Pa /var/www/man/*/man1 , /var/www/man/*/man2
145 etc. containing source
149 manuals with file name extensions matching the section numbers,
150 second-level subdirectories
151 .Pa /var/www/man/*/cat1 , /var/www/man/*/cat2
152 etc. containing preformatted manuals with the file name extension
154 and optional third-level subdirectories for architectures.
159 database inside each manpath.
161 Configure your web server to execute CGI programs located in
167 proxy daemon is needed to translate FastCGI requests to plain old CGI.
175 and edit it according to your needs.
176 It contains the following compile-time definitions:
179 Only useful for running on www.openbsd.org to deal with old URIs containing
180 .Qq "manpath=OpenBSD "
181 where the blank character has to be translated to a hyphen.
182 When compiling for other sites, this definition can be deleted.
184 An optional path to the directory containing the CSS files,
185 to be specified relative to the server's document root,
186 and to be specified without a trailing slash.
187 When not specified, the CSS files
188 are assumed to be in the document root.
189 This is used in generated HTML code.
190 .It Ev CUSTOMIZE_BEGIN
191 A HTML string to be inserted right after opening the
194 .It Ev CUSTOMIZE_TITLE
195 An ASCII string to be used for the HTML
199 The FQDN of the (possibly virtual) host the HTTP server is running on.
202 headers in HTTP 303 responses.
206 data directory to be used instead of
208 relative to the web server
210 directory, to be specified without a trailing slash.
211 This is prepended to the manpath when opening
213 and manual page files.
222 and copy the files to the proper locations.
227 can help with that, but do not run it without carefully checking it
228 because the directory layouts of web servers vary greatly.
231 uniform resource identifiers are not needed for interactive use,
232 but can be useful for deep linking.
240 The host name and a following slash.
242 The path to the program, normally
243 .Pa cgi-bin/man.cgi/ .
245 To show a single page, a slash, the manpath, another slash,
246 and the name of the requested file, for example
247 .Pa /OpenBSD-current/man1/mandoc.1 .
249 For searches, a query string starting with a question mark
251 .Ar key Ns = Ns Ar value
252 pairs, separated by ampersands, for example
253 .Pa ?manpath=OpenBSD-current&query=mandoc .
267 which is a boolean parameter to select or deselect the
270 For backward compatibility with the traditional
273 is supported as an alias for
276 .Ss Restricted character set
277 For security reasons, in particular to prevent cross site scripting
278 attacks, some strings used by
280 can only contain the following characters:
282 .Bl -dash -compact -offset indent
284 lower case and upper case ASCII letters
286 the ten decimal digits
301 In particular, this applies to the
303 to all manpaths, and to all architecture names.
305 The web server may pass the following CGI variables to
309 The final part of the URI path passed from the client to the server,
312 and ending before the
316 page to acquire the manpath and filename it needs.
318 The HTTP query string passed from the client to the server.
319 It is the final part of the URI, after the question mark.
322 page to acquire the named parameters it needs.
326 binary relative to the server root, usually
327 .Pa /cgi-bin/man.cgi .
328 This is used for generating URIs to be embedded
329 in generated HTML code and HTTP headers.
330 If this contains any character not contained in the
331 .Sx Restricted character set ,
333 reports an internal server error and exits without doing anything.
341 All the following paths are specified relative to this directory.
342 .It Pa /cgi-bin/man.cgi
345 program relative to the server root.
349 The path to the server document root relative to the server root.
350 This is part of the web server configuration and not specific to
352 .It Pa /htdocs/man-cgi.css
353 A style sheet for general
355 styling, referenced from each generated HTML page.
356 .It Pa /htdocs/man.css
359 HTML styling, referenced from each generated HTML page after
364 data directory containing all the manual trees.
367 .It Pa /man/mandoc/man1/apropos.1 , /man/mandoc/man8/man.cgi.8
368 Manual pages documenting
370 itself, linked from the index page.
371 .It Pa /man/manpath.conf
372 The list of available manpaths, one per line.
373 If any of the lines in this file contains a slash
375 or any character not contained in the
376 .Sx Restricted character set ,
378 reports an internal server error and exits without doing anything.
379 .It Pa /man/OpenBSD-current/man1/mandoc.1
382 source file located below the
389 CGI program is call-compatible with queries from the traditional
391 script by Wolfram Schneider.
392 However, the output may not be quite the same.
403 first appeared in mdocml-1.12.1 (March 2012).
404 The current SQLite3-based version first appeared in
410 program was written by
411 .An Kristaps Dzonsons Aq Mt kristaps@bsd.lv
412 and ported to the SQLite3-based
415 .An Ingo Schwarze Aq Mt schwarze@openbsd.org .