MAN.CGI(8) | System Manager's Manual | MAN.CGI(8) |
man.cgi
— CGI
program to search and display manual pages
The man.cgi
CGI program searches for
manual pages on a WWW server and displays them to HTTP clients, providing
functionality equivalent to the
man(1) and
apropos(1) utilities. It can
use multiple manual trees in parallel.
At the top of each generated HTML page,
man.cgi
displays a search form containing these
elements:
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.
-s
option. Otherwise, pages from all sections are
shown.-S
option. By default, pages for all architectures
are shown.The man.cgi
program generates five kinds
of output pages:
man.cgi
without
PATH_INFO
and without a
QUERY_STRING
. It serves as a starting point for
using the program and shows the search form only.Xr
link on
another manual page is followed.For each manual tree, create one first-level subdirectory below
/var/www/man. The name of one of these directories
is called a “manpath” in the context of
man.cgi
. Create a single ASCII text file
/var/www/man/manpath.conf containing the names of
these directories, one per line. The directory given first is used as the
default manpath.
Inside each of these directories, use the same directory and file structure as found below /usr/share/man, that is, second-level subdirectories /var/www/man/*/man1, /var/www/man/*/man2 etc. containing source mdoc(7) and man(7) manuals with file name extensions matching the section numbers, second-level subdirectories /var/www/man/*/cat1, /var/www/man/*/cat2 etc. containing preformatted manuals with the file name extension ‘0’, and optional third-level subdirectories for architectures. Use makewhatis(8) to create a mandoc.db(5) database inside each manpath.
Configure your web server to execute CGI programs located in /cgi-bin. When using OpenBSD httpd(8), the slowcgi(8) proxy daemon is needed to translate FastCGI requests to plain old CGI.
To compile man.cgi
, first copy
cgi.h.example to cgi.h and
edit it according to your needs. It contains the following compile-time
definitions:
COMPAT_OLDURI
CSS_DIR
CUSTOMIZE_TITLE
MAN_DIR
man.cgi
data directory
relative to the web server
chroot(2)
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 manpath.conf,
header.html, and
footer.html are looked up in this directory. It is
also prepended to the manpath when opening
mandoc.db(5) and manual
page files.SCRIPT_NAME
After editing cgi.h, run
make man.cgi
and copy the resulting binary to the proper location, for example using the command:
make installcgi
In addition to that, make sure the default manpath contains the files man1/apropos.1 and man8/man.cgi.8, or the documentation links at the bottom of the index page will not work.
man.cgi
uniform resource identifiers are
not needed for interactive use, but can be useful for deep linking. They
consist of:
http://
or https://
protocol specifier.SCRIPT_NAME
, preceded by a slash unless
empty.man
sec][/arch]/name[.sec]manpath
,
query
, sec
,
arch
, corresponding to
apropos(1)
-M
, expression,
-s
, -S
, respectively, and
apropos
, which is a boolean parameter to select or
deselect the apropos(1) query
mode. For backward compatibility with the traditional
man.cgi
, sektion
is
supported as an alias for sec
.For security reasons, in particular to prevent cross site
scripting attacks, some strings used by man.cgi
can
only contain the following characters:
In particular, this applies to all manpaths and architecture names.
The web server may pass the following CGI variables to
man.cgi
:
SCRIPT_NAME
PATH_INFO
. This is ignored by
man.cgi
. When constructing URIs for links and
redirections, the SCRIPT_NAME
preprocessor
constant is used instead.PATH_INFO
SCRIPT_NAME
and ending before
the QUERY_STRING
. It is used by the
show
page to acquire the manpath and filename it
needs.QUERY_STRING
search
page to acquire the named parameters it
needs.man.cgi
program
inside the web server
chroot(2)
directory. A different name can be chosen, but in any case, it needs to be
configured in
httpd.conf(5).man.cgi
.man.cgi
data directory containing all the
manual trees. Can be overridden by MAN_DIR
.man.cgi
reports an internal server error
and exits without doing anything.The man.cgi
CGI program is call-compatible
with queries from the traditional man.cgi script by
Wolfram Schneider. However, the output looks quite different.
A version of man.cgi
based on
mandoc(1) first appeared in
mdocml-1.12.1 (March 2012). The current
mandoc.db(5) database format
first appeared in OpenBSD 6.1.
The man.cgi
program was written by
Kristaps Dzonsons
<kristaps@bsd.lv> and
is maintained by Ingo Schwarze
<schwarze@openbsd.org>,
who also designed and implemented the database format.
May 20, 2018 | Linux 5.14.0-pf2 |