[BACK]Return to man.cgi.8 CVS log [TXT][DIR] Up to [local] / src / usr.bin / mandoc

Annotation of src/usr.bin/mandoc/man.cgi.8, Revision 1.13

1.13    ! schwarze    1: .\"     $OpenBSD: man.cgi.8,v 1.12 2015/11/05 20:55:46 schwarze Exp $
1.1       schwarze    2: .\"
1.13    ! schwarze    3: .\" Copyright (c) 2014, 2015, 2016 Ingo Schwarze <schwarze@openbsd.org>
1.1       schwarze    4: .\"
                      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.
                      8: .\"
                      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.
                     16: .\"
1.12      schwarze   17: .Dd $Mdocdate: November 5 2015 $
1.1       schwarze   18: .Dt MAN.CGI 8
                     19: .Os
                     20: .Sh NAME
                     21: .Nm man.cgi
                     22: .Nd CGI program to search and display manual pages
                     23: .Sh DESCRIPTION
                     24: The
                     25: .Nm
                     26: CGI program searches for manual pages on a WWW server
                     27: and displays them to HTTP clients,
                     28: providing functionality equivalent to the
                     29: .Xr apropos 1
                     30: and
                     31: .Xr man 1
                     32: utilities.
                     33: It can use multiple manual trees in parallel.
                     34: .Ss HTML search interface
                     35: At the top of each generated HTML page,
                     36: .Nm
                     37: displays a search form containing these elements:
                     38: .Bl -enum
                     39: .It
1.2       schwarze   40: An input box for search queries, expecting
                     41: either a name of a manual page or an
1.1       schwarze   42: .Ar expression
                     43: using the syntax described in the
                     44: .Xr apropos 1
                     45: manual; filling this in is required for each search.
1.10      schwarze   46: .Pp
                     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.
1.1       schwarze   52: .It
1.2       schwarze   53: A
                     54: .Dq Submit
                     55: button to send a search request from the client to the server.
                     56: .It
                     57: A
                     58: .Dq Reset
                     59: button to undo any changes to the input boxes and the dropdown menus
                     60: and reset them to the values contained in the
                     61: .Ev QUERY_STRING .
                     62: .It
                     63: Radio buttons to select pages either by name like in
                     64: .Xr man 1
                     65: or using
                     66: .Xr apropos 1
                     67: queries.
                     68: .It
                     69: A dropdown menu to optionally select a manual section.
1.1       schwarze   70: If one is provided, it has the same effect as the
1.2       schwarze   71: .Xr man 1
                     72: and
1.1       schwarze   73: .Xr apropos 1
                     74: .Fl s
                     75: option.
                     76: Otherwise, pages from all sections are shown.
                     77: .It
1.2       schwarze   78: A dropdown menu to optionally select an architecture.
1.1       schwarze   79: If one is provided, it has the same effect as the
1.2       schwarze   80: .Xr man 1
                     81: and
1.1       schwarze   82: .Xr apropos 1
                     83: .Fl S
                     84: option.
                     85: By default, pages for all architectures are shown.
                     86: .It
                     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.
                     92: .El
                     93: .Ss Program output
                     94: The
                     95: .Nm
                     96: program generates five kinds of output pages:
                     97: .Bl -tag -width Ds
                     98: .It The index page.
                     99: This is returned when calling
                    100: .Nm
                    101: without
                    102: .Ev PATH_INFO
                    103: and without a
                    104: .Ev QUERY_STRING .
                    105: It serves as a starting point for using the program
                    106: and shows the search form only.
                    107: .It A list page.
                    108: Lists are returned when searches match more than one manual page.
                    109: The first column shows the names and section numbers of manuals
                    110: as clickable links.
                    111: The second column shows the one-line descriptions of the manuals.
                    112: .It A manual page.
                    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
                    115: .Ic \&Xr
                    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.
                    121: .It \&An error page.
                    122: This cannot happen by merely clicking the
                    123: .Dq Search
                    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.
                    127: .El
                    128: .Ss Setup
                    129: For each manual tree, create one first-level subdirectory below
                    130: .Pa /var/www/man .
                    131: The name of one of these directories is called a
                    132: .Dq manpath
                    133: in the context of
                    134: .Nm .
                    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.
                    139: .Pp
                    140: Inside each of these directories, use the same directory and file
                    141: structure as found below
                    142: .Pa /usr/share/man ,
                    143: that is, second-level subdirectories
                    144: .Pa /var/www/man/*/man1 , /var/www/man/*/man2
                    145: etc. containing source
                    146: .Xr mdoc 7
                    147: and
                    148: .Xr man 7
                    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
                    153: .Sq 0 ,
                    154: and optional third-level subdirectories for architectures.
                    155: Use
                    156: .Xr makewhatis 8
                    157: to create a
                    158: .Xr mandoc.db 5
                    159: database inside each manpath.
                    160: .Pp
                    161: Configure your web server to execute CGI programs located in
                    162: .Pa /cgi-bin .
1.4       schwarze  163: .Pp
                    164: To compile
                    165: .Nm ,
                    166: first copy
                    167: .Pa cgi.h.example
                    168: to
                    169: .Pa cgi.h
                    170: and edit it according to your needs.
                    171: It contains the following compile-time definitions:
                    172: .Bl -tag -width Ds
                    173: .It Ev COMPAT_OLDURI
                    174: Only useful for running on www.openbsd.org to deal with old URIs containing
                    175: .Qq "manpath=OpenBSD "
                    176: where the blank character has to be translated to a hyphen.
                    177: When compiling for other sites, this definition can be deleted.
                    178: .It Ev CSS_DIR
                    179: An optional path to the directory containing the CSS files,
                    180: to be specified relative to the server's document root,
                    181: and to be specified without a trailing slash.
                    182: When not specified, the CSS files
                    183: are assumed to be in the document root.
                    184: This is used in generated HTML code.
                    185: .It Ev CUSTOMIZE_TITLE
1.12      schwarze  186: An ASCII string to be used for the HTML <TITLE> element.
1.6       schwarze  187: .It Ev HTTP_HOST
                    188: The FQDN of the (possibly virtual) host the HTTP server is running on.
                    189: This is used for
                    190: .Ic Location:
                    191: headers in HTTP 303 responses.
1.4       schwarze  192: .It Ev MAN_DIR
                    193: A path to the
                    194: .Nm
                    195: data directory to be used instead of
                    196: .Pa /var/www/man ,
                    197: relative to the web server
                    198: .Xr chroot 2
                    199: directory, to be specified without a trailing slash.
                    200: This is prepended to the manpath when opening
                    201: .Xr mandoc.db 5
                    202: and manual page files.
                    203: .El
                    204: .Pp
                    205: After editing
                    206: .Pa cgi.h ,
                    207: run
                    208: .Pp
                    209: .Dl make man.cgi
                    210: .Pp
                    211: and copy the files to the proper locations.
                    212: Reading the
                    213: .Cm installcgi
                    214: target in the
                    215: .Pa Makefile
                    216: can help with that, but do not run it without carefully checking it
                    217: because the directory layouts of web servers vary greatly.
1.1       schwarze  218: .Ss URI interface
                    219: .Nm
                    220: uniform resource identifiers are not needed for interactive use,
                    221: but can be useful for deep linking.
                    222: They consist of:
                    223: .Bl -enum
                    224: .It
                    225: The
                    226: .Cm http://
                    227: protocol specifier.
                    228: .It
                    229: The host name and a following slash.
                    230: .It
                    231: The path to the program, normally
                    232: .Pa cgi-bin/man.cgi/ .
1.13    ! schwarze  233: On
        !           234: .Lk http://man.openbsd.org/ ,
        !           235: .Xr httpd 8
        !           236: is configured such that the path to the program can be omitted.
1.1       schwarze  237: .It
1.2       schwarze  238: To show a single page, a slash, the manpath, another slash,
1.1       schwarze  239: and the name of the requested file, for example
                    240: .Pa /OpenBSD-current/man1/mandoc.1 .
1.13    ! schwarze  241: This can be abbreviated according to the following syntax:
        !           242: .Sm off
        !           243: .Op / Ar manpath Oo / Cm man Ar sec Oc Op / Ar arch
        !           244: .Pf / Ar name Op \&. Ar sec
        !           245: .Sm on
1.1       schwarze  246: .It
1.2       schwarze  247: For searches, a query string starting with a question mark
1.1       schwarze  248: and consisting of
                    249: .Ar key Ns = Ns Ar value
                    250: pairs, separated by ampersands, for example
1.2       schwarze  251: .Pa ?manpath=OpenBSD-current&query=mandoc .
1.1       schwarze  252: Supported keys are
                    253: .Cm manpath ,
1.2       schwarze  254: .Cm query ,
1.1       schwarze  255: .Cm sec ,
                    256: .Cm arch ,
                    257: corresponding to
                    258: .Xr apropos 1
                    259: .Fl M ,
                    260: .Ar expression ,
                    261: .Fl s ,
                    262: .Fl S ,
1.2       schwarze  263: respectively, and
                    264: .Cm apropos ,
                    265: which is a boolean parameter to select or deselect the
                    266: .Xr apropos 1
                    267: query mode.
1.1       schwarze  268: For backward compatibility with the traditional
                    269: .Nm ,
1.2       schwarze  270: .Cm sektion
1.1       schwarze  271: is supported as an alias for
                    272: .Cm sec .
                    273: .El
1.7       schwarze  274: .Ss Restricted character set
                    275: For security reasons, in particular to prevent cross site scripting
                    276: attacks, some strings used by
                    277: .Nm
                    278: can only contain the following characters:
                    279: .Pp
                    280: .Bl -dash -compact -offset indent
                    281: .It
                    282: lower case and upper case ASCII letters
                    283: .It
                    284: the ten decimal digits
                    285: .It
                    286: the dash
                    287: .Pq Sq -
                    288: .It
                    289: the dot
                    290: .Pq Sq \&.
                    291: .It
                    292: the slash
                    293: .Pq Sq /
                    294: .It
                    295: the underscore
                    296: .Pq Sq _
                    297: .El
                    298: .Pp
                    299: In particular, this applies to the
                    300: .Ev SCRIPT_NAME ,
                    301: to all manpaths, and to all architecture names.
1.1       schwarze  302: .Sh ENVIRONMENT
                    303: The web server may pass the following CGI variables to
                    304: .Nm :
                    305: .Bl -tag -width Ds
                    306: .It Ev PATH_INFO
                    307: The final part of the URI path passed from the client to the server,
                    308: starting after the
                    309: .Ev SCRIPT_NAME
                    310: and ending before the
                    311: .Ev QUERY_STRING .
                    312: It is used by the
                    313: .Cm show
1.8       schwarze  314: page to acquire the manpath and filename it needs.
1.1       schwarze  315: .It Ev QUERY_STRING
                    316: The HTTP query string passed from the client to the server.
                    317: It is the final part of the URI, after the question mark.
                    318: It is used by the
                    319: .Cm search
                    320: page to acquire the named parameters it needs.
                    321: .It Ev SCRIPT_NAME
                    322: The path to the
                    323: .Nm
                    324: binary relative to the server root, usually
                    325: .Pa /cgi-bin/man.cgi .
                    326: This is used for generating URIs to be embedded
                    327: in generated HTML code and HTTP headers.
1.7       schwarze  328: If this contains any character not contained in the
                    329: .Sx Restricted character set ,
                    330: .Nm
                    331: reports an internal server error and exits without doing anything.
1.1       schwarze  332: .El
                    333: .Sh FILES
                    334: .Bl -tag -width Ds
                    335: .It Pa /var/www
                    336: Default web server
                    337: .Xr chroot 2
                    338: directory.
                    339: All the following paths are specified relative to this directory.
                    340: .It Pa /cgi-bin/man.cgi
                    341: The path to the
                    342: .Nm
                    343: program relative to the server root.
                    344: Can be overridden by
                    345: .Ev SCRIPT_NAME .
                    346: .It Pa /htdocs
                    347: The path to the server document root relative to the server root.
                    348: This is part of the web server configuration and not specific to
                    349: .Nm .
1.11      schwarze  350: .It Pa /htdocs/mandoc.css
1.1       schwarze  351: A style sheet for
                    352: .Xr mandoc 1
1.11      schwarze  353: HTML styling, referenced from each generated HTML page.
1.1       schwarze  354: .It Pa /man
                    355: Default
                    356: .Nm
                    357: data directory containing all the manual trees.
                    358: Can be overridden by
                    359: .Ev MAN_DIR .
1.3       schwarze  360: .It Pa /man/mandoc/man1/apropos.1 , /man/mandoc/man8/man.cgi.8
                    361: Manual pages documenting
                    362: .Nm
                    363: itself, linked from the index page.
1.1       schwarze  364: .It Pa /man/manpath.conf
                    365: The list of available manpaths, one per line.
1.7       schwarze  366: If any of the lines in this file contains a slash
                    367: .Pq Sq /
                    368: or any character not contained in the
                    369: .Sx Restricted character set ,
                    370: .Nm
                    371: reports an internal server error and exits without doing anything.
1.12      schwarze  372: .It Pa /man/header.html
                    373: An optional file containing static HTML code to be inserted right
                    374: after opening the <BODY> element.
                    375: .It Pa /man/footer.html
                    376: An optional file containing static HTML code to be inserted right
                    377: before closing the <BODY> element.
1.1       schwarze  378: .It Pa /man/OpenBSD-current/man1/mandoc.1
                    379: An example
                    380: .Xr mdoc 7
                    381: source file located below the
                    382: .Dq OpenBSD-current
                    383: manpath.
1.2       schwarze  384: .El
1.1       schwarze  385: .Sh COMPATIBILITY
                    386: The
                    387: .Nm
                    388: CGI program is call-compatible with queries from the traditional
                    389: .Pa man.cgi
                    390: script by Wolfram Schneider.
1.2       schwarze  391: However, the output may not be quite the same.
1.1       schwarze  392: .Sh SEE ALSO
                    393: .Xr apropos 1 ,
                    394: .Xr mandoc.db 5 ,
                    395: .Xr makewhatis 8 ,
                    396: .Xr slowcgi 8
                    397: .Sh HISTORY
                    398: A version of
                    399: .Nm
                    400: based on
                    401: .Xr mandoc 1
                    402: first appeared in mdocml-1.12.1 (March 2012).
                    403: The current SQLite3-based version first appeared in
                    404: .Ox 5.6 .
                    405: .Sh AUTHORS
                    406: .An -nosplit
                    407: The
                    408: .Nm
                    409: program was written by
                    410: .An Kristaps Dzonsons Aq Mt kristaps@bsd.lv
                    411: and ported to the SQLite3-based
                    412: .Xr mandoc.db 5
                    413: backend by
                    414: .An Ingo Schwarze Aq Mt schwarze@openbsd.org .