mod_cgid.c revision 73e8b26287de5c06fa470d36162e103dbac9c7e5
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering/* ====================================================================
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * The Apache Software License, Version 1.1
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * Copyright (c) 2000 The Apache Software Foundation. All rights
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * Redistribution and use in source and binary forms, with or without
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * modification, are permitted provided that the following conditions
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * 1. Redistributions of source code must retain the above copyright
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * notice, this list of conditions and the following disclaimer.
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * 2. Redistributions in binary form must reproduce the above copyright
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * notice, this list of conditions and the following disclaimer in
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * the documentation and/or other materials provided with the
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * distribution.
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * 3. The end-user documentation included with the redistribution,
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * if any, must include the following acknowledgment:
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * "This product includes software developed by the
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * Apache Software Foundation (http://www.apache.org/)."
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * Alternately, this acknowledgment may appear in the software itself,
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * if and wherever such third-party acknowledgments normally appear.
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * 4. The names "Apache" and "Apache Software Foundation" must
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * not be used to endorse or promote products derived from this
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * software without prior written permission. For written
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * permission, please contact apache@apache.org.
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * 5. Products derived from this software may not be called "Apache",
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * nor may "Apache" appear in their name, without prior written
8e54f5d90a6b9dd1ff672fb97ea98de66c49e332Lennart Poettering * permission of the Apache Software Foundation.
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
0d2cd47617b423f37d7425be7a56ae2fca8ff9f6Lennart Poettering * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8e54f5d90a6b9dd1ff672fb97ea98de66c49e332Lennart Poettering * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
8e54f5d90a6b9dd1ff672fb97ea98de66c49e332Lennart Poettering * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
0c8570287400ba57d3705a2f62dd26039121ea6fLennart Poettering * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
0c8570287400ba57d3705a2f62dd26039121ea6fLennart Poettering * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
#define CORE_PRIVATE
#include "apr_lib.h"
#include "apr_strings.h"
#include "apr_general.h"
#include "apr_file_io.h"
#include "apr_portable.h"
#include "ap_buckets.h"
#include "util_filter.h"
#include "httpd.h"
#include "http_config.h"
#include "http_request.h"
#include "http_core.h"
#include "http_protocol.h"
#include "http_main.h"
#include "http_log.h"
#include "util_script.h"
#include "http_conf_globals.h"
#include "ap_mpm.h"
#include "unixd.h"
#ifdef HAVE_SYS_SOCKET_H
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#ifndef DEFAULT_CGID_LISTENBACKLOG
const char *sockname;
const char *logname;
long logbytes;
int bufbytes;
int x, numwords;
char **av;
int idx = 0;
++numwords;
if (path) {
if (user) {
if (group) {
ap_unescape_url(w);
return av;
switch (reason) {
case APR_OC_REASON_DEATH:
case APR_OC_REASON_LOST:
case APR_OC_REASON_RESTART:
case APR_OC_REASON_UNREGISTER:
int i, len, j;
unsigned char *data;
char **environ;
void **dconf;
#ifdef RLIMIT_CPU
#ifdef RLIMIT_NPROC
int len;
char *data;
NULL);
for (i =0; env[i]; i++) {
for (i = 0; env[i]; i++) {
#ifdef RLIMIT_CPU
len = 0;
len = 0;
#ifdef RLIMIT_NPROC
len = 0;
return errno;
if (rc < 0) {
return errno;
return errno;
if (!geteuid()) {
return errno;
char *argv0;
char *filename;
char **env;
const char * const *argv;
apr_pool_t *p;
request_rec *r;
if (sd2 < 0) {
r->pool = p;
(const char * const *)env,
procattr, p);
void *data;
int first_time = 0;
if (!data) {
if (!first_time) {
else if (pid == 0) {
cgid_server_conf *c =
return NULL;
return NULL;
return NULL;
return NULL;
{NULL}
return ret;
apr_close(f);
return ret;
if (script_err) {
return ret;
&& *dbuf) {
if (script_err) {
if (script_err) {
apr_close(f);
return ret;
ap_bucket *b;
void *sconf;
int is_included;
int sd;
char **env;
return DECLINED;
return DECLINED;
argv0++;
argv0++;
ap_add_cgi_vars(r);
return retval;
argv0++;
if (ap_should_client_block(r)) {
dbpos = 0;
while ((len_read =
if (!nph) {
const char *location;
int ret;
return OK;
return HTTP_MOVED_TEMPORARILY;
if (!r->header_only) {
b = ap_bucket_create_eos();
if (nph) {
b = ap_bucket_create_eos();