mod_suexec.c revision 78cd48acd325773619d78ac0d7263a99a8922fae
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher/* Copyright 2000-2004 The Apache Software Foundation
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher * Licensed under the Apache License, Version 2.0 (the "License");
294e9a5521d327c5cdc49beeb9cb9e703b3134f1Jan Zeleny * you may not use this file except in compliance with the License.
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher * You may obtain a copy of the License at
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher * Unless required by applicable law or agreed to in writing, software
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher * distributed under the License is distributed on an "AS IS" BASIS,
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher * See the License for the specific language governing permissions and
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher * limitations under the License.
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher * Create a configuration specific to this module for a server or directory
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher * location, and fill it with the default settings.
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher suexec_config_t *cfg = apr_palloc(p, sizeof(suexec_config_t));
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher * Respond to a callback to create configuration record for a server or
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher * vhost environment.
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagherstatic void *create_mconfig_for_server(apr_pool_t *p, server_rec *s)
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher * Respond to a callback to create a config record for a specific directory.
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagherstatic void *create_mconfig_for_directory(apr_pool_t *p, char *dir)
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagherstatic const char *set_suexec_ugid(cmd_parms *cmd, void *mconfig,
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher suexec_config_t *cfg = (suexec_config_t *) mconfig;
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher "Warning: SuexecUserGroup directive requires SUEXEC wrapper.\n");
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagherstatic ap_unix_identity_t *get_suexec_id_doer(const request_rec *r)
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher (suexec_config_t *) ap_get_module_config(r->per_dir_config, &suexec_module);
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher#define SUEXEC_POST_CONFIG_USERDATA "suexec_post_config_userdata"
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagherstatic int suexec_post_config(apr_pool_t *p, apr_pool_t *plog,
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher apr_pool_userdata_get(&reported, SUEXEC_POST_CONFIG_USERDATA,
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher if ((reported == NULL) && unixd_config.suexec_enabled) {
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, s,
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher "suEXEC mechanism enabled (wrapper: %s)", SUEXEC_BIN);
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher apr_pool_userdata_set((void *)1, SUEXEC_POST_CONFIG_USERDATA,
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher * Define the directives specific to this module. This structure is referenced
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher * later by the 'module' structure.
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher /* XXX - Another important reason not to allow this in .htaccess is that
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher * the ap_[ug]name2id() is not thread-safe */
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher AP_INIT_TAKE2("SuexecUserGroup", set_suexec_ugid, NULL, RSRC_CONF,
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher "User and group for spawned processes"),
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher ap_hook_get_suexec_identity(get_suexec_id_doer,NULL,NULL,APR_HOOK_MIDDLE);