main.c revision 1b21d7b3d97def358b2e923655edeb16613a1c31
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
#include "apr.h"
#include "apr_strings.h"
#include "apr_getopt.h"
#include "apr_general.h"
#include "apr_lib.h"
#define APR_WANT_STDIO
#include "apr_want.h"
#define CORE_PRIVATE
#include "ap_config.h"
#include "httpd.h"
#include "http_main.h"
#include "http_log.h"
#include "http_config.h"
#include "http_vhost.h"
#include "util_uri.h"
#include "util_ebcdic.h"
#include "ap_mpm.h"
/* WARNING: Win32 binds http_main.c dynamically to the server. Please place
* extern functions and global data in another appropriate module.
*
* Most significant main() global data can be found in http_config.c
*/
/* XXX - We should be able to grab the per-MPM settings here too */
static void show_compile_settings(void)
{
printf("Server's Module Magic Number: %u:%u\n",
printf("Server compiled with....\n");
#ifdef BIG_SECURITY_HOLE
printf(" -D BIG_SECURITY_HOLE\n");
#endif
printf(" -D SECURITY_HOLE_PASS_AUTHORIZATION\n");
#endif
#if APR_HAS_MMAP
printf(" -D HAVE_MMAP\n");
#endif
#ifdef HAVE_SHMGET
printf(" -D HAVE_SHMGET\n");
#endif
#ifdef AP_USE_FILE_BASED_SCOREBOARD
printf(" -D AP_USE_FILE_BASED_SCOREBOARD\n");
#endif
#ifdef AP_USE_MEM_BASED_SCOREBOARD
printf(" -D AP_USE_MEM_BASED_SCOREBOARD\n");
#endif
#ifdef APR_HAS_MMAP
printf(" -D APR_HAS_MMAP\n");
#endif /*APR_HAS_MMAP*/
#ifdef NO_WRITEV
printf(" -D NO_WRITEV\n");
#endif
#ifdef NO_LINGCLOSE
printf(" -D NO_LINGCLOSE\n");
#endif
#if APR_HAVE_IPV6
printf(" -D APR_HAVE_IPV6\n");
#endif
printf(" -D APR_USE_FLOCK_SERIALIZE\n");
#endif
printf(" -D APR_USE_SYSVSEM_SERIALIZE\n");
#endif
printf(" -D APR_USE_FCNTL_SERIALIZE\n");
#endif
printf(" -D APR_USE_PROC_PTHREAD_SERIALIZE\n");
#endif
printf(" -D APR_USE_PTHREAD_SERIALIZE\n");
#endif
printf(" -D APR_PROCESS_LOCK_IS_GLOBAL\n");
#endif
printf(" -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT\n");
#endif
printf(" -D APR_HAS_OTHER_CHILD\n");
#endif
#ifdef AP_HAVE_RELIABLE_PIPED_LOGS
printf(" -D AP_HAVE_RELIABLE_PIPED_LOGS\n");
#endif
#ifdef BUFFERED_LOGS
printf(" -D BUFFERED_LOGS\n");
#ifdef PIPE_BUF
#endif
#endif
printf(" -D APR_CHARSET_EBCDIC\n");
#endif
#ifdef APACHE_XLATE
printf(" -D APACHE_XLATE\n");
#endif
#ifdef NEED_HASHBANG_EMUL
printf(" -D NEED_HASHBANG_EMUL\n");
#endif
#ifdef SHARED_CORE
printf(" -D SHARED_CORE\n");
#endif
/* This list displays the compiled in default paths: */
#ifdef HTTPD_ROOT
#endif
#ifdef SUEXEC_BIN
#endif
#if defined(SHARED_CORE) && defined(SHARED_CORE_DIR)
#endif
#ifdef DEFAULT_PIDLOG
#endif
#ifdef DEFAULT_SCOREBOARD
#endif
#ifdef DEFAULT_LOCKFILE
#endif
#ifdef DEFAULT_XFERLOG
#endif
#ifdef DEFAULT_ERRORLOG
#endif
#ifdef TYPES_CONFIG_FILE
#endif
#ifdef SERVER_CONFIG_FILE
#endif
}
{
}
{
if (stat != APR_SUCCESS) {
/* XXX From the time that we took away the NULL pool->malloc mapping
* we have been unable to log here without segfaulting.
*/
"apr_pool_create() failed to create "
"initial context");
exit(1);
}
return process;
}
{
char pad[MAX_STRING_LEN];
unsigned i;
pad[i] = ' ';
pad[i] = '\0';
#ifdef SHARED_CORE
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0,NULL , "Usage: %s [-R directory] [-D name] [-d directory] [-f file]", bin);
#else
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Usage: %s [-D name] [-d directory] [-f file]", bin);
#endif
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " %s [-C \"directive\"] [-c \"directive\"]", pad);
#ifdef WIN32
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " %s [-k restart|shutdown|start]", pad);
#endif
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " %s [-v] [-V] [-h] [-l] [-L] [-t] [-T]", pad);
#ifdef SHARED_CORE
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -R directory : specify an alternate location for shared object files");
#endif
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -D name : define a name for use in <IfDefine name> directives");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -d directory : specify an alternate initial ServerRoot");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -f file : specify an alternate ServerConfigFile");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -C \"directive\" : process directive before reading config files");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -c \"directive\" : process directive after reading config files");
#ifdef WIN32
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -n name : set service name and use its ServerConfigFile");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -k shutdown : tell running Apache to shutdown");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -k restart : tell running Apache to do a graceful restart");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -k start : tell Apache to start");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -i : install an Apache service");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -u : uninstall an Apache service");
#endif
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -h : list available command line options (this page)");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -L : list available configuration directives");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -t -D DUMP_VHOSTS : show parsed settings (currently only vhost settings)");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -t : run syntax check for config files (with docroot check)");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -T : run syntax check for config files (without docroot check)");
/* TODOC: -X goes away, expect MPMs to use -D options */
}
{
char c;
int configtestonly = 0;
const char *confname = SERVER_CONFIG_FILE;
const char *def_server_root = HTTPD_ROOT;
const char *optarg;
}
#endif
/* Maintain AP_SERVER_BASEARGS list in http_main.h to allow the MPM
* to safely pass on our args from its rewrite_args() handler.
*/
== APR_SUCCESS) {
char **new;
switch (c) {
case 'c':
break;
case 'C':
break;
case 'd':
break;
case 'D':
break;
case 'f':
break;
case 'v':
case 'V':
case 'l':
case 'L':
case 't':
configtestonly = 1;
break;
case '?':
case 'h':
}
}
/* 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. */
if (configtestonly) {
}
for (;;) {
}
/* 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
*/
ap_conftree = NULL;
}
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 apr_password_validate() into the image so that modules like
* mod_auth can use it even if they're dynamically loaded.
*/
void suck_in_apr_password_validate(void);
void suck_in_apr_password_validate(void)
{
}
#endif
#ifdef AP_USING_AUTOCONF
/* This ugly little hack pulls any function referenced in exports.c into
* the web server. exports.c is generated during the build, and it
* has all of the APR functions specified by the apr/apr.exports and
* apr-util/aprutil.exports files.
*/
const void *suck_in_APR(void);
const void *suck_in_APR(void)
{
extern const void *ap_ugly_hack;
return ap_ugly_hack;
}
#endif