diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2018-04-20 16:38:04 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2018-04-20 16:38:04 +0300 |
commit | a839739765a69e07199f375458e22578ec4a4aca (patch) | |
tree | 46c595587aa290ae2ff2b8b22d9908a949e55917 | |
parent | 2514afaf0c1975a8ab7e9346a46348497cc0dd7f (diff) | |
download | fileserv-a839739765a69e07199f375458e22578ec4a4aca.tar.gz fileserv-a839739765a69e07199f375458e22578ec4a4aca.tar.bz2 |
Update documentation. Minor bugfixes.
* src/Makefile.am: Install fileserv.conf, unless it already exists.
* src/config.c: Rename pid-file to pidfile, and mime-magic-file to
mime-types-file. Retain old names for compatibility.
* src/defidx.html: Minor fix.
* src/fileserv.8: Rewrite.
* src/fileserv.conf: New file.
* src/idx.c (exp_filetype): Remove useless return.
-rw-r--r-- | src/Makefile.am | 8 | ||||
-rw-r--r-- | src/config.c | 2 | ||||
-rw-r--r-- | src/defidx.html | 2 | ||||
-rw-r--r-- | src/fileserv.8 | 517 | ||||
-rw-r--r-- | src/fileserv.conf | 206 | ||||
-rw-r--r-- | src/idx.c | 1 |
6 files changed, 642 insertions, 94 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index d3e6035..444cefc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,7 +9,13 @@ endif dist_man_MANS=fileserv.8 LDADD = ../mimetypes/libmimetypes.a AM_CPPFLAGS = -I $(top_srcdir)/mimetypes -DSYSCONFDIR=\"$(sysconfdir)\" -EXTRA_DIST=ftoc.sed defidx.html +EXTRA_DIST=ftoc.sed defidx.html fileserv.conf .html.h: $(AM_V_GEN)sed -f $(srcdir)/ftoc.sed $< > $@ +install-data-local: + @if [ ! -r $(DESTDIR)$(sysconfdir)/fileserv.conf ]; then :; \ + test -z "$(DESTDIR)$(sysconfdir)" || $(mkdir_p) "$(DESTDIR)$(sysconfdir)" + ${INSTALL} -m 644 fileserv.conf \ + $(DESTDIR)$(sysconfdir)/fileserv.conf; \ + fi diff --git a/src/config.c b/src/config.c index 5820c31..19b26c7 100644 --- a/src/config.c +++ b/src/config.c @@ -618,7 +618,9 @@ static struct config_keyword keywords[] = { { CTXGLOB, "trusted-proxy", set_trusted_proxy }, { CTXGLOB, "temp-dir", set_temp_dir }, { CTXGLOB, "mime-magic-file", set_mime_magic_file }, + { CTXGLOB, "mime-types-file", set_mime_magic_file }, { CTXGLOB, "pid-file", set_pidfile }, + { CTXGLOB, "pidfile", set_pidfile }, { CTXGLOB, "syslog", set_syslog }, { CTXGLOB, "mapping", set_mapping }, { CTXGLOB, "error-dir", set_error_dir }, diff --git a/src/defidx.html b/src/defidx.html index 385eeec..77e51be 100644 --- a/src/defidx.html +++ b/src/defidx.html @@ -11,7 +11,7 @@ <table id="indexlist"> <tr class="indexhead"> <th class="indexcolicon"> - {% if $(iconlookup BLANK) %} + {% if $(iconlookup - - BLANK) %} <img src="{% $(iconsrc) %}" alt="[{% $(iconalt) %}]"> {% else %} [ICO] diff --git a/src/fileserv.8 b/src/fileserv.8 index 72c62a5..6014fad 100644 --- a/src/fileserv.8 +++ b/src/fileserv.8 @@ -1,5 +1,5 @@ .\" This file is part of fileserv -*- nroff -*- -.\" Copyright (C) 2017 Sergey Poznyakoff +.\" Copyright (C) 2017, 2018 Sergey Poznyakoff .\" .\" Fileserv is free software; you can redistribute it and/or modify .\" it under the terms of the GNU General Public License as published by @@ -13,87 +13,144 @@ .\" .\" You should have received a copy of the GNU General Public License .\" along with fileserv. If not, see <http://www.gnu.org/licenses/>. -.TH FILESERV 8 "October 24, 2017" "FILESERV" "User Commands" +.TH FILESERV 8 "April 20, 2018" "FILESERV" "User Commands" .SH NAME fileserv \- simple http server for static files .SH SYNOPSIS \fBfileserv\fR\ - [\fB\-fh\fR]\ - [\fB\-a \fIADDRESS:PORT\fR]\ - [\fB\-F \fIFACILITY\fR]\ - [\fB\-g \fIGROUP\fR]\ - [\fB\-p \fIFILE\fR]\ - [\fB\-t \fIIP\fR[\fB/\fIMASK\fR]]\ - [\fB\-x \fIHEADER\fR]\ - [\fB\-u \fIUSER\fR]\ - [\fIHOST\fB:\fR]\fIURL-path\fB:\fIDIR\fR ... + [\fB\-fhsv\fR]\ + [\fB\-c\fR \fIFILE\fR]\ + [\fIHOST\fB:\fR]\fIURL\fB:\fIDIR\fR ... .SH DESCRIPTION -A simple and lightweight HTTP server for serving static files. URLs -and directories from which to serve files are supplied as command line -arguments. Each argument declares a mapping between the URL of the -incoming request and the directory on the local filesystem (think of -Apache \fBAlias\fR directive). URLs with a path beginning with -\fIURL-path\fR will be mapped to local files beginning with \fIDIR\fR. -Optional \fIHOST\fR part limits the mapping to requests that have this -value in the HTTP \fBHost:\fR header. -.PP -After resolving the mapping, the obtained filename is canonicalized -using -.BR realpath (3) -and the resulting absolute name is checked once more against the -mappings to filter out possible breaking attempts. -.PP -By default, the program listens on all available interfaces on port -8080. Each request is logged in Apache \fBcombined\fR format. Log -messages are sent to syslog channel \fBdaemon\fR, unless the program -is started in foreground mode, in which case standard error is used. -.PP -Each log message contains the client IP of the connection. -If the \fBX\-Forwarded\-For\fR header is present, its value overrides -that IP. If the header contains a comma-delimited list of IP -addresses, this list is processed in right-to-left order, until either -a not trusted IP or the first IP in the list is encountered, whichever -occurs first. -.PP -The list of trusted IP is initially empty. New addresses or networks -are added to that list using the \fB\-t\fR command line option. E.g. -.sp -.RS 4 -.nf -fileserv -t 192.168.1.0/24 -t 127.0.0.0/8 -.fi -.RE -.sp -Any header can be used in place of \fBX\-Forwarded\-For\fR, provided its -name is given as argument to the \fB\-x\fR option. -.PP -Normally \fBfileserv\fR runs with the privileges of the user that -started it. If running as root, the user to run as can be specified -using the \fB\-u\fR command line option. When switching to the user -privileges, the principal and auxiliary groups are changed to those of -the requested user. The principal group can be changed using the -\fB\-g\fR command line option. -.PP -Source IPs of the incoming requests are checked using \fBlibwrap\fR, -if it is available. See -.BR hosts_access (5), -for details. +A simple and lightweight HTTP server. It serves static files from one +or more directories on the file system. The directories to be used and +the corresponding URLs are defined in the form of mappings, either in +the command line or in the configuration file. The mapping +.PP +.EX + \fIPATH\fR:\fIDIR\fR +.EE +.PP +instructs the server to map all URLs that begin with the path prefix +\fIPATH\fR to the directory \fIDIR\fR on the file system. The mapping +.PP +.EX + \fIHOST\fR:\fIPATH\fR:\fIDIR\fR +.EE +.PP +has the same effect, but only if the \fBHost:\fR header of the +incoming HTTP request has the value \fIHOST\fR. +.PP +Depending on the configuration settings, the directory listing can be +produced. .SH OPTIONS .TP -\fB\-a \fIADDRESS\fB:\fIPORT\fR -Listen on the given address. Both \fIADDRESS\fR and \fIPORT\fR are -optional, but at least one of them must be present. If \fIADDRESS\fR -is omitted, the colon must be retained. In that case the program will -listen on all configured IP addresses. If \fIPORT\fR is absent, the -colon must be omitted. In that case the default port 8080 will be used. +\fB\-c \fIFILE\fB +Read configuration from \fIFILE\fR, instead of \fB/etc/fileserv.conf\fR. +.TP +.B \-f +Run in foreground. +.TP +.B \-s +Run in single-process mode. In this mode, \fBfileserv\fR does not +start a sentinel process. +.TP +.B \-h +Display a terse command line summary and exit. +.TP +.B \-v +Increase verbosity level. Multiple options accumulate. +.SH CONFIGURATION FILE +The server reads most of its settings from the configuration file +\fB/etc/fileserv.conf\fR (the default location can be overridden using +the \fB\-c\fR command line option). The file has a traditional UNIX +configuration file syntax. Each statement occupies a single line and +consists of configuration keyword followed by one or more +values, separated by whitespace characters. Values containing +whitespace characters should be quoted (with either single or double +quote characters). Backslash character serves to escape the following +character. Usual \fBC\fR escapes are understood. Empty lines are +ignored. Comments are introduced by \fB#\fR symbol. +.PP +.TP +\fBuser\fR \fINAME\fR +Run as the user \fINAME\fR. Argument must be either login name of a +user listed in the user database, or a numeric UID prefixed with a +plus sign. + +Notice, that in single-process mode (see the \fB\-s\fR option) +switching to user privileges is performed before writing the PID file, +so make sure that the directory it is located in is writable for this +user (see the \fBpidfile\fR statement). +.TP +\fBgroup\fR \fINAME\fR +Run with primary group \fINAME\fR. Argument must be either the name of +a group listed in the user database, or a numeric GID prefixed with a +plus sign. By default, the primary group of the user supplied with +the \fBuser\fR statement will be used. + +Note, that supplementary groups are always honored. +.TP +\fBpidfile\fR \fBFILE\fR +Save PID of the running process to \fIFILE\fR. See the notice to the +\fBuser\fR statement, above. + +For compatibility with earlier versions, the keyword can also be +spelled as \fBpid\-file\fR. .TP -\fB\-F \fIFACILITY\fR -Send log messages to this syslog facility, instead of the default -\fBdaemon\fR. Valid facility names are +\fBmime\-types\-file\fR \fIFILE\fR +Name of the MIME magic file. This file is used to determine the +types of the files being served or listed. The file syntax is the same +as for \fBcups\fR. See +.BR mime.types (5), +for a detailed discussion. The \fBapache\fR's mime types file, which is a +simplification of this format, can also be used. +.TP +\fBlisten\fR \fIIPADDR\fB:\fIPORT\fR +Listen on the given IP address and port. Either IPADDR or PORT (but +not both) can be omitted. If IPADDR is omitted, the colon must be +retained. + +Notice, that multiple listen addresses are not supported. + +Default address is \fB0.0.0.0:8080\fR. +.TP +\fBaccess\-file\-name\fR \fINAME\fR +Name of the per-directory access file. The file has the same syntax as +the main configuration file, except that only the following statements +are allowed: +.BR directory\-index , +.BR follow , +.BR listing , +.BR list\-unreadable ", and" +.BR hidden-files . + +Default access file name is +.BR .fileserv . +.TP +\fBforwarded\-header\fR \fINAME\fR +Treat the value of the HTTP header \fINAME\fR as a comma-delimited list of +intermediate useragent IP addresses. To determine the actual useragent +IP, the list is traversed from right to left, until an IP is found +that is not listed as trusted-proxy address (see below). + +Default header name is +.BR X\-Forwarded\-For . +.TP +\fBtrusted\-proxy\fR \fBIP\fR [\fBIP\fR...] +List of IP addresses of trusted proxies. One or more IP addresses can +be given. Multiple statements accumulate. The initial list is empty. +.TP +\fBtemp\-dir\fR \fIDIR\fR +Store temporary files in \fIDIR\fR. Default is \fB/tmp\fR. +.TP +\fBsyslog\fR \fINAME\fR +Syslog facility name to use for reporting. Valid values for \fINAME\fR +are: .BR auth , .BR authpriv , .BR cron , -.BR daemon , +.BR daemon "(default), " .BR ftp , .BR kern , .BR lpr , @@ -107,34 +164,312 @@ and .B local0 through .BR local7. +.SS Access control settings +The statements discussed below configure access control +settings. These remain in effect for all subdirectories of the +selected mapping, until overridden by the corresponding statements in +the per-directory access files (see \fBaccess\-file\-name\fR, above). +.PP +Some of these statements take a boolean value (denoted as \fIBOOL\fR) +as their arguments. Valid boolean values are (case-insensitive): +.BR 1, +.BR yes , +.BR true , +or +.BR on, +indicating true value, and +.BR 0 , +.BR no , +.BR false "or ," +.BR off, +indicating false value. +.TP +\fBdirectory\-index\fR \fIFILE\fR [\fIFILE\fR...] +Directory index file names. One or more filename arguments are +expected. If the first argument is \fB+\fR (a plus sign), all subsequent +arguments are appended to the current list, instead of overwriting +it. This is for use in per-directory access files. +.TP +\fBfollow\fR \fIBOOL\fR +Follow symbolic links. If set to \fByes\fR, symbolic links appearing +in the request will be resolved. Notice, that the resulting file or +directory will be served only if it is located in one of the +configured mappings. + +Default is \fBno\fR. .TP -\fB\-f\fR -Remain in the foreground. +\fBlisting\fR \fIBOOL\fR +Enable directory listing mode. Directory listing will be returned as a +response for a request with URL mapping to a directory without valid +index file. The format of the listing file is configurable. See the +section \fBLISTING TEMPLATE\fR, for a detailed discussion. + +Default is \fBno\fR. .TP -\fB\-g \fIGROUP\fR -Run with privileges of \fIGROUP\fR. +\fBlist\-unreadable\fR \fIBOOL\fR +Whether to include in the listing the names of files that cannot be +read. + +Default is \fBno\fR. +.TP +\fBhidden\-files\fR \fIREGEX\fR [\fIREGEX\fR...] +When producing a directory listing, omit any files whose names match +one of the POSIX extended regular expressions from this list. +.SS Mapping +Mappings declare correspondence between URLs of incoming requests +and directories on the local filesystem. At least one mapping must +be defined. +.TP +\fBmapping\fR [\fIHOST\fB:\fR]\fIURL\fB:\fIDIR\fR +HTTP requests with path beginning with \fIURL\fR will be mapped to +local file paths beginning with \fIDIR\fR. Optional \fIHOST\fR part +limits the mapping to requests that have this value in the HTTP +"Host:" header. This is similar to Apache's \fBAlias\fR directive. +.SS Error documents +.TP +\fBerror\-dir\fR \fIDIR\fR +Look for customized versions of error pages in the directory \fIDIR\fR. +specified by the \fBerror\-dir statement. +.PP +When reporting a HTTP error, \fBfileserv\fR will search in that directory +for the first existing file from the following list: +\fICODE\fB.html\fR, +\fICODE\fB.html.var\fR, +\fIERR\fB.html,\fR, +\fIERR\fB.html.var\fR, +where \fICODE\fR is the HTTP error code, and \fIERR\fR is its internal name. +Allowed \fICODE\fRs and the corresponding \fIERR\fR names are: +403 (HTTP_FORBIDDEN), 404 (HTTP_NOT_FOUND), 405 (HTTP_METHOD_NOT_ALLOWED), +500 (HTTP_INTERNAL_SERVER_ERROR), 501 (HTTP_NOT_IMPLEMENTED), and +503 (HTTP_SERVICE_UNAVAILABLE). +.PP +If the file with \fB.html\fR suffix is found, it will be served as the body of +the error response. If the file with \fB.html.var\fR suffix is found, it +will be treated as a type map in Apache's \fBmod_negotiation\fR. +A type map has a format similar to RFC822 mail headers. It contains +error document descriptions separated by blank lines, with lines beginning +with a hash character treated as comments. A document description +consists of several header records; records may be continued on multiple +lines if the continuation lines start with spaces. The leading space will be +deleted and the lines concatenated. A header record consists of a keyword +name, which always ends in a colon, followed by a value. Whitespace is +allowed between the header name and value, and between the tokens of value. +The headers allowed are: +.TP +.B Content\-Language: +The language(s) of the variant, as an Internet standard language tag +(RFC 1766), e.g. en, meaning English. If the variant contains more than +one language, they are separated by a comma. + +This header is a look-up key. +.TP +.B Content\-Type: +The MIME media type of the document, with optional parameters. +.TP +.B Body: +The actual content of the error document is included in the type-map +file using the \fBBody\fR header. This header must contain a string that +designates a delimiter for the body content. Then all following lines +in the type map file will be considered part of the document body until +the delimiter string is found. +.PP +The server will select this error description whose Content-language header +matches the language definitions from the \fBAccept\-Language\fR +request header. +.SS Listing template +The following statements control generation of directory index +listings (see the \fBlisting\fR statement, above). .TP -\fB\-h\fR -Show short help message. +\fBindex\-template\fR \fIFILE\fR +By default, \fBfileserv\fR uses the built-in template (see +the file \fBsrc/defidx.html\fR). This statement instructs it to use +\fIFILE\fR instead. See the section \fBLISTING TEMPLATE FILE\fR, for a +discussion of its syntax. \fIFILE\fR must be an absolute file name. .TP -\fB\-p \fIFILE\fR -Store PID in \fIFILE\fR. The file must be located in directory -writable for the user \fBfileserv\fR runs as. +\fBindex\-css\fR \fIFILE\fR +Name of the CSS file to use in listings. It will be available in the +\fB$INDEXCSS\fR template variable. \fIFILE\fR must be an absolute file +name. .TP -\fB\-t\fR \fICIDR\fR -Defines a range of trusted IP addresses. \fICIDR\fR is either an IPv4 -or IPv6 address, or an address followed by slash and the length of the -network mask in decimal. The list of trusted IP addresses is used when -processing the \fBX\-Forwarded\-For\fR header in order to determine -the client IP address. +\fBmime\-icon\fR \fIURL\fR [\fBalt=\fITEXT\fR] \fITYPE\fR [\fITYPE\fR...] +Defines icon to use for files of given MIME types. Each \fITYPE\fR is +treated as globbing pattern (see \fBglob\fR(7)). \fIURL\fR is the +URL of the image file to be displayed for matching files, and \fITEXT\fR +is the alternative text. .TP -\fB\-x\fR \fIHEADER\fR -Get remote IP from \fIHEADER\fR, instead of \fBX\-Forwarded\-For\fR. +\fBname\-icon\fR \fIURL\fR [\fBalt=\fITEXT\fR] \fISUFFIX\fR [\fISUFFIX\fR...] +Defines icon for to use file names that end in one of the \fISUFFIX\Res. See +\fBmime\-icon\fR, for the description of \fIURL\fR and \fITYPE\fR. .TP -\fB\-u \fIUSER\fR -Run with this \fIUSER\fR privileges. +\fBtype\-icon\fR \fIURL\fR [\fBalt=\fITEXT\fR] \fITYPE\fR [\fITYPE\fR...] +Defines icon to use for file of the given type. Available \fITYPE\fRs +are: \fBDIRECTORY\fR, for a directory, \fBFILE\fR, for a regular file, +and \fBBLANK\fR, for a blank line. +.SH LISTING TEMPLATE +Listing template file is used to produce directory listings. It is a +normal HTML file, except for the following special constructs: +.TP +.BI "{% " STRING " %}" +Replaced with the expansion of \fISTRSING\fR +.TP +.BI "{% if " STRING " %}" +Starts conditional construct. The syntax is: +.EX +{% if \fISTRING\fR %} +.I " TEXT-IF-TRUE" +{% else %} +.I " TEXT-IF-FALSE" +{% endif %} +.EE +If the expansion if \fISTRING\fR is not empty, the construct is +replaced with \fITEXT-IF-TRUE\fR, otherwise it is replaced with +\fITEXT-IF-FALSE\fR. The else branch is optional. +.TP +.B {% loop %} +Starts main loop. The syntax is: + +.EX +{% loop %} +.I " TEXT" +{% endloop %} +.EE + +For each file found in the directory being listed, the loop construct +produces expansion of \fITEXT\fR. +.PP +The \fIexpansions\fR performed on strings in template constructs are: +.Ss Variable expansion +Variable expansion replaces each occurrence of +.BI $ NAME +or +.BI ${ NAME } +with the value of the templave variable \fINAME\fR. +.PP +The forms below test for a variable that is unset or null. Omitting the +colon results in a test only for a variable that is unset. +.TP +.BI ${ variable :- word } +.BR "Use Default Values" . +If \fIvariable\fR is unset or null, the expansion of \fIword\fR is substituted. +Otherwise, the value of \fIvariable\fR is substituted. +.TP +.BI ${ variable := word } +.BR "Assign Default Values" . +If \fIvariable\fR is unset or null, the expansion of \fIword\fR is +assigned to \fIvariable\fR. The value of \fIvariable\fR is then substituted. +.TP +.BI ${ variable :? word } +.BR "Display Error if Null or Unset" . +If \fIvariable\fR is null or unset, the expansion of \fIword\fR (or a +message to that effect if word is not present) is sent to the +program error output stream. Otherwise, the value of \fIvariable\fR is +substituted. +.TP +.BI ${ variable :+ word } +.BR "Use Alternate Value" . +If \fIvariable\fR is null or unset, nothing is substituted, otherwise the +expansion of \fIword\fR is substituted. +.PP +The following template variables are defined: +.TP +.B URI +URL of the object being listed. +.TP +.B INDEXCSS +The value of \fBindex\-css\fR configuration statement. +.PP +The following variables are available only within the loop construct: +.TP +.B ROWCLASS +Expands to the string \fBodd\fR or \fBeven\fR, depending on the number +of iteration within loop. +.TP +.B FILENAME +Current file name. +.TP +.B FILESIZE +Current file size. +.TP +.B FILETIME +Last modification time of the current file, in format "%Y-%m-%d %H:%M". +.TP +.B FILETYPE +Type of the current file: either \fBDIRECTORY\fR or \fBFILE\fR. +.TP +.B MIMETYPE +MIME type of the current file, as determined using the +\fBmime\-types\-file\fR. +.SS Command substitution +During \fIcommand substitution\fR, each word is scanned for commands. +Each command found is executed and replaced with the output it creates. +.PP +The syntax is: +.PP +.RS +4 +.BI $( command ) +.RE +.PP +Command substitutions may be nested. +.PP +Available template commands are: +.TP +.BI iconlookup " NAME MIME TYPE" +Look up the icon to use for file \fINAME\fR, using the list of +\fBname\-icon\fR statements. If no icon is found and the MIME type +\fIMIME\fR is given, look up the icon for that MIME type, using the +\fBmime\-icon\fR statements. If the icon file is not found after that +step, and the file type \fITYPE\fR is given, then look up the icon for +that type, using the \fBtype\-icon\fR configuration statements. On +success, return the \fIURL\fR of the icon. If no matching icon was found, +return empty string. +.TP +.B iconsrc +If the previous call to +.B $(iconlookup) +succeeded, returns the URL of the icon. +.TP +.B iconalt +If the previous call to +.B $(iconlookup) +succeeded, returns the alternative text for the icon, i.e. the +\fITEXT\fR part of the \fBalt=\fR parameter to the matching +\fBname\-icon\fR, \fBmime\-icon\fR, or \fBtype\-icon\fR statement. +.TP +.BI updir " URL" +Returns the URL obtained by removing the last firectory component from +the \fIURL\fR argument, or empty string if the latter is \fB/\fR. +.TP +.BI sortorder " COL" +Reverts the current sort order for the sorting column +\fICOL\fR. Possible values for the argument are: +.sp +.nf +.ta 8n 20n +.ul + N File name + M File modification date + S File size + D Description +.fi +.sp +Return value is \fBA\fR for ascending, and \fBD\fR for descending +order. +.sp +This function is useful to create listing ordering menu, e.g.: +.sp +.EX + <th> + <a href="?C=N&O={% $(sortorder N) %}">Name</a> + </th> + <th> + <a href="?C=M&O={% $(sortorder M) %}">Last modified</a> + </th> + <th> + <a href="?C=S&O={% $(sortorder S) %}">Size</a> + </th> +.EE9 .SH COPYRIGHT -Copyright \(co 2017 Sergey Poznyakoff +Copyright \(co 2017, 2018 Sergey Poznyakoff .br .na License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> diff --git a/src/fileserv.conf b/src/fileserv.conf new file mode 100644 index 0000000..1b56676 --- /dev/null +++ b/src/fileserv.conf @@ -0,0 +1,206 @@ +# Run as this user. +# Argument must be either login name of a user listed in the user database, +# or a numeric UID prefixed with a plus sign. +#user root + +# Run as this primary group. +# Argument must be either the name of a group listed in the user database, +# or a numeric GID prefixed with a plus sign. +# By default, the primary group of the user supplied with the 'user' statement +# will be used. +# Note that supplementary groups are always honored. +#group root + +# Name of the PID file +# Notice, that the file is created after assuming user privileges, so +# you should make sure that its directory is writable for the user +# fileserv is running as. +pidfile /var/run/fileserv.pid + +# Name of the MIME magic file. This file is used to determine the +# types of the files being served or listed. +mime-types-file /var/lib/fileserv/mime.types + +# Listen on the given interface +#listen 0.0.0.0:8080 + +# Name of the per-directory access file. +# The file has the same syntax as /etc/fileserv.conf, except that only +# the following statements are allowed: directory-index, follow, +# listing, list-unreadable, and hidden-files. +#access-file-name .fileserv + +# Treat the value of the specified header as a comma-delimited list of +# intermediate useragent IP addresses. To determine the actual useragent +# IP, the list is traversed from right to left, until an IP is found +# that is not listed as trusted-proxy address (see below). +# +#forwarded-header X-Forwarded-For + +# List of IP addresses of trusted proxies. Expects one or more arguments. +# Multiple statements accumulate. Initial list is empty. +trusted-proxy 127.0.0.1 + +# Directory for temporary files. +#temp-dir /tmp + +# Syslog facility to use for reporting. +#syslog daemon + +# Global access control settings. These remain in effect for all +# subdirectories of the selected mapping, until overridden by the +# corresponding statements in the per-directory access files (see +# access-file-name above). + +# Directory index file names. One or more filename arguments are +# expected. If the first argument is + (a plus sign), subsequent +# arguments are appended to the current list, instead of overwriting +# it. This is for use in per-directory access files. +directory-index index.html + +# Follow symbolic links. +# If set to "yes", symbolic links appearing in the request will be +# resolved. Notice, that the resulting file or directory will be served +# only if it is located in one of the configured mappings. +#follow no + +# Enable directory listing mode. +#listing no + +# Add unreadable files to the listing. +#list-unreadable no + +# When producing a directory listing, omit any files whose names match +# one of the POSIX extended regular expressions from this list. +hidden-files '^\..*' '^#' '~$' '\.rej$' '\.orig$' + +# MAPPINGS +# Mappings define which directories fileserv will be serving. +# +# Each statement declares a mapping between the URL of the incoming request +# and the directory on the local filesystem (think of Apache Alias directive). +# The syntax is +# [HOST:]URL:DIR +# URLs with a path beginning with URL will be mapped to local file paths +# beginning with DIR. Optional HOST part limits the mapping to requests that +# have this value in the HTTP Host: header. +# +# At least one mapping must be defined. + +mapping /:/var/www/static + +# ERROR DOCUMENTS +# Customized versions of error pages are looked up in the directory, +# specified by the error-dir statement. +# When reporting a HTTP error, fileserv will search in that directory +# for the first existing file from the following list: +# CODE.html, CODE.html.var, ERR.html, ERR.html.var +# where CODE is the HTTP error code, and ERR is its internal name. +# Allowed CODEs and the corresponding ERR names are: +# +# 403 HTTP_FORBIDDEN +# 404 HTTP_NOT_FOUND +# 405 HTTP_METHOD_NOT_ALLOWED +# 500 HTTP_INTERNAL_SERVER_ERROR +# 501 HTTP_NOT_IMPLEMENTED +# 503 HTTP_SERVICE_UNAVAILABLE +# +# If the file with .html suffix is found, it will be served as the body of +# the error response. If the file with .html.var suffix is found, it +# will be treated as a type map in Apache's mod_negotiation: +# A type map has a format similar to RFC822 mail headers. It contains +# error document descriptions separated by blank lines, with lines beginning +# with a hash character ('#') treated as comments. A document description +# consists of several header records; records may be continued on multiple +# lines if the continuation lines start with spaces. The leading space will be +# deleted and the lines concatenated. A header record consists of a keyword +# name, which always ends in a colon, followed by a value. Whitespace is +# allowed between the header name and value, and between the tokens of value. +# The headers allowed are: +# Content-Language: +# The language(s) of the variant, as an Internet standard language tag +# (RFC 1766), e.g. en, meaning English. If the variant contains more than +# one language, they are separated by a comma. +# This header is a look-up key +# Content-Type: +# The MIME media type of the document, with optional parameters. +# Body: +# The actual content of the error document is included in the type-map +# file using the Body header. This header must contain a string that +# designates a delimiter for the body content. Then all following lines +# in the type map file will be considered part of the document body until +# the delimiter string is found. +# Fileserv will select the error description whose Content-language header +# matches the language definitions from the Accept-Language request header. +#error-dir /var/lib/fileserv/error + +# INDEX TEMPLATE +# +# The following statements control generation of directory index +# listings for directories, where these are allowed (see the 'listing' +# statement, above). + +# By default, fileserv uses the built-in template (see src/defidx.html). +# The index-template statement supplies alternative template file. +#index-template /var/lib/fileserv/index.tmpl + +# Name of the CSS file. It will be available in the $INDEXCSS template +# variable. +#index-css /css/autoindex.css + +# Define icons for various MIME types. +# Syntax: +# mime-icon URL alt=TEXT TYPELIST +# where URL is the URL of the image file to be displayed for matching files, +# TEXT is the alternative text, +# TYPELIST is a whitespace-delimited list of one or more globbing +# patterns. +# When a file is being processed for the listing, its MIME type is determined +# using rules from the mime-types-file, then defined mime-icons are scanned +# until the MIME type matches one of patterns in the TYPELIST. + +# mime-icon /icons/compressed.gif alt=CMP */x-compress */x-gzip */x-bzip2 +# mime-icon /icons/text.gif alt=TXT text/* +# mime-icon /icons/image2.gif alt=IMG image/* +# mime-icon /icons/sound2.gif alt=SND audio/* +# mime-icon /icons/movie.gif alt=VID video/* +# mime-icon /icons/text.gif alt=TXT text/* +# mime-icon /icons/image2.gif alt=IMG image/* +# mime-icon /icons/sound2.gif alt=SND audio/* +# mime-icon /icons/movie.gif alt=VID video/* +# mime-icon /icons/unknown.gif alt=FILE */* + +# Define icons for various file names. +# Syntax: +# name-icon URL alt=TEXT SUFFIXLIST +# where URL is the URL of the image file to be displayed for matching files, +# TEXT is the alternative text, +# SUFFIXLIST is a whitespace-delimited list of one or more file suffixes. +# +# name-icon /icons/back.gif alt=BACK .. +# name-icon /icons/script.gif alt=SCRIPT .conf .sh .shar .csh .ksh .tcl +# name-icon /icons/hand.right.gif README +# name-icon /icons/compressed.gif alt=CMP .Z .z .tgz .txz .tbz .gz .xz .bz2 .lzip +# .zip +# name-icon /icons/uuencoded.gif alt=UU .uu +# name-icon /icons/a.gif alt=PS .ps .ai .eps +# name-icon /icons/layout.gif alt=HTML .html .shtml .htm +# name-icon /icons/layout.gif alt=PDF .pdf +# name-icon /icons/text.gif alt=TXT .txt +# name-icon /icons/c.gif alt=SRC .c +# name-icon /icons/p.gif alt=SRC .pl .py +# name-icon /icons/f.gif alt=SRC .for +# name-icon /icons/dvi.gif alt=DVI .dvi +# name-icon /icons/tex.gif alt=TEX .tex +# name-icon /icons/bomb.gif alt=CORE core + +# Define icons for various file types. +# Syntax: +# type-icon URL alt=TEXT TYPELIST +# where URL is the URL of the image file to be displayed for matching files, +# TEXT is the alternative text, +# TYPELIST is a whitespace-delimited list of one or more file types. +# +# type-icon /icons/folder.gif alt=DIR DIRECTORY +# type-icon /icons/blank.gif alt=ICO BLANK +# type-icon /icons/unknown.gif alt=FILE FILE @@ -608,7 +608,6 @@ exp_filetype(char **ret, EVAL_ENV *env) if (env->ent) s = S_ISDIR(env->ent->st.st_mode) ? "DIRECTORY" : "FILE"; return retstr(ret, s); - return *ret ? WRDSE_OK : WRDSE_NOSPACE; } struct var_dcl { |