mod_cern_meta.c revision 032b8a34c3911bbc5ad5385ca40af65af273bff9
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * ==================================================================== * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * Portions of this software are based upon public domain software * originally written at the National Center for Supercomputing Applications, * University of Illinois, Urbana-Champaign. * Andrew Wilson <Andrew.Wilson@cm.cf.ac.uk> 25.Jan.96 * per-directory basis. Previous versions of the module defined behaviour * on a per-server basis. The upshot is that you'll need to revisit your * configuration files in order to make use of the new module. * Emulate the CERN HTTPD Meta file semantics. Meta files are HTTP * headers that can be output in addition to the normal range of * headers for each file accessed. They appear rather like the Apache * .asis files, and are able to provide a crude way of influencing * the Expires: header, as well as providing other curiosities. * There are many ways to manage meta information, this one was * chosen because there is already a large number of CERN users * who can exploit this module. It should be noted that there are probably * more sensitive ways of managing the Expires: header specifically. * The module obeys the following directives, which can appear * in the server's .conf files and in .htaccess files. * turns on|off meta file processing for any directory. * # turn on MetaFiles in this directory * MetaDir <directory name> * specifies the name of the directory in which Apache can find * meta information files. The directory is usually a 'hidden' * subdirectory of the directory that contains the file being * # .meta files are in the *same* directory as the * the default is to look in a '.web' subdirectory. This is the * same as for CERN 3.+ webservers and behaviour is the same as * MetaSuffix <meta file suffix> * specifies the file name suffix for the file containing the * # our meta files are suffixed with '.cern_meta' * the default is to look for files with the suffix '.meta'. This * behaviour is the same as for the directive: * When accessing the file * this module will look for the file * and will use its contents to generate additional MIME header * For more information on the CERN Meta file semantics see: * DECLINE when real file not found, we may be checking each * need to report missing ones as spurious errors. * 31.Jan.96 log_error reports about a malformed .meta file, rather * 20.Jun.96 MetaFiles <on|off> default off, added, so that module * can be configured per-directory. Prior to this the module * was running for each request anywhere on the server, naughty.. * 29.Jun.96 All directives made per-directory. "Limited to 'on' or 'off'"},
"the name of the directory containing meta files"},
"the filename suffix for meta files"},
/* XXX: this is very similar to ap_scan_script_header_err_core... * are the differences deliberate, or just a result of bit rot? /* Delete terminal (CR?)LF */ if (p > 0 && w[p -
1] ==
'\n') {
if (p >
1 && w[p -
2] ==
'\015')
/* if we see a bogus header don't ignore it. Shout and scream */ "malformed header in meta file: %s", r->
filename);
/* Nuke trailing whitespace */ /* if ./.web/$1.meta exists then output 'asis' */ /* is this a directory? */ /* what directory is this file in? */ /* skip leading slash, recovered in later processing */ /* skip over last slash */ /* no last slash, buh?! */ "internal error in mod_cern_meta: %s", r->
filename);
/* should really barf, but hey, let's be friends... */ /* XXX: it sucks to require this subrequest to complete, because this * means people must leave their meta files accessible to the world. * A better solution might be a "safe open" feature of pfopen to avoid * pipes, symlinks, and crap like that. "meta file permissions deny server access: %s",
metafilename);
/* read the headers in */ NULL,
/* server config */ NULL,
/* merge server configs */