os.c revision cccd31fa4a72fe23cc3249c06db181b274a55a69
0066eddda7203f6345b56f77d146a759298dc635gryzor/* ====================================================================
0066eddda7203f6345b56f77d146a759298dc635gryzor * The Apache Software License, Version 1.1
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd *
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * Copyright (c) 2000 The Apache Software Foundation. All rights
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * reserved.
0066eddda7203f6345b56f77d146a759298dc635gryzor *
0066eddda7203f6345b56f77d146a759298dc635gryzor * Redistribution and use in source and binary forms, with or without
0066eddda7203f6345b56f77d146a759298dc635gryzor * modification, are permitted provided that the following conditions
0066eddda7203f6345b56f77d146a759298dc635gryzor * are met:
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc *
0066eddda7203f6345b56f77d146a759298dc635gryzor * 1. Redistributions of source code must retain the above copyright
0066eddda7203f6345b56f77d146a759298dc635gryzor * notice, this list of conditions and the following disclaimer.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen *
2e545ce2450a9953665f701bb05350f0d3f26275nd * 2. Redistributions in binary form must reproduce the above copyright
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * notice, this list of conditions and the following disclaimer in
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * the documentation and/or other materials provided with the
0066eddda7203f6345b56f77d146a759298dc635gryzor * distribution.
0066eddda7203f6345b56f77d146a759298dc635gryzor *
0066eddda7203f6345b56f77d146a759298dc635gryzor * 3. The end-user documentation included with the redistribution,
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen * if any, must include the following acknowledgment:
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * "This product includes software developed by the
0066eddda7203f6345b56f77d146a759298dc635gryzor * Apache Software Foundation (http://www.apache.org/)."
0066eddda7203f6345b56f77d146a759298dc635gryzor * Alternately, this acknowledgment may appear in the software itself,
0066eddda7203f6345b56f77d146a759298dc635gryzor * if and wherever such third-party acknowledgments normally appear.
3f08db06526d6901aa08c110b5bc7dde6bc39905nd *
0066eddda7203f6345b56f77d146a759298dc635gryzor * 4. The names "Apache" and "Apache Software Foundation" must
0066eddda7203f6345b56f77d146a759298dc635gryzor * not be used to endorse or promote products derived from this
0066eddda7203f6345b56f77d146a759298dc635gryzor * software without prior written permission. For written
0066eddda7203f6345b56f77d146a759298dc635gryzor * permission, please contact apache@apache.org.
0066eddda7203f6345b56f77d146a759298dc635gryzor *
0066eddda7203f6345b56f77d146a759298dc635gryzor * 5. Products derived from this software may not be called "Apache",
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung * nor may "Apache" appear in their name, without prior written
0066eddda7203f6345b56f77d146a759298dc635gryzor * permission of the Apache Software Foundation.
0066eddda7203f6345b56f77d146a759298dc635gryzor *
0066eddda7203f6345b56f77d146a759298dc635gryzor * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
0066eddda7203f6345b56f77d146a759298dc635gryzor * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1a1356f375e36db7bee379ea0684ab389579f798rbowen * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
0066eddda7203f6345b56f77d146a759298dc635gryzor * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
0066eddda7203f6345b56f77d146a759298dc635gryzor * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0066eddda7203f6345b56f77d146a759298dc635gryzor * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0066eddda7203f6345b56f77d146a759298dc635gryzor * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
0066eddda7203f6345b56f77d146a759298dc635gryzor * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
0066eddda7203f6345b56f77d146a759298dc635gryzor * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
0066eddda7203f6345b56f77d146a759298dc635gryzor * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
0066eddda7203f6345b56f77d146a759298dc635gryzor * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
0066eddda7203f6345b56f77d146a759298dc635gryzor * SUCH DAMAGE.
0066eddda7203f6345b56f77d146a759298dc635gryzor * ====================================================================
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar *
01f52ba6a87aa39d3873a441369828875c471823trawick * This software consists of voluntary contributions made by many
01f52ba6a87aa39d3873a441369828875c471823trawick * individuals on behalf of the Apache Software Foundation. For more
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar * information on the Apache Software Foundation, please see
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar * <http://www.apache.org/>.
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar *
0066eddda7203f6345b56f77d146a759298dc635gryzor * Portions of this software are based upon public domain software
0066eddda7203f6345b56f77d146a759298dc635gryzor * originally written at the National Center for Supercomputing Applications,
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh * University of Illinois, Urbana-Champaign.
01f52ba6a87aa39d3873a441369828875c471823trawick */
01f52ba6a87aa39d3873a441369828875c471823trawick
01f52ba6a87aa39d3873a441369828875c471823trawick/*
0066eddda7203f6345b56f77d146a759298dc635gryzor * This file will include OS specific functions which are not inlineable.
01f52ba6a87aa39d3873a441369828875c471823trawick * Any inlineable functions should be defined in os-inline.c instead.
01f52ba6a87aa39d3873a441369828875c471823trawick */
01f52ba6a87aa39d3873a441369828875c471823trawick
01f52ba6a87aa39d3873a441369828875c471823trawick#include "httpd.h"
01f52ba6a87aa39d3873a441369828875c471823trawick#include "http_core.h"
01f52ba6a87aa39d3873a441369828875c471823trawick#include "os.h"
01f52ba6a87aa39d3873a441369828875c471823trawick#include "httpd.h"
8d71cfe50621fe78b960ccef99680b89bb61170elgentis
01f52ba6a87aa39d3873a441369828875c471823trawick/* Check the Content-Type to decide if conversion is needed */
01f52ba6a87aa39d3873a441369828875c471823trawickint ap_checkconv(struct request_rec *r)
01f52ba6a87aa39d3873a441369828875c471823trawick{
01f52ba6a87aa39d3873a441369828875c471823trawick int convert_to_ascii;
01f52ba6a87aa39d3873a441369828875c471823trawick const char *type;
01f52ba6a87aa39d3873a441369828875c471823trawick
01f52ba6a87aa39d3873a441369828875c471823trawick /* To make serving of "raw ASCII text" files easy (they serve faster
20f499565e77defe9dab24dd85c02f38a1175855nd * since they don't have to be converted from EBCDIC), a new
01f52ba6a87aa39d3873a441369828875c471823trawick * "magic" type prefix was invented: text/x-ascii-{plain,html,...}
01f52ba6a87aa39d3873a441369828875c471823trawick * If we detect one of these content types here, we simply correct
01f52ba6a87aa39d3873a441369828875c471823trawick * the type to the real text/{plain,html,...} type. Otherwise, we
01f52ba6a87aa39d3873a441369828875c471823trawick * set a flag that translation is required later on.
01f52ba6a87aa39d3873a441369828875c471823trawick */
01f52ba6a87aa39d3873a441369828875c471823trawick
01f52ba6a87aa39d3873a441369828875c471823trawick type = (r->content_type == NULL) ? ap_default_type(r) : r->content_type;
01f52ba6a87aa39d3873a441369828875c471823trawick
01f52ba6a87aa39d3873a441369828875c471823trawick /* If no content type is set then treat it as (ebcdic) text/plain */
20f499565e77defe9dab24dd85c02f38a1175855nd convert_to_ascii = (type == NULL);
01f52ba6a87aa39d3873a441369828875c471823trawick
01f52ba6a87aa39d3873a441369828875c471823trawick /* Conversion is applied to text/ files only, if ever. */
01f52ba6a87aa39d3873a441369828875c471823trawick if (type && (strncasecmp(type, "text/", 5) == 0 ||
01f52ba6a87aa39d3873a441369828875c471823trawick strncasecmp(type, "message/", 8) == 0)) {
01f52ba6a87aa39d3873a441369828875c471823trawick if (strncasecmp(type, ASCIITEXT_MAGIC_TYPE_PREFIX,
0066eddda7203f6345b56f77d146a759298dc635gryzor sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1) == 0)
0066eddda7203f6345b56f77d146a759298dc635gryzor r->content_type = apr_pstrcat(r->pool, "text/",
0066eddda7203f6345b56f77d146a759298dc635gryzor type+sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1,
0066eddda7203f6345b56f77d146a759298dc635gryzor NULL);
0066eddda7203f6345b56f77d146a759298dc635gryzor else
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung /* translate EBCDIC to ASCII */
727872d18412fc021f03969b8641810d8896820bhumbedooh convert_to_ascii = 1;
0d0ba3a410038e179b695446bb149cce6264e0abnd }
727872d18412fc021f03969b8641810d8896820bhumbedooh /* Enable conversion if it's a text document */
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, convert_to_ascii);
0d0ba3a410038e179b695446bb149cce6264e0abnd
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh return convert_to_ascii;
727872d18412fc021f03969b8641810d8896820bhumbedooh}
0d0ba3a410038e179b695446bb149cce6264e0abnd
0d0ba3a410038e179b695446bb149cce6264e0abndAP_DECLARE(apr_status_t) ap_os_create_privileged_process(
0d0ba3a410038e179b695446bb149cce6264e0abnd const request_rec *r,
ac082aefa89416cbdc9a1836eaf3bed9698201c8humbedooh apr_proc_t *newproc, const char *progname,
0d0ba3a410038e179b695446bb149cce6264e0abnd const char * const *args,
0d0ba3a410038e179b695446bb149cce6264e0abnd const char * const *env,
0d0ba3a410038e179b695446bb149cce6264e0abnd apr_procattr_t *attr, apr_pool_t *p)
727872d18412fc021f03969b8641810d8896820bhumbedooh{
0d0ba3a410038e179b695446bb149cce6264e0abnd return apr_create_process(newproc, progname, args, env, attr, p);
0d0ba3a410038e179b695446bb149cce6264e0abnd}
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh
205f749042ed530040a4f0080dbcb47ceae8a374rjung