/*
- suPHP - (c)2002-2004 Sebastian Marsching <sebastian@marsching.com>
+ suPHP - (c)2002-2005 Sebastian Marsching <sebastian@marsching.com>
This file is part of suPHP.
src_end = bucket_data + bucket_data_len;
while ((src < src_end) && (dst < dst_end))
{
- *dst = *src;
+ *dst = *src;
dst++;
src++;
count++;
char *target_user;
char *target_group;
#endif
+ apr_table_t *handlers;
} suphp_conf;
cfg->target_group = NULL;
#endif
+ /* Create table with 0 initial elements */
+ /* This size may be increased for performance reasons */
+ cfg->handlers = apr_table_make(p, 0);
+
return (void *) cfg;
}
merged->target_group = NULL;
#endif
+ merged->handlers = apr_table_overlay(p, child->handlers, parent->handlers);
+
return (void *) merged;
}
#endif
+static const char *suphp_handle_cmd_add_handler(cmd_parms *cmd, void *mconfig,
+ const char *arg)
+{
+ suphp_conf *cfg = (suphp_conf *) mconfig;
+ // Mark active handler with '1'
+ apr_table_set(cfg->handlers, arg, "1");
+
+ return NULL;
+}
+
+
+static const char *suphp_handle_cmd_remove_handler(cmd_parms *cmd,
+ void *mconfig,
+ const char *arg)
+{
+ suphp_conf *cfg = (suphp_conf *) mconfig;
+ // Mark deactivated handler with '0'
+ apr_table_set(cfg->handlers, arg, "0");
+
+ return NULL;
+}
+
+
static const command_rec suphp_cmds[] =
{
AP_INIT_FLAG("suPHP_Engine", suphp_handle_cmd_engine, NULL, RSRC_CONF | ACCESS_CONF,
AP_INIT_TAKE2("suPHP_UserGroup", suphp_handle_cmd_user_group, NULL, RSRC_CONF | ACCESS_CONF,
"User and group scripts shall be run as"),
#endif
+ AP_INIT_ITERATE("suPHP_AddHandler", suphp_handle_cmd_add_handler, NULL, RSRC_CONF | ACCESS_CONF, "Tells mod_suphp to handle these MIME-types"),
+ AP_INIT_ITERATE("suPHP_RemoveHandler", suphp_handle_cmd_remove_handler, NULL, RSRC_CONF | ACCESS_CONF, "Tells mod_suphp not to handle these MIME-types"),
{NULL}
};
dconf = ap_get_module_config(r->per_dir_config, &suphp_module);
core_conf = (core_dir_config *) ap_get_module_config(r->per_dir_config, &core_module);
- /* only handle request if x-httpd-php handler is asigned */
+ /* only handle request if mod_suphp is active for this handler */
+ /* check only first byte of value (second has to be \0) */
+ if ((apr_table_get(dconf->handlers, r->handler) == NULL)
+ || (*(apr_table_get(dconf->handlers, r->handler)) == '0'))
+ return DECLINED;
- if (strcmp(r->handler, "x-httpd-php")
- && strcmp(r->handler, "application/x-httpd-php"))
- return DECLINED;
-
/* check if suPHP is enabled for this request */
if (((sconf->engine != SUPHP_ENGINE_ON)
ap_add_common_vars(r);
ap_add_cgi_vars(r);
- apr_table_unset(r->subprocess_env, "PHP_CONFIG");
- apr_table_unset(r->subprocess_env, "PHP_AUTH_USER");
- apr_table_unset(r->subprocess_env, "PHP_AUTH_PW");
+ apr_table_unset(r->subprocess_env, "SUPHP_PHP_CONFIG");
+ apr_table_unset(r->subprocess_env, "SUPHP_AUTH_USER");
+ apr_table_unset(r->subprocess_env, "SUPHP_AUTH_PW");
#ifdef SUPHP_USE_USERGROUP
- apr_table_unset(r->subprocess_env, "PHP_SU_USER");
- apr_table_unset(r->subprocess_env, "PHP_SU_GROUP");
+ apr_table_unset(r->subprocess_env, "SUPHP_USER");
+ apr_table_unset(r->subprocess_env, "SUPHP_GROUP");
#endif
if (dconf->php_config)
{
- apr_table_setn(r->subprocess_env, "PHP_CONFIG", apr_pstrdup(p, dconf->php_config));
+ apr_table_setn(r->subprocess_env, "SUPHP_PHP_CONFIG", apr_pstrdup(p, dconf->php_config));
}
+ apr_table_setn(r->subprocess_env, "SUPHP_HANDLER", r->handler);
+
if (r->headers_in)
{
const char *auth = NULL;
if (auth_user && auth_pass)
{
- apr_table_setn(r->subprocess_env, "PHP_AUTH_USER", auth_user);
- apr_table_setn(r->subprocess_env, "PHP_AUTH_PW", auth_pass);
+ apr_table_setn(r->subprocess_env, "SUPHP_AUTH_USER", auth_user);
+ apr_table_setn(r->subprocess_env, "SUPHP_AUTH_PW", auth_pass);
}
#ifdef SUPHP_USE_USERGROUP
if (dconf->target_user)
{
- apr_table_setn(r->subprocess_env, "PHP_SU_USER",
+ apr_table_setn(r->subprocess_env, "SUPHP_USER",
apr_pstrdup(r->pool, dconf->target_user));
}
else
{
- apr_table_setn(r->subprocess_env, "PHP_SU_USER",
+ apr_table_setn(r->subprocess_env, "SUPHP_USER",
apr_pstrdup(r->pool, sconf->target_user));
}
if (dconf->target_group)
{
- apr_table_setn(r->subprocess_env, "PHP_SU_GROUP",
+ apr_table_setn(r->subprocess_env, "SUPHP_GROUP",
apr_pstrdup(r->pool, dconf->target_group));
}
else
{
- apr_table_setn(r->subprocess_env, "PHP_SU_GROUP",
+ apr_table_setn(r->subprocess_env, "SUPHP_GROUP",
apr_pstrdup(r->pool, sconf->target_group));
}
#endif