main.c revision fb0c14f07aa634d66663d85fa621c99a53bc74e4
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering/* ====================================================================
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering * The Apache Software License, Version 1.1
12b42c76672a66c2d4ea7212c14f8f1b5a62b78dTom Gundersen *
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering * Copyright (c) 2000 The Apache Software Foundation. All rights
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering * reserved.
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering *
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering * Redistribution and use in source and binary forms, with or without
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering * modification, are permitted provided that the following conditions
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering * are met:
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering *
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering * 1. Redistributions of source code must retain the above copyright
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering * notice, this list of conditions and the following disclaimer.
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering *
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering * 2. Redistributions in binary form must reproduce the above copyright
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering * notice, this list of conditions and the following disclaimer in
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering * the documentation and/or other materials provided with the
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering * distribution.
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering *
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering * 3. The end-user documentation included with the redistribution,
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering * if any, must include the following acknowledgment:
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering * "This product includes software developed by the
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering * Apache Software Foundation (http://www.apache.org/)."
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering * Alternately, this acknowledgment may appear in the software itself,
56ba3c78ae35065064c4289a0c8e22a81256af20Zbigniew Jędrzejewski-Szmek * if and wherever such third-party acknowledgments normally appear.
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering *
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * 4. The names "Apache" and "Apache Software Foundation" must
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * not be used to endorse or promote products derived from this
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * software without prior written permission. For written
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * permission, please contact apache@apache.org.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek *
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * 5. Products derived from this software may not be called "Apache",
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * nor may "Apache" appear in their name, without prior written
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * permission of the Apache Software Foundation.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek *
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * SUCH DAMAGE.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * ====================================================================
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering *
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * This software consists of voluntary contributions made by many
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * individuals on behalf of the Apache Software Foundation. For more
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * information on the Apache Software Foundation, please see
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * <http://www.apache.org/>.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek *
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * Portions of this software are based upon public domain software
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * originally written at the National Center for Supercomputing Applications,
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * University of Illinois, Urbana-Champaign.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#define CORE_PRIVATE
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#include "ap_config.h"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#include "httpd.h"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#include "http_main.h"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#include "http_log.h"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#include "http_config.h"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#include "http_vhost.h"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#include "util_uri.h"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#include "util_ebcdic.h"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#include "apr_getopt.h"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#include "ap_mpm.h"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* WARNING: Win32 binds http_main.c dynamically to the server. Please place
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering * extern functions and global data in another appropriate module.
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering *
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering * Most significant main() global data can be found in http_config.c
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering */
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* XXX - We should be able to grab the per-MPM settings here too */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekstatic void show_compile_settings(void)
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek{
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf("Server version: %s\n", ap_get_server_version());
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf("Server built: %s\n", ap_get_server_built());
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf("Server's Module Magic Number: %u:%u\n",
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf("Server compiled with....\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef BIG_SECURITY_HOLE
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D BIG_SECURITY_HOLE\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef SECURITY_HOLE_PASS_AUTHORIZATION
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D SECURITY_HOLE_PASS_AUTHORIZATION\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef APR_HAS_MMAP
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D HAVE_MMAP\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef HAVE_SHMGET
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D HAVE_SHMGET\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef USE_FILE_BASED_SCOREBOARD
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D USE_FILE_BASED_SCOREBOARD\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef USE_MEM_BASED_SCOREBOARD
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D USE_MEM_BASED_SCOREBOARD\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef USE_MMAP_FILES
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D USE_MMAP_FILES\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef MMAP_SEGMENT_SIZE
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D MMAP_SEGMENT_SIZE=%ld\n",(long)MMAP_SEGMENT_SIZE);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif /*USE_MMAP_FILES*/
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef NO_WRITEV
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D NO_WRITEV\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef NO_LINGCLOSE
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D NO_LINGCLOSE\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#if APR_USE_FLOCK_SERIALIZE
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D APR_USE_FLOCK_SERIALIZE\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#if APR_USE_SYSVSEM_SERIALIZE
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D APR_USE_SYSVSEM_SERIALIZE\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#if APR_USE_FCNTL_SERIALIZE
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D APR_USE_FCNTL_SERIALIZE\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#if APR_USE_PROC_PTHREAD_SERIALIZE
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D APR_USE_PROC_PTHREAD_SERIALIZE\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#if APR_USE_PTHREAD_SERIALIZE
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D APR_USE_PTHREAD_SERIALIZE\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering#ifdef SINGLE_LISTEN_UNSERIALIZED_ACCEPT
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering printf(" -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT\n");
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering#endif
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering#ifdef APR_HAS_OTHER_CHILD
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering printf(" -D APR_HAS_OTHER_CHILD\n");
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering#endif
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering#ifdef HAVE_RELIABLE_PIPED_LOGS
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering printf(" -D HAVE_RELIABLE_PIPED_LOGS\n");
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering#endif
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering#ifdef BUFFERED_LOGS
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering printf(" -D BUFFERED_LOGS\n");
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering#ifdef PIPE_BUF
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering printf(" -D PIPE_BUF=%ld\n",(long)PIPE_BUF);
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering#endif
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering#endif
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering#ifdef CHARSET_EBCDIC
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering printf(" -D CHARSET_EBCDIC\n");
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering#endif
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering#ifdef APACHE_XLATE
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering printf(" -D APACHE_XLATE\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef NEED_HASHBANG_EMUL
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D NEED_HASHBANG_EMUL\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef SHARED_CORE
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D SHARED_CORE\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering/* This list displays the compiled in default paths: */
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering#ifdef HTTPD_ROOT
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering printf(" -D HTTPD_ROOT=\"" HTTPD_ROOT "\"\n");
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef SUEXEC_BIN
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D SUEXEC_BIN=\"" SUEXEC_BIN "\"\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#if defined(SHARED_CORE) && defined(SHARED_CORE_DIR)
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D SHARED_CORE_DIR=\"" SHARED_CORE_DIR "\"\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef DEFAULT_PIDLOG
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D DEFAULT_PIDLOG=\"" DEFAULT_PIDLOG "\"\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef DEFAULT_SCOREBOARD
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D DEFAULT_SCOREBOARD=\"" DEFAULT_SCOREBOARD "\"\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef DEFAULT_LOCKFILE
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D DEFAULT_LOCKFILE=\"" DEFAULT_LOCKFILE "\"\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef DEFAULT_XFERLOG
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D DEFAULT_XFERLOG=\"" DEFAULT_XFERLOG "\"\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef DEFAULT_ERRORLOG
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D DEFAULT_ERRORLOG=\"" DEFAULT_ERRORLOG "\"\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef TYPES_CONFIG_FILE
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D TYPES_CONFIG_FILE=\"" TYPES_CONFIG_FILE "\"\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef SERVER_CONFIG_FILE
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D SERVER_CONFIG_FILE=\"" SERVER_CONFIG_FILE "\"\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek}
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekstatic void destroy_and_exit_process(process_rec *process, int process_exit_value)
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek{
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek ap_destroy_pool(process->pool); /* and destroy all descendent pools */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek ap_terminate();
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering exit(process_exit_value);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek}
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekstatic process_rec *create_process(int argc, char *const *argv)
667c24a6a86a5a26a906b7477ae81dcf4c73e64eLennart Poettering{
667c24a6a86a5a26a906b7477ae81dcf4c73e64eLennart Poettering process_rec *process;
667c24a6a86a5a26a906b7477ae81dcf4c73e64eLennart Poettering
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering {
667c24a6a86a5a26a906b7477ae81dcf4c73e64eLennart Poettering ap_pool_t *cntx;
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering ap_status_t stat;
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering stat = ap_create_pool(&cntx, NULL);
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering if (stat != APR_SUCCESS) {
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, NULL,
667c24a6a86a5a26a906b7477ae81dcf4c73e64eLennart Poettering "ap_create_pool() failed to create "
667c24a6a86a5a26a906b7477ae81dcf4c73e64eLennart Poettering "initial context");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek ap_terminate();
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek exit(1);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek }
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek process = ap_palloc(cntx, sizeof(process_rec));
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek process->pool = cntx;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek }
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek ap_create_pool(&process->pconf, process->pool);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek process->argc = argc;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek process->argv = argv;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek process->short_name = ap_filename_of_pathname(argv[0]);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek return process;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek}
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekstatic void usage(process_rec *process)
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek{
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek const char *bin = process->argv[0];
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek char pad[MAX_STRING_LEN];
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek unsigned i;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek for (i = 0; i < strlen(bin); i++)
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek pad[i] = ' ';
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek pad[i] = '\0';
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef SHARED_CORE
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0,NULL , "Usage: %s [-R directory] [-D name] [-d directory] [-f file]", bin);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#else
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Usage: %s [-D name] [-d directory] [-f file]", bin);
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering#endif
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " %s [-C \"directive\"] [-c \"directive\"]", pad);
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering#ifdef WIN32
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " %s [-k restart|shutdown|start]", pad);
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " %s [-n service_name]", pad);
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " %s [-i] [-u]", pad);
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering#endif
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " %s [-v] [-V] [-h] [-l] [-L] [-S] [-t] [-T]", pad);
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Options:");
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering#ifdef SHARED_CORE
7ca4155737730ece73ae4b4ac80571005cb99b69Jan Engelhardt ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -R directory : specify an alternate location for shared object files");
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering#endif
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -D name : define a name for use in <IfDefine name> directives");
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -d directory : specify an alternate initial ServerRoot");
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -f file : specify an alternate ServerConfigFile");
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -C \"directive\" : process directive before reading config files");
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -c \"directive\" : process directive after reading config files");
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering#ifdef WIN32
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -n name : set service name and use its ServerConfigFile");
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -k shutdown : tell running Apache to shutdown");
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -k restart : tell running Apache to do a graceful restart");
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -k start : tell Apache to start");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -i : install an Apache service");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -u : uninstall an Apache service");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -v : show version number");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -V : show compile settings");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -h : list available command line options (this page)");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -l : list compiled in modules");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -L : list available configuration directives");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek /* TODOC: -S has been replaced by '-t -D DUMP_VHOSTS' */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek /* ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -S : show parsed settings (currently only vhost settings)"); */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -t : run syntax check for config files (with docroot check)");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -T : run syntax check for config files (without docroot check)");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek /* TODOC: -X goes away, expect MPMs to use -D options */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek destroy_and_exit_process(process, 1);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek}
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint main(int argc, char *argv[])
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek{
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek int c;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek int configtestonly = 0;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek const char *confname = SERVER_CONFIG_FILE;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek const char *def_server_root = HTTPD_ROOT;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek process_rec *process;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek server_rec *server_conf;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek ap_pool_t *pglobal;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek ap_pool_t *pconf;
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering ap_pool_t *plog; /* Pool of log streams, reset _after_ each read of conf */
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering ap_pool_t *ptemp; /* Pool for temporary config stuff, reset often */
ap_pool_t *pcommands; /* Pool for -D, -C and -c switches */
module **mod;
ap_directive_t *conftree = NULL;
ap_initialize();
process = create_process(argc, (char *const *)argv);
pglobal = process->pool;
pconf = process->pconf;
ap_server_argv0 = process->short_name;
#ifdef CHARSET_EBCDIC
if (ap_init_ebcdic(pglobal) != APR_SUCCESS) {
destroy_and_exit_process(process, 1);
}
#endif
ap_util_uri_init();
ap_setup_prelinked_modules(process);
ap_create_pool(&pcommands, pglobal);
ap_server_pre_read_config = ap_make_array(pcommands, 1, sizeof(char *));
ap_server_post_read_config = ap_make_array(pcommands, 1, sizeof(char *));
ap_server_config_defines = ap_make_array(pcommands, 1, sizeof(char *));
ap_run_rewrite_args(process);
/* Maintain AP_SERVER_BASEARGS list in http_main.h to allow the MPM
* to safely pass on our args from its rewrite_args() handler.
*/
while (ap_getopt(process->argc, process->argv,
AP_SERVER_BASEARGS, &c, pcommands)
== APR_SUCCESS) {
char **new;
switch (c) {
case 'c':
new = (char **)ap_push_array(ap_server_post_read_config);
*new = ap_pstrdup(pcommands, ap_optarg);
break;
case 'C':
new = (char **)ap_push_array(ap_server_pre_read_config);
*new = ap_pstrdup(pcommands, ap_optarg);
break;
case 'd':
def_server_root = ap_optarg;
break;
case 'D':
new = (char **)ap_push_array(ap_server_config_defines);
*new = ap_pstrdup(pcommands, ap_optarg);
break;
case 'f':
confname = ap_optarg;
break;
case 'v':
printf("Server version: %s\n", ap_get_server_version());
printf("Server built: %s\n", ap_get_server_built());
destroy_and_exit_process(process, 0);
case 'V':
show_compile_settings();
destroy_and_exit_process(process, 0);
case 'l':
ap_show_modules();
destroy_and_exit_process(process, 0);
case 'L':
ap_show_directives();
destroy_and_exit_process(process, 0);
case 't':
configtestonly = 1;
break;
case '?':
case 'h':
usage(process);
}
}
ap_create_pool(&plog, pglobal);
ap_create_pool(&ptemp, pconf);
/* Note that we preflight the config file once
before reading it _again_ in the main loop.
This allows things, log files configuration
for example, to settle down. */
ap_server_root = def_server_root;
server_conf = ap_read_config(process, ptemp, confname, &conftree);
ap_run_pre_config(pconf, plog, ptemp);
ap_process_config_tree(server_conf, conftree, process->pconf, ptemp);
ap_fixup_virtual_hosts(pconf, server_conf);
ap_fini_vhost_config(pconf, server_conf);
ap_sort_hooks();
if (configtestonly) {
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Syntax OK\n");
destroy_and_exit_process(process, 0);
}
ap_clear_pool(plog);
ap_run_open_logs(pconf, plog, ptemp, server_conf);
ap_post_config_hook(pconf, plog, ptemp, server_conf);
ap_destroy_pool(ptemp);
for (;;) {
ap_hook_deregister_all();
ap_clear_pool(pconf);
for (mod = ap_prelinked_modules; *mod != NULL; mod++) {
ap_register_hooks(*mod);
}
/* This is a hack until we finish the code so that it only reads
* the config file once and just operates on the tree already in
* memory. rbb
*/
conftree = NULL;
ap_create_pool(&ptemp, pconf);
ap_server_root = def_server_root;
server_conf = ap_read_config(process, ptemp, confname, &conftree);
ap_run_pre_config(pconf, plog, ptemp);
ap_process_config_tree(server_conf, conftree, process->pconf, ptemp);
ap_fixup_virtual_hosts(pconf, server_conf);
ap_fini_vhost_config(pconf, server_conf);
ap_sort_hooks();
ap_clear_pool(plog);
ap_run_open_logs(pconf, plog, ptemp, server_conf);
ap_post_config_hook(pconf, plog, ptemp, server_conf);
ap_destroy_pool(ptemp);
if (ap_mpm_run(pconf, plog, server_conf)) break;
}
destroy_and_exit_process(process, 0);
return 0; /* Supress compiler warning. */
}
/* force Expat to be linked into the server executable */
#if defined(USE_EXPAT) && !defined(SHARED_CORE_BOOTSTRAP)
#include "xmlparse.h"
const XML_LChar *suck_in_expat(void);
const XML_LChar *suck_in_expat(void)
{
return XML_ErrorString(XML_ERROR_NONE);
}
#endif /* USE_EXPAT */
#ifndef SHARED_CORE_BOOTSTRAP
/*
* Force ap_validate_password() into the image so that modules like
* mod_auth can use it even if they're dynamically loaded.
*/
void suck_in_ap_validate_password(void);
void suck_in_ap_validate_password(void)
{
ap_validate_password("a", "b");
}
#endif