main.c revision fb0c14f07aa634d66663d85fa621c99a53bc74e4
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering/* ====================================================================
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering * The Apache Software License, Version 1.1
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering * Copyright (c) 2000 The Apache Software Foundation. All rights
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering * Redistribution and use in source and binary forms, with or without
0b3b020a178cf3b957fed627de13c895773995ecLennart Poettering * modification, are permitted provided that the following conditions
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 * 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.
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.
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 * 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 * 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 * ====================================================================
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 * 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/* 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 * Most significant main() global data can be found in http_config.c
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 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 printf(" -D BIG_SECURITY_HOLE\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#ifdef SECURITY_HOLE_PASS_AUTHORIZATION
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D SECURITY_HOLE_PASS_AUTHORIZATION\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D USE_FILE_BASED_SCOREBOARD\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D USE_MEM_BASED_SCOREBOARD\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D MMAP_SEGMENT_SIZE=%ld\n",(long)MMAP_SEGMENT_SIZE);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif /*USE_MMAP_FILES*/
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D APR_USE_FLOCK_SERIALIZE\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D APR_USE_SYSVSEM_SERIALIZE\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D APR_USE_FCNTL_SERIALIZE\n");
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 printf(" -D APR_USE_PTHREAD_SERIALIZE\n");
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering printf(" -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT\n");
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering printf(" -D HAVE_RELIABLE_PIPED_LOGS\n");
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering printf(" -D PIPE_BUF=%ld\n",(long)PIPE_BUF);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D NEED_HASHBANG_EMUL\n");
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering/* This list displays the compiled in default paths: */
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering printf(" -D HTTPD_ROOT=\"" HTTPD_ROOT "\"\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D SUEXEC_BIN=\"" SUEXEC_BIN "\"\n");
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 printf(" -D DEFAULT_PIDLOG=\"" DEFAULT_PIDLOG "\"\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D DEFAULT_SCOREBOARD=\"" DEFAULT_SCOREBOARD "\"\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D DEFAULT_LOCKFILE=\"" DEFAULT_LOCKFILE "\"\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D DEFAULT_XFERLOG=\"" DEFAULT_XFERLOG "\"\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D DEFAULT_ERRORLOG=\"" DEFAULT_ERRORLOG "\"\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D TYPES_CONFIG_FILE=\"" TYPES_CONFIG_FILE "\"\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek printf(" -D SERVER_CONFIG_FILE=\"" SERVER_CONFIG_FILE "\"\n");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekstatic void destroy_and_exit_process(process_rec *process, int process_exit_value)
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek ap_destroy_pool(process->pool); /* and destroy all descendent pools */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekstatic process_rec *create_process(int argc, char *const *argv)
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 process = ap_palloc(cntx, sizeof(process_rec));
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek ap_create_pool(&process->pconf, process->pool);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek process->short_name = ap_filename_of_pathname(argv[0]);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekstatic void usage(process_rec *process)
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek const char *bin = process->argv[0];
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek for (i = 0; i < strlen(bin); i++)
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);
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Usage: %s [-D name] [-d directory] [-f file]", bin);
707b66c66381c899d7ef640e158ffdd5bcff4debLennart Poettering ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " %s [-C \"directive\"] [-c \"directive\"]", pad);
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 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:");
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 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 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 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 const char *confname = SERVER_CONFIG_FILE;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek const char *def_server_root = HTTPD_ROOT;
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 */
#ifdef CHARSET_EBCDIC
/* Maintain AP_SERVER_BASEARGS list in http_main.h to allow the MPM
== APR_SUCCESS) {
char **new;
if (configtestonly) {
#include "xmlparse.h"
#ifndef SHARED_CORE_BOOTSTRAP
void suck_in_ap_validate_password(void);
void suck_in_ap_validate_password(void)