mod_cgid.c revision b980ad7fdc218b4855cde9f75a747527f50c554d
9ff48d0982fcb97923955685fe9fa4e0e67cb238Zbigniew Jędrzejewski-Szmek/* ====================================================================
9ff48d0982fcb97923955685fe9fa4e0e67cb238Zbigniew Jędrzejewski-Szmek * The Apache Software License, Version 1.1
9ff48d0982fcb97923955685fe9fa4e0e67cb238Zbigniew Jędrzejewski-Szmek * Copyright (c) 2000 The Apache Software Foundation. All rights
9ff48d0982fcb97923955685fe9fa4e0e67cb238Zbigniew Jędrzejewski-Szmek * Redistribution and use in source and binary forms, with or without
9ff48d0982fcb97923955685fe9fa4e0e67cb238Zbigniew Jędrzejewski-Szmek * modification, are permitted provided that the following conditions
9ff48d0982fcb97923955685fe9fa4e0e67cb238Zbigniew Jędrzejewski-Szmek * 1. Redistributions of source code must retain the above copyright
9ff48d0982fcb97923955685fe9fa4e0e67cb238Zbigniew Jędrzejewski-Szmek * notice, this list of conditions and the following disclaimer.
9ff48d0982fcb97923955685fe9fa4e0e67cb238Zbigniew Jędrzejewski-Szmek * 2. Redistributions in binary form must reproduce the above copyright
9ff48d0982fcb97923955685fe9fa4e0e67cb238Zbigniew Jędrzejewski-Szmek * notice, this list of conditions and the following disclaimer in
9ff48d0982fcb97923955685fe9fa4e0e67cb238Zbigniew Jędrzejewski-Szmek * the documentation and/or other materials provided with the
9ff48d0982fcb97923955685fe9fa4e0e67cb238Zbigniew Jędrzejewski-Szmek * 3. The end-user documentation included with the redistribution,
9ff48d0982fcb97923955685fe9fa4e0e67cb238Zbigniew Jędrzejewski-Szmek * if any, must include the following acknowledgment:
9ff48d0982fcb97923955685fe9fa4e0e67cb238Zbigniew Jędrzejewski-Szmek * "This product includes software developed by the
9ff48d0982fcb97923955685fe9fa4e0e67cb238Zbigniew Jędrzejewski-Szmek * Apache Software Foundation (http://www.apache.org/)."
9ff48d0982fcb97923955685fe9fa4e0e67cb238Zbigniew Jędrzejewski-Szmek * Alternately, this acknowledgment may appear in the software itself,
9ff48d0982fcb97923955685fe9fa4e0e67cb238Zbigniew Jędrzejewski-Szmek * if and wherever such third-party acknowledgments normally appear.
9ff48d0982fcb97923955685fe9fa4e0e67cb238Zbigniew Jędrzejewski-Szmek * 4. The names "Apache" and "Apache Software Foundation" must
9ff48d0982fcb97923955685fe9fa4e0e67cb238Zbigniew Jędrzejewski-Szmek * not be used to endorse or promote products derived from this
9ff48d0982fcb97923955685fe9fa4e0e67cb238Zbigniew Jędrzejewski-Szmek * software without prior written permission. For written
9ff48d0982fcb97923955685fe9fa4e0e67cb238Zbigniew Jędrzejewski-Szmek * permission, please contact apache@apache.org.
#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 "apr_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;
apr_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 = apr_bucket_create_eos();
if (nph) {
b = apr_bucket_create_eos();