OBS User unknown 2008-04-20 19:03:37 +00:00 committed by Git OBS Bridge
parent d4a6a9907c
commit 9c1a724576
11 changed files with 248 additions and 996 deletions

View File

@ -10,7 +10,7 @@
sysconf=/etc/sysconfig/apache2
var=APACHE_SERVER_FLAGS
PATH="$PATH:/usr/bin:/usr/sbin"
PATH="$PATH:/usr/bin:/usr/sbin:/usr/share/apache2"
debug=true

View File

@ -10,7 +10,7 @@
sysconf=/etc/sysconfig/apache2
var=APACHE_MODULES
PATH="$PATH:/usr/bin:/usr/sbin"
PATH="$PATH:/usr/bin:/usr/sbin:/usr/share/apache2"
debug=true

View File

@ -1,6 +1,6 @@
This README is now online:
http://www.opensuse.org/Apache_Howto_Quickstart
http://en.opensuse.org/Apache_Quickstart_HOWTO
General starting point:
http://www.opensuse.org/Apache

View File

@ -9,7 +9,7 @@
SetHandler server-status
Order deny,allow
Deny from all
Allow from localhost
Allow from localhost 127.0.0.1
</Location>
</IfModule>

View File

@ -1,3 +1,29 @@
-------------------------------------------------------------------
Fri Apr 18 14:17:31 CEST 2008 - poeml@suse.de
- sync up with changes from Build Service:
- new implementation of sysconf_addword, using sed instead of ed.
Moving it from the -utils subpackage into the parent package,
where it's actually needed. If sysconf_addword is already present
in the system, it is preferred (by PATH). That's because the tool
has been integrated into aaa_base.rpm with openSUSE 11.0.
Removing the requires on the ed package. [bnc#377131]
- better documentation how to enable SSL in /etc/sysconfig/apache2
- quickstart readme: the link to the openSUSE wiki is about to move
- add "127.0.0.1" to the local access list in mod_status.conf,
because on some systems "localhost" seems to resolve only to IPv6
localhost
- /etc/init.d/apache2: implement restart-graceful, stop-graceful
- fix graceful-restart. Wait until the pidfile is gone, but don't
wait for the parent to disappear. It stays there, after closing
the listen ports.
- don't configure in maintainer-mode. It not only enables compile
time warnings, but also adds AP_DEBUG into the mix which causes
enablement of debug code which is not wanted in production
builds.
- drop obsolete patches mod_dbd.c-issue18989-autoconnect.dif and
mod_dbd.c-r571441, as the 2.2.8 mod_dbd is just fine.
-------------------------------------------------------------------
Tue Apr 1 16:05:07 CEST 2008 - mkoenig@suse.de

View File

@ -56,7 +56,7 @@ License: The Apache Software License
Group: Productivity/Networking/Web/Servers
%define realver 2.2.8
Version: 2.2.8
Release: 8
Release: 13
#Source0: http://www.apache.org/dist/httpd-%{version}.tar.bz2
Source0: http://httpd.apache.org/dev/dist/httpd-%{realver}.tar.bz2
Source10: SUSE-NOTICE
@ -77,6 +77,9 @@ Source41: find_mpm
Source42: get_module_list
Source43: get_includes
Source44: find_httpd2_includes
# sysconf_addword is part of aaa_base.rpm starting with openSUSE 11.0
# we bring our own copy for the cases where it is not available
Source45: sysconf_addword
Source46: a2enflag
Source47: a2enmod
Source48: apache2.xml
@ -100,16 +103,14 @@ Source130: apache2-vhost.template
Source131: apache2-vhost-ssl.template
Source140: apache2-check_forensic
Source141: apache-20-22-upgrade
Source150: mod_dbd.c-r512038
Patch2: httpd-2.1.3alpha-layout.dif
Patch10: httpd-2.1.3alpha-autoconf-2.59.dif
Patch23: httpd-2.1.9-apachectl.dif
Patch65: httpd-2.0.49-log_server_status.dif
Patch66: httpd-2.0.54-envvars.dif
Patch67: httpd-2.2.0-apxs-a2enmod.dif
Patch150: mod_dbd.c-issue18989-autoconnect.dif
Url: http://httpd.apache.org/
Icon: Apache.xpm
Icon: Apache.xpm
Summary: The Apache Web Server Version 2.0
AutoReqProv: on
Provides: httpd http_daemon %{apache_mmn} suse_help_viewer
@ -329,8 +330,6 @@ Authors:
%patch65 -p1
%patch66 -p1
%patch67 -p1
cp -p %{S:150} modules/database/mod_dbd.c
#%patch150 -p0
#
cat $RPM_SOURCE_DIR/SUSE-NOTICE >> NOTICE
#
@ -358,7 +357,6 @@ function configure {
%endif
CPPFLAGS="-DSSL_EXPERIMENTAL_ENGINE -DMAX_SERVER_LIMIT=200000 -DLDAP_DEPRECATED -DMAXLINE=4096" \
./configure \
--enable-maintainer-mode \
--enable-layout=SuSE81%(test "%_lib" = lib64 && echo -n _64) \
--with-program-name=httpd%{vers}$mpm_suffix \
--with-apr=%{_bindir}/apr-1-config \
@ -575,6 +573,7 @@ install -m 755 $RPM_SOURCE_DIR/apache-20-22-upgrade $RPM_BUILD_ROOT/%{_prefix}/s
sed 's+/usr/lib+/usr/%_lib+' $RPM_SOURCE_DIR/get_module_list \
> $RPM_BUILD_ROOT/%{_prefix}/share/%{pname}/get_module_list
chmod 755 $RPM_BUILD_ROOT/%{_prefix}/share/%{pname}/get_module_list
install -m 755 $RPM_SOURCE_DIR/sysconf_addword $RPM_BUILD_ROOT/%{_prefix}/share/%{pname}/
install -m 755 $RPM_SOURCE_DIR/a2enflag $RPM_BUILD_ROOT/%{_sbindir}
ln -s a2enflag $RPM_BUILD_ROOT/%{_sbindir}/a2disflag
install -m 755 $RPM_SOURCE_DIR/a2enmod $RPM_BUILD_ROOT/%{_sbindir}
@ -846,6 +845,7 @@ mv $RPM_BUILD_ROOT/%{sysconfdir}/original .
%{_prefix}/share/%{pname}/find_httpd2_includes
%{_prefix}/share/%{pname}/find_mpm
%{_prefix}/share/%{pname}/load_configuration
%{_prefix}/share/%{pname}/sysconf_addword
%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{name}
%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{name}-ssl
%if %prefork
@ -1031,6 +1031,29 @@ if ! test -f /.buildenv; then
fi
%changelog
* Fri Apr 18 2008 poeml@suse.de
- sync up with changes from Build Service:
- new implementation of sysconf_addword, using sed instead of ed.
Moving it from the -utils subpackage into the parent package,
where it's actually needed. If sysconf_addword is already present
in the system, it is preferred (by PATH). That's because the tool
has been integrated into aaa_base.rpm with openSUSE 11.0.
Removing the requires on the ed package. [bnc#377131]
- better documentation how to enable SSL in /etc/sysconfig/apache2
- quickstart readme: the link to the openSUSE wiki is about to move
- add "127.0.0.1" to the local access list in mod_status.conf,
because on some systems "localhost" seems to resolve only to IPv6
localhost
- /etc/init.d/apache2: implement restart-graceful, stop-graceful
- fix graceful-restart. Wait until the pidfile is gone, but don't
wait for the parent to disappear. It stays there, after closing
the listen ports.
- don't configure in maintainer-mode. It not only enables compile
time warnings, but also adds AP_DEBUG into the mix which causes
enablement of debug code which is not wanted in production
builds.
- drop obsolete patches mod_dbd.c-issue18989-autoconnect.dif and
mod_dbd.c-r571441, as the 2.2.8 mod_dbd is just fine.
* Tue Apr 01 2008 mkoenig@suse.de
- remove dir /usr/share/omc/svcinfo.d as it is provided now
by filesystem

View File

@ -1,65 +0,0 @@
--- modules/database/mod_dbd.c.orig 2006-05-18 10:59:22.000000000 -0700
+++ modules/database/mod_dbd.c 2006-05-18 10:57:10.000000000 -0700
@@ -433,6 +432,7 @@
svr_cfg *svr = ap_get_module_config(s->module_config, &dbd_module);
apr_status_t rv = APR_SUCCESS;
const char *errmsg;
+ int tries;
if (!svr->persist) {
/* Return a once-only connection */
@@ -445,14 +445,33 @@
return NULL;
}
}
- rv = apr_reslist_acquire(svr->dbpool, &rec);
- if (rv != APR_SUCCESS) {
- ap_log_perror(APLOG_MARK, APLOG_ERR, rv, pool,
- "Failed to acquire DBD connection from pool!");
- return NULL;
- }
- rv = apr_dbd_check_conn(arec->driver, pool, arec->handle);
- if ((rv != APR_SUCCESS) && (rv != APR_ENOTIMPL)) {
+ /* PR#39329: implement retries here
+ * How many times to retry? Well, svr->nkeep is an absolute max
+ * for the number of connections that could've gone stale while
+ * the backend remains up. I guess it could go above that in
+ * some edge case (the database gets restarted?)
+ * We need 1 try for nkeep = 0 or 1. Hence the dodgy loop logic.
+ *
+ * This effect of nkeep needs documenting in TFM.
+ */
+
+ tries = svr->nkeep;
+ do {
+ rv = apr_reslist_acquire(svr->dbpool, &rec);
+ if (rv != APR_SUCCESS) {
+ ap_log_perror(APLOG_MARK, APLOG_ERR, rv, pool,
+ "Failed to acquire DBD connection from pool!");
+ break;
+ }
+ rv = apr_dbd_check_conn(arec->driver, pool, arec->handle);
+ /* mysql wants a second mysql_ping to reopen the connection */
+ if (rv == APR_EGENERAL) {
+ rv = apr_dbd_check_conn(arec->driver, pool, arec->handle);
+ }
+ if ((rv == APR_SUCCESS) || (rv == APR_ENOTIMPL)) {
+ rv = dbd_prepared_init(pool, svr, rec);
+ break;
+ }
errmsg = apr_dbd_error(arec->driver, arec->handle, rv);
if (!errmsg) {
errmsg = "(unknown)";
@@ -460,9 +478,9 @@
ap_log_perror(APLOG_MARK, APLOG_ERR, rv, pool,
"DBD[%s] Error: %s", svr->name, errmsg );
apr_reslist_invalidate(svr->dbpool, rec);
- return NULL;
- }
- return arec;
+ } while (--tries > 0);
+
+ return ((rv == APR_SUCCESS) || (rv == APR_ENOTIMPL)) ? arec : NULL;
}
#else
DBD_DECLARE_NONSTD(ap_dbd_t*) ap_dbd_open(apr_pool_t *pool, server_rec *s)

View File

@ -1,914 +0,0 @@
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* Overview of what this is and does:
* http://www.apache.org/~niq/dbd.html
* or
* http://apache.webthing.com/database/
*/
#include "apr_reslist.h"
#include "apr_strings.h"
#include "apr_hash.h"
#include "apr_tables.h"
#include "apr_lib.h"
#include "apr_dbd.h"
#define APR_WANT_MEMFUNC
#define APR_WANT_STRFUNC
#include "apr_want.h"
#include "http_protocol.h"
#include "http_config.h"
#include "http_log.h"
#include "http_request.h"
#include "mod_dbd.h"
extern module AP_MODULE_DECLARE_DATA dbd_module;
/************ svr cfg: manage db connection pool ****************/
#define NMIN_SET 0x1
#define NKEEP_SET 0x2
#define NMAX_SET 0x4
#define EXPTIME_SET 0x8
typedef struct {
server_rec *server;
const char *name;
const char *params;
int persist;
#if APR_HAS_THREADS
int nmin;
int nkeep;
int nmax;
int exptime;
int set;
#endif
apr_hash_t *queries;
} dbd_cfg_t;
typedef struct dbd_group_t dbd_group_t;
struct dbd_group_t {
dbd_cfg_t *cfg;
dbd_group_t *next;
apr_pool_t *pool;
#if APR_HAS_THREADS
apr_thread_mutex_t *mutex;
apr_reslist_t *reslist;
int destroyed;
#else
ap_dbd_t *rec;
#endif
};
typedef struct {
dbd_cfg_t *cfg;
dbd_group_t *group;
} svr_cfg;
typedef enum { cmd_name, cmd_params, cmd_persist,
cmd_min, cmd_keep, cmd_max, cmd_exp
} cmd_parts;
static apr_pool_t *config_pool;
static dbd_group_t *group_list;
/* a default DBDriver value that'll generate meaningful error messages */
static const char *const no_dbdriver = "[DBDriver unset]";
/* A default nmin of >0 will help with generating meaningful
* startup error messages if the database is down.
*/
#define DEFAULT_NMIN 1
#define DEFAULT_NKEEP 2
#define DEFAULT_NMAX 10
#define DEFAULT_EXPTIME 300
static void *create_dbd_config(apr_pool_t *pool, server_rec *s)
{
svr_cfg *svr = apr_pcalloc(pool, sizeof(svr_cfg));
dbd_cfg_t *cfg = svr->cfg = apr_pcalloc(pool, sizeof(dbd_cfg_t));
cfg->server = s;
cfg->name = no_dbdriver; /* to generate meaningful error messages */
cfg->params = ""; /* don't risk segfault on misconfiguration */
cfg->persist = -1;
#if APR_HAS_THREADS
cfg->nmin = DEFAULT_NMIN;
cfg->nkeep = DEFAULT_NKEEP;
cfg->nmax = DEFAULT_NMAX;
cfg->exptime = DEFAULT_EXPTIME;
#endif
cfg->queries = apr_hash_make(pool);
return svr;
}
static void *merge_dbd_config(apr_pool_t *pool, void *basev, void *addv)
{
dbd_cfg_t *base = ((svr_cfg*) basev)->cfg;
dbd_cfg_t *add = ((svr_cfg*) addv)->cfg;
svr_cfg *svr = apr_pcalloc(pool, sizeof(svr_cfg));
dbd_cfg_t *new = svr->cfg = apr_pcalloc(pool, sizeof(dbd_cfg_t));
new->server = add->server;
new->name = (add->name != no_dbdriver) ? add->name : base->name;
new->params = strcmp(add->params, "") ? add->params : base->params;
new->persist = (add->persist != -1) ? add->persist : base->persist;
#if APR_HAS_THREADS
new->nmin = (add->set&NMIN_SET) ? add->nmin : base->nmin;
new->nkeep = (add->set&NKEEP_SET) ? add->nkeep : base->nkeep;
new->nmax = (add->set&NMAX_SET) ? add->nmax : base->nmax;
new->exptime = (add->set&EXPTIME_SET) ? add->exptime : base->exptime;
#endif
new->queries = apr_hash_overlay(pool, add->queries, base->queries);
return svr;
}
#define ISINT(val) do { \
const char *p; \
\
for (p = val; *p; ++p) { \
if (!apr_isdigit(*p)) { \
return "Argument must be numeric!"; \
} \
} \
} while (0)
static const char *dbd_param(cmd_parms *cmd, void *dconf, const char *val)
{
const apr_dbd_driver_t *driver = NULL;
svr_cfg *svr = ap_get_module_config(cmd->server->module_config,
&dbd_module);
dbd_cfg_t *cfg = svr->cfg;
switch ((long) cmd->info) {
case cmd_name:
cfg->name = val;
/* loading the driver involves once-only dlloading that is
* best done at server startup. This also guarantees that
* we won't return an error later.
*/
switch (apr_dbd_get_driver(cmd->pool, cfg->name, &driver)) {
case APR_ENOTIMPL:
return apr_psprintf(cmd->pool, "DBD: No driver for %s", cfg->name);
case APR_EDSOOPEN:
return apr_psprintf(cmd->pool,
"DBD: Can't load driver file apr_dbd_%s.so",
cfg->name);
case APR_ESYMNOTFOUND:
return apr_psprintf(cmd->pool,
"DBD: Failed to load driver apr_dbd_%s_driver",
cfg->name);
}
break;
case cmd_params:
cfg->params = val;
break;
#if APR_HAS_THREADS
case cmd_min:
ISINT(val);
cfg->nmin = atoi(val);
cfg->set |= NMIN_SET;
break;
case cmd_keep:
ISINT(val);
cfg->nkeep = atoi(val);
cfg->set |= NKEEP_SET;
break;
case cmd_max:
ISINT(val);
cfg->nmax = atoi(val);
cfg->set |= NMAX_SET;
break;
case cmd_exp:
ISINT(val);
cfg->exptime = atoi(val);
cfg->set |= EXPTIME_SET;
break;
#endif
}
return NULL;
}
static const char *dbd_param_flag(cmd_parms *cmd, void *dconf, int flag)
{
svr_cfg *svr = ap_get_module_config(cmd->server->module_config,
&dbd_module);
switch ((long) cmd->info) {
case cmd_persist:
svr->cfg->persist = flag;
break;
}
return NULL;
}
static const char *dbd_prepare(cmd_parms *cmd, void *dconf, const char *query,
const char *label)
{
if (!label) {
label = query;
query = "";
}
ap_dbd_prepare(cmd->server, query, label);
return NULL;
}
static const command_rec dbd_cmds[] = {
AP_INIT_TAKE1("DBDriver", dbd_param, (void*)cmd_name, RSRC_CONF,
"SQL Driver"),
AP_INIT_TAKE1("DBDParams", dbd_param, (void*)cmd_params, RSRC_CONF,
"SQL Driver Params"),
AP_INIT_FLAG("DBDPersist", dbd_param_flag, (void*)cmd_persist, RSRC_CONF,
"Use persistent connection/pool"),
AP_INIT_TAKE12("DBDPrepareSQL", dbd_prepare, NULL, RSRC_CONF,
"SQL statement to prepare (or nothing, to override "
"statement inherited from main server) and label"),
#if APR_HAS_THREADS
AP_INIT_TAKE1("DBDMin", dbd_param, (void*)cmd_min, RSRC_CONF,
"Minimum number of connections"),
/* XXX: note that mod_proxy calls this "smax" */
AP_INIT_TAKE1("DBDKeep", dbd_param, (void*)cmd_keep, RSRC_CONF,
"Maximum number of sustained connections"),
AP_INIT_TAKE1("DBDMax", dbd_param, (void*)cmd_max, RSRC_CONF,
"Maximum number of connections"),
/* XXX: note that mod_proxy calls this "ttl" (time to live) */
AP_INIT_TAKE1("DBDExptime", dbd_param, (void*)cmd_exp, RSRC_CONF,
"Keepalive time for idle connections"),
#endif
{NULL}
};
static int dbd_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
apr_pool_t *ptemp)
{
config_pool = pconf;
group_list = NULL;
return OK;
}
DBD_DECLARE_NONSTD(void) ap_dbd_prepare(server_rec *s, const char *query,
const char *label)
{
svr_cfg *svr;
svr = ap_get_module_config(s->module_config, &dbd_module);
if (!svr) {
/* some modules may call from within config directive handlers, and
* if these are called in a server context that contains no mod_dbd
* config directives, then we have to create our own server config
*/
svr = create_dbd_config(config_pool, s);
ap_set_module_config(s->module_config, &dbd_module, svr);
}
if (apr_hash_get(svr->cfg->queries, label, APR_HASH_KEY_STRING)
&& strcmp(query, "")) {
ap_log_error(APLOG_MARK, APLOG_WARNING, 0, s,
"conflicting SQL statements with label %s", label);
}
apr_hash_set(svr->cfg->queries, label, APR_HASH_KEY_STRING, query);
}
typedef struct {
const char *label, *query;
} dbd_query_t;
static int dbd_post_config(apr_pool_t *pconf, apr_pool_t *plog,
apr_pool_t *ptemp, server_rec *s)
{
server_rec *sp;
apr_array_header_t *add_queries = apr_array_make(ptemp, 10,
sizeof(dbd_query_t));
for (sp = s; sp; sp = sp->next) {
svr_cfg *svr = ap_get_module_config(sp->module_config, &dbd_module);
dbd_cfg_t *cfg = svr->cfg;
apr_hash_index_t *hi_first = apr_hash_first(ptemp, cfg->queries);
dbd_group_t *group;
/* dbd_setup in 2.2.3 and under was causing spurious error messages
* when dbd isn't configured. We can stop that with a quick check here
* together with a similar check in ap_dbd_open (where being
* unconfigured is a genuine error that must be reported).
*/
if (cfg->name == no_dbdriver || !cfg->persist) {
continue;
}
for (group = group_list; group; group = group->next) {
dbd_cfg_t *group_cfg = group->cfg;
apr_hash_index_t *hi;
int group_ok = 1;
if (strcmp(cfg->name, group_cfg->name)
|| strcmp(cfg->params, group_cfg->params)) {
continue;
}
#if APR_HAS_THREADS
if (cfg->nmin != group_cfg->nmin
|| cfg->nkeep != group_cfg->nkeep
|| cfg->nmax != group_cfg->nmax
|| cfg->exptime != group_cfg->exptime) {
continue;
}
#endif
add_queries->nelts = 0;
for (hi = hi_first; hi; hi = apr_hash_next(hi)) {
const char *label, *query;
const char *group_query;
apr_hash_this(hi, (void*) &label, NULL, (void*) &query);
group_query = apr_hash_get(group_cfg->queries, label,
APR_HASH_KEY_STRING);
if (!group_query) {
dbd_query_t *add_query = apr_array_push(add_queries);
add_query->label = label;
add_query->query = query;
}
else if (strcmp(query, group_query)) {
group_ok = 0;
break;
}
}
if (group_ok) {
int i;
for (i = 0; i < add_queries->nelts; ++i) {
dbd_query_t *add_query = ((dbd_query_t*) add_queries->elts)
+ i;
apr_hash_set(group_cfg->queries, add_query->label,
APR_HASH_KEY_STRING, add_query->query);
}
svr->group = group;
break;
}
}
if (!svr->group) {
svr->group = group = apr_pcalloc(pconf, sizeof(dbd_group_t));
group->cfg = cfg;
group->next = group_list;
group_list = group;
}
}
return OK;
}
static apr_status_t dbd_prepared_init(apr_pool_t *pool, dbd_cfg_t *cfg,
ap_dbd_t *rec)
{
apr_hash_index_t *hi;
apr_status_t rv = APR_SUCCESS;
rec->prepared = apr_hash_make(pool);
for (hi = apr_hash_first(pool, cfg->queries); hi;
hi = apr_hash_next(hi)) {
const char *label, *query;
apr_dbd_prepared_t *stmt;
apr_hash_this(hi, (void*) &label, NULL, (void*) &query);
if (!strcmp(query, "")) {
continue;
}
stmt = NULL;
if (apr_dbd_prepare(rec->driver, pool, rec->handle, query,
label, &stmt)) {
rv = APR_EGENERAL;
}
else {
apr_hash_set(rec->prepared, label, APR_HASH_KEY_STRING, stmt);
}
}
return rv;
}
static apr_status_t dbd_close(void *data)
{
ap_dbd_t *rec = data;
return apr_dbd_close(rec->driver, rec->handle);
}
#if APR_HAS_THREADS
static apr_status_t dbd_destruct(void *data, void *params, apr_pool_t *pool)
{
dbd_group_t *group = params;
if (!group->destroyed) {
ap_dbd_t *rec = data;
apr_pool_destroy(rec->pool);
}
return APR_SUCCESS;
}
#endif
/* an apr_reslist_constructor for SQL connections
* Also use this for opening in non-reslist modes, since it gives
* us all the error-handling in one place.
*/
static apr_status_t dbd_construct(void **data_ptr,
void *params, apr_pool_t *pool)
{
dbd_group_t *group = params;
dbd_cfg_t *cfg = group->cfg;
apr_pool_t *rec_pool, *prepared_pool;
ap_dbd_t *rec;
apr_status_t rv;
rv = apr_pool_create(&rec_pool, pool);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, cfg->server,
"DBD: Failed to create memory pool");
return rv;
}
rec = apr_pcalloc(rec_pool, sizeof(ap_dbd_t));
rec->pool = rec_pool;
/* The driver is loaded at config time now, so this just checks a hash.
* If that changes, the driver DSO could be registered to unload against
* our pool, which is probably not what we want. Error checking isn't
* necessary now, but in case that changes in the future ...
*/
rv = apr_dbd_get_driver(rec->pool, cfg->name, &rec->driver);
if (rv != APR_SUCCESS) {
switch (rv) {
case APR_ENOTIMPL:
ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server,
"DBD: driver for %s not available", cfg->name);
break;
case APR_EDSOOPEN:
ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server,
"DBD: can't find driver for %s", cfg->name);
break;
case APR_ESYMNOTFOUND:
ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server,
"DBD: driver for %s is invalid or corrupted",
cfg->name);
break;
default:
ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server,
"DBD: mod_dbd not compatible with APR in get_driver");
break;
}
apr_pool_destroy(rec->pool);
return rv;
}
rv = apr_dbd_open(rec->driver, rec->pool, cfg->params, &rec->handle);
if (rv != APR_SUCCESS) {
switch (rv) {
case APR_EGENERAL:
ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server,
"DBD: Can't connect to %s", cfg->name);
break;
default:
ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server,
"DBD: mod_dbd not compatible with APR in open");
break;
}
apr_pool_destroy(rec->pool);
return rv;
}
apr_pool_cleanup_register(rec->pool, rec, dbd_close,
apr_pool_cleanup_null);
/* we use a sub-pool for the prepared statements for each connection so
* that they will be cleaned up first, before the connection is closed
*/
rv = apr_pool_create(&prepared_pool, rec->pool);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, cfg->server,
"DBD: Failed to create memory pool");
apr_pool_destroy(rec->pool);
return rv;
}
rv = dbd_prepared_init(prepared_pool, cfg, rec);
if (rv != APR_SUCCESS) {
const char *errmsg = apr_dbd_error(rec->driver, rec->handle, rv);
ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server,
"DBD: failed to prepare SQL statements: %s",
(errmsg ? errmsg : "[???]"));
apr_pool_destroy(rec->pool);
return rv;
}
*data_ptr = rec;
return APR_SUCCESS;
}
#if APR_HAS_THREADS
static apr_status_t dbd_destroy(void *data)
{
dbd_group_t *group = data;
group->destroyed = 1;
return APR_SUCCESS;
}
static apr_status_t dbd_setup(server_rec *s, dbd_group_t *group)
{
dbd_cfg_t *cfg = group->cfg;
apr_status_t rv;
/* We create the reslist using a sub-pool of the pool passed to our
* child_init hook. No other threads can be here because we're
* either in the child_init phase or dbd_setup_lock() acquired our mutex.
* No other threads will use this sub-pool after this, except via
* reslist calls, which have an internal mutex.
*
* We need to short-circuit the cleanup registered internally by
* apr_reslist_create(). We do this by registering dbd_destroy()
* as a cleanup afterwards, so that it will run before the reslist's
* internal cleanup.
*
* If we didn't do this, then we could free memory twice when the pool
* was destroyed. When apr_pool_destroy() runs, it first destroys all
* all the per-connection sub-pools created in dbd_construct(), and
* then it runs the reslist's cleanup. The cleanup calls dbd_destruct()
* on each resource, which would then attempt to destroy the sub-pools
* a second time.
*/
rv = apr_reslist_create(&group->reslist,
cfg->nmin, cfg->nkeep, cfg->nmax,
apr_time_from_sec(cfg->exptime),
dbd_construct, dbd_destruct, group,
group->pool);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
"DBD: failed to initialise");
return rv;
}
apr_pool_cleanup_register(group->pool, group, dbd_destroy,
apr_pool_cleanup_null);
return APR_SUCCESS;
}
#endif
static apr_status_t dbd_setup_init(apr_pool_t *pool, server_rec *s)
{
dbd_group_t *group;
apr_status_t rv = APR_SUCCESS;
for (group = group_list; group; group = group->next) {
apr_status_t rv2;
rv2 = apr_pool_create(&group->pool, pool);
if (rv2 != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv2, s,
"DBD: Failed to create reslist cleanup memory pool");
return rv2;
}
#if APR_HAS_THREADS
rv2 = dbd_setup(s, group);
if (rv2 == APR_SUCCESS) {
continue;
}
else if (rv == APR_SUCCESS) {
rv = rv2;
}
/* we failed, so create a mutex so that subsequent competing callers
* to ap_dbd_open can serialize themselves while they retry
*/
rv2 = apr_thread_mutex_create(&group->mutex,
APR_THREAD_MUTEX_DEFAULT, pool);
if (rv2 != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv2, s,
"DBD: Failed to create thread mutex");
return rv2;
}
#endif
}
return rv;
}
#if APR_HAS_THREADS
static apr_status_t dbd_setup_lock(server_rec *s, dbd_group_t *group)
{
apr_status_t rv = APR_SUCCESS, rv2;
/* several threads could be here at the same time, all trying to
* initialize the reslist because dbd_setup_init failed to do so
*/
if (!group->mutex) {
/* we already logged an error when the mutex couldn't be created */
return APR_EGENERAL;
}
rv2 = apr_thread_mutex_lock(group->mutex);
if (rv2 != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, rv2, s,
"DBD: Failed to acquire thread mutex");
return rv2;
}
if (!group->reslist) {
rv = dbd_setup(s, group);
}
rv2 = apr_thread_mutex_unlock(group->mutex);
if (rv2 != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, rv2, s,
"DBD: Failed to release thread mutex");
if (rv == APR_SUCCESS) {
rv = rv2;
}
}
return rv;
}
#endif
/* Functions we export for modules to use:
- open acquires a connection from the pool (opens one if necessary)
- close releases it back in to the pool
*/
DBD_DECLARE_NONSTD(void) ap_dbd_close(server_rec *s, ap_dbd_t *rec)
{
svr_cfg *svr = ap_get_module_config(s->module_config, &dbd_module);
if (!svr->cfg->persist) {
apr_pool_destroy(rec->pool);
}
#if APR_HAS_THREADS
else {
apr_reslist_release(svr->group->reslist, rec);
}
#endif
}
static apr_status_t dbd_check(apr_pool_t *pool, server_rec *s, ap_dbd_t *rec)
{
svr_cfg *svr;
apr_status_t rv = apr_dbd_check_conn(rec->driver, pool, rec->handle);
const char *errmsg;
if ((rv == APR_SUCCESS) || (rv == APR_ENOTIMPL)) {
return APR_SUCCESS;
}
errmsg = apr_dbd_error(rec->driver, rec->handle, rv);
if (!errmsg) {
errmsg = "(unknown)";
}
svr = ap_get_module_config(s->module_config, &dbd_module);
ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
"DBD [%s] Error: %s", svr->cfg->name, errmsg);
return rv;
}
DBD_DECLARE_NONSTD(ap_dbd_t*) ap_dbd_open(apr_pool_t *pool, server_rec *s)
{
svr_cfg *svr = ap_get_module_config(s->module_config, &dbd_module);
dbd_group_t *group = svr->group;
dbd_cfg_t *cfg = svr->cfg;
ap_dbd_t *rec = NULL;
#if APR_HAS_THREADS
apr_status_t rv;
#endif
/* If nothing is configured, we shouldn't be here */
if (cfg->name == no_dbdriver) {
ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, "DBD: not configured");
return NULL;
}
if (!cfg->persist) {
/* Return a once-only connection */
group = apr_pcalloc(pool, sizeof(dbd_group_t));
group->cfg = cfg;
dbd_construct((void*) &rec, group, pool);
return rec;
}
#if APR_HAS_THREADS
if (!group->reslist) {
if (dbd_setup_lock(s, group) != APR_SUCCESS) {
return NULL;
}
}
rv = apr_reslist_acquire(group->reslist, (void*) &rec);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
"Failed to acquire DBD connection from pool!");
return NULL;
}
if (dbd_check(pool, s, rec) != APR_SUCCESS) {
apr_reslist_invalidate(group->reslist, rec);
return NULL;
}
#else
/* If we have a persistent connection and it's good, we'll use it;
* since this is non-threaded, we can update without a mutex
*/
rec = group->rec;
if (rec) {
if (dbd_check(pool, s, rec) != APR_SUCCESS) {
apr_pool_destroy(rec->pool);
rec = NULL;
}
}
/* We don't have a connection right now, so we'll open one */
if (!rec) {
dbd_construct((void*) &rec, group, group->pool);
group->rec = rec;
}
#endif
return rec;
}
#if APR_HAS_THREADS
typedef struct {
ap_dbd_t *rec;
apr_reslist_t *reslist;
} dbd_acquire_t;
static apr_status_t dbd_release(void *data)
{
dbd_acquire_t *acq = data;
apr_reslist_release(acq->reslist, acq->rec);
return APR_SUCCESS;
}
DBD_DECLARE_NONSTD(ap_dbd_t *) ap_dbd_acquire(request_rec *r)
{
dbd_acquire_t *acq;
while (!ap_is_initial_req(r)) {
if (r->prev) {
r = r->prev;
}
else if (r->main) {
r = r->main;
}
}
acq = ap_get_module_config(r->request_config, &dbd_module);
if (!acq) {
acq = apr_palloc(r->pool, sizeof(dbd_acquire_t));
acq->rec = ap_dbd_open(r->pool, r->server);
if (acq->rec) {
svr_cfg *svr = ap_get_module_config(r->server->module_config,
&dbd_module);
ap_set_module_config(r->request_config, &dbd_module, acq);
if (svr->cfg->persist) {
acq->reslist = svr->group->reslist;
apr_pool_cleanup_register(r->pool, acq, dbd_release,
apr_pool_cleanup_null);
}
}
}
return acq->rec;
}
DBD_DECLARE_NONSTD(ap_dbd_t *) ap_dbd_cacquire(conn_rec *c)
{
dbd_acquire_t *acq = ap_get_module_config(c->conn_config, &dbd_module);
if (!acq) {
acq = apr_palloc(c->pool, sizeof(dbd_acquire_t));
acq->rec = ap_dbd_open(c->pool, c->base_server);
if (acq->rec) {
svr_cfg *svr = ap_get_module_config(c->base_server->module_config,
&dbd_module);
ap_set_module_config(c->conn_config, &dbd_module, acq);
if (svr->cfg->persist) {
acq->reslist = svr->group->reslist;
apr_pool_cleanup_register(c->pool, acq, dbd_release,
apr_pool_cleanup_null);
}
}
}
return acq->rec;
}
#else
DBD_DECLARE_NONSTD(ap_dbd_t *) ap_dbd_acquire(request_rec *r)
{
ap_dbd_t *rec;
while (!ap_is_initial_req(r)) {
if (r->prev) {
r = r->prev;
}
else if (r->main) {
r = r->main;
}
}
rec = ap_get_module_config(r->request_config, &dbd_module);
if (!rec) {
rec = ap_dbd_open(r->pool, r->server);
if (rec) {
ap_set_module_config(r->request_config, &dbd_module, rec);
}
}
return rec;
}
DBD_DECLARE_NONSTD(ap_dbd_t *) ap_dbd_cacquire(conn_rec *c)
{
ap_dbd_t *rec = ap_get_module_config(c->conn_config, &dbd_module);
if (!rec) {
rec = ap_dbd_open(c->pool, c->base_server);
if (rec) {
ap_set_module_config(c->conn_config, &dbd_module, rec);
}
}
return rec;
}
#endif
static void dbd_hooks(apr_pool_t *pool)
{
ap_hook_pre_config(dbd_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_post_config(dbd_post_config, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_child_init((void*)dbd_setup_init, NULL, NULL, APR_HOOK_MIDDLE);
APR_REGISTER_OPTIONAL_FN(ap_dbd_prepare);
APR_REGISTER_OPTIONAL_FN(ap_dbd_open);
APR_REGISTER_OPTIONAL_FN(ap_dbd_close);
APR_REGISTER_OPTIONAL_FN(ap_dbd_acquire);
APR_REGISTER_OPTIONAL_FN(ap_dbd_cacquire);
apr_dbd_init(pool);
}
module AP_MODULE_DECLARE_DATA dbd_module = {
STANDARD20_MODULE_STUFF,
NULL,
NULL,
create_dbd_config,
merge_dbd_config,
dbd_cmds,
dbd_hooks
};

View File

@ -14,7 +14,7 @@
### BEGIN INIT INFO
# Provides: apache2 httpd2
# Required-Start: $local_fs $remote_fs $network
# X-UnitedLinux-Should-Start: $named $time postgresql sendmail mysql ypclient dhcp radiusd
# Should-Start: $named $time postgresql sendmail mysql ypclient dhcp radiusd
# Required-Stop: $local_fs $remote_fs $network
# X-UnitedLinux-Should-Stop:
# Default-Start: 3 5
@ -172,6 +172,31 @@ case "$action" in
esac
fi
rc_status -v
;;
stop-graceful)
echo "Shutting down httpd2 gracefully (SIGWINCH)"
if ! [ -f $pidfile ]; then
echo -n "(not running)"
else
pid=$(<$pidfile)
kill -WINCH $pid 2>/dev/null
case $? in
1) echo -n "(not running)";;
0) # wait until the pidfile is gone. The parent stays there, but closes the listen ports.
echo -n "(waiting for parent to close listen ports and remove pidfile) "
for ((wait=0; wait<120; wait++)); do
if test -f $pidfile; then
usleep 500000
continue
else
break
fi
done
;;
esac
fi
rc_status -v
;;
try-restart)
@ -209,6 +234,18 @@ case "$action" in
# Remember status and be quiet
rc_status -v
;;
restart-graceful)
$0 configtest "$@" || { rc_failed $?; rc_exit; }
if $0 status &>/dev/null; then
$0 stop-graceful "$@"
$0 start "$@"
else
$0 start "$@"
fi
# Remember status and be quiet
rc_status
;;
reload|force-reload|graceful)
echo -n "Reload httpd2 (graceful restart)"
cmdline=$(echo $apache_bin -f $httpd_conf $server_flags "$@")
@ -294,13 +331,18 @@ case "$action" in
where <command> is one of:
start - start httpd
startssl - start httpd with -DSSL
stop - stop httpd (sendign SIGTERM to parent)
stop - stop httpd (sending SIGTERM to parent)
try-restart - stop httpd and if this succeeds (i.e. if
it was running before), start it again.
status - check whether httpd is running
restart - stop httpd if running; start httpd
reload|graceful - do a graceful restart by sending a SIGUSR1 or
restart-graceful - stop httpd gracefully if running; start httpd
reload|graceful - do a graceful restart by sending a SIGUSR1, or
start if not running
stop-graceful - stop httpd (sending SIGWINCH to parent)
configtest - do a configuration syntax test
extreme-configtest - try to run httpd as nobody (detects more errors
by actually loading the configuration, but cannot
@ -308,10 +350,12 @@ case "$action" in
probe - probe for the necessity of a reload, give
out the argument which is required for a reload.
(by comparing conf files with pidfile timestamp)
full-server-status - dump a full status screen; requires lynx or w3m
and mod_status enabled
server-status - dump a short status screen; requires lynx or w3m
and mod_status enabled
help - this screen
optional server flags are passed through to httpd.

137
sysconf_addword Normal file
View File

@ -0,0 +1,137 @@
#!/bin/bash
# Copyright 2005 Peter Poeml <apache@suse.de>. All Rights Reserved.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
debug=false
function usage() {
cat <<-EOF
usage: $(basename $0) [-r] FILE VAR WORD
Add word WORD to variable VAR in file FILE, or remove
it if the -r option is given.
Example:
$(basename $0) /etc/sysconfig/apache2 APACHE_SERVER_FLAGS asdf
leads to the change:
-APACHE_SERVER_FLAGS="SSL STATUS ruby"
+APACHE_SERVER_FLAGS="SSL STATUS ruby asdf"
If multiple lines matching ^VAR= are found (which happens to be a habit of
mine), only the last one is manipulated.
It does not work for WORD starting with characters like a dash which
prevent word boundary matching.
EOF
}
function find_last_occurrence () {
# takes two arguments, FILE and VAR
# and return the number of the last line where
# VAR occurs in FILE (not commented)
grep -n -- "^[[:space:]]*$1" $2 | tail -n 1 | cut -d: -f1
}
function word_present () {
. $file
case " ${!var} " in
*" $word "*) true;;
*) false;;
esac
}
function add_word() {
local word=$1
local word_quoted=$2
if ! word_present; then
$debug && cp $file $tmpf
sed -i -e "${lineno} {
s/^[[:space:]]*\($var=\".*\)\(\".*\)/\1 $word_quoted\2/;
s/=\" /=\"/
}" $file
$debug && diff -u $tmpf $file
else
echo \"$word\" already present
fi
# some balancing for vim"s syntax highlighting
}
function remove_word() {
local word=$1
local word_quoted=$2
if word_present; then
$debug && cp $file $tmpf
sed -i -e "${lineno} {
s/\(['\" ]\)$word_quoted\(['\" ]\)/\1 \2/g
s/ / /g
}" $file
$debug && diff -u $tmpf $file
else
echo \"$word\" not present
fi
# some balancing for vim"s syntax highlighting
}
# poor man's option parsing
case "$1" in
-h) usage; exit 0;;
esac
if [ $# -lt 3 ]; then
echo not enough arguments
echo
usage; exit 1
fi
action=add
case "$1" in
-r) action=remove; shift;;
esac
file=$1; shift
var=$1; shift
word=$1
word_quoted=${1//\//\\\/}
if $debug; then
echo FILE: $file
echo VAR: $var
echo WORD: $word
echo current content:
grep "^$var=" $file | tail -n 1
echo
fi
if ! [ -r $file ]; then
echo ${0##*/}: file $file is not a readable file
exit 1
fi
lineno=$(find_last_occurrence $var $file)
if [ -z $lineno ]; then
echo ${0##*/}: variable $var does not occur in $file
exit 1
fi
$debug && tmpf=$(mktemp /tmp/$(basename $0).XXXXXX)
if [ $action = add ]; then
add_word $word $word_quoted $lineno
else
remove_word $word $word_quoted $lineno
fi
$debug && rm -f $tmpf
exit 0

View File

@ -51,14 +51,15 @@ APACHE_CONF_INCLUDE_DIRS=""
# * In the APACHE_MODULES variable, you can use mod_xyz or just xyz syntax.
# You may also name an absolute path if you like.
#
# * NOTE ON MOD_SSL: before you can enable this module, you need a server certificate.
# * NOTE ON SSL: before you can use mod_ssl, you need a server certificate.
# A test certificate can be created by entering
# 'cd /usr/share/doc/packages/apache2; ./certificate.sh' as root.
# Also, you need to set the ServerName inside the <VirtualHost _default_:443>
# block to the fully qualified domain name (see /etc/HOSTNAME).
#
# * if your server certificate is protected by a passphrase you should increase the
# APACHE_START_TIMEOUT (see above)
# * to finally enable ssl support, you need to add 'SSL' to APACHE_SERVER_FLAGS
# below.
#
# * modules listed here will be ignored if they are not installed
#
@ -89,7 +90,7 @@ APACHE_MODULES="actions alias auth_basic authn_file authz_host authz_groupfile a
# special cases, like during server maintenance, or for testing
# something temporarily.
#
# Notably, to enable SSL support, 'SSL' needs to be added here.
# Notably, to enable ssl support, 'SSL' needs to be added here.
# To enable the server-status, 'STATUS' needs to be added here.
#
# It does not matter if you write flag1, -D flag1 or -Dflag1.