static const char * SVNMasterURI_cmd(cmd_parms *cmd, void *config, const char *arg1) { dir_conf_t *conf = config; apr_uri_t parsed_uri; const char *uri_base_name = ""; /* SVNMasterURI requires mod_proxy and mod_proxy_http * (r->handler = "proxy-server" in mirror.c), make sure * they are present. */ if (ap_find_linked_module("mod_proxy.c") == NULL) return "module mod_proxy not loaded, required for SVNMasterURI"; if (ap_find_linked_module("mod_proxy_http.c") == NULL) return "module mod_proxy_http not loaded, required for SVNMasterURI"; if (APR_SUCCESS != apr_uri_parse(cmd->pool, arg1, &parsed_uri)) return "unable to parse SVNMasterURI value"; if (parsed_uri.path) uri_base_name = svn_urlpath__basename( svn_urlpath__canonicalize(parsed_uri.path, cmd->pool), cmd->pool); if (! *uri_base_name) return "SVNMasterURI value must not be a server root"; conf->master_uri = apr_pstrdup(cmd->pool, arg1); return NULL; }
void embperl_ApacheAddModule (void) { bApDebug |= ap_exists_config_define("EMBPERL_APDEBUG") ; #ifdef APACHE2 if (bApDebug) ap_log_error (APLOG_MARK, APLOG_WARNING | APLOG_NOERRNO, APLOG_STATUSCODE NULL, "EmbperlDebug: Perl part initialization start [%d/%d]\n", getpid(), gettid()) ; return ; #else if (!ap_find_linked_module("mod_embperl.c")) { apr_pool_t * pool ; if (bApDebug) ap_log_error (APLOG_MARK, APLOG_WARNING | APLOG_NOERRNO, APLOG_STATUSCODE NULL, "EmbperlDebug: About to add mod_embperl.c as dynamic module [%d/%d]\n", getpid(), gettid()) ; ap_add_module (&embperl_module) ; pool = perl_get_startup_pool () ; embperl_ApacheInitUnload (pool) ; } else if (bApDebug) ap_log_error (APLOG_MARK, APLOG_WARNING | APLOG_NOERRNO, APLOG_STATUSCODE NULL, "EmbperlDebug: mod_embperl.c already added as dynamic module [%d/%d]\n", getpid(), gettid()) ; #endif }
static int post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) { proxy_available = (ap_find_linked_module("mod_proxy.c") != NULL); return OK; }
static int vhx_init_handler(apr_pool_t * pconf, apr_pool_t * plog, apr_pool_t * ptemp, server_rec * s) { /* make sure that mod_ldap (util_ldap) is loaded */ if (ap_find_linked_module("util_ldap.c") == NULL) { VH_AP_LOG_ERROR(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, s, "%s: (vhx_init_handler) module mod_ldap missing. Mod_ldap (aka. util_ldap) " "must be loaded in order for vhx to function properly",VH_NAME); return HTTP_INTERNAL_SERVER_ERROR; } VH_AP_LOG_ERROR(APLOG_MARK, APLOG_INFO, 0, s, "Loading %s version %s", VH_NAME,VH_VERSION); ap_add_version_component(pconf, VH_VERSION); #ifdef HAVE_MPM_ITK_SUPPORT unsigned short int itk_enable = 1; server_rec *sp; module *mpm_itk_module = ap_find_linked_module("itk.c"); if (mpm_itk_module == NULL) { VH_AP_LOG_ERROR(APLOG_MARK, APLOG_ERR, 0, s, "%s: (vhx_init_handler) itk.c is not loaded",VH_NAME); itk_enable = 0; } for (sp = s; sp; sp = sp->next) { vhx_config_rec *vhr = (vhx_config_rec *) ap_get_module_config(sp->module_config, &vhostx_module); if (vhr->itk_enable) { if (!itk_enable) { vhr->itk_enable = 0; } else { itk_conf *cfg = (itk_conf *) ap_get_module_config(sp->module_config, mpm_itk_module); vhr->itk_defuid = cfg->uid; vhr->itk_defgid = cfg->gid; //vhr->itk_defusername = DEFAULT_USER; VH_AP_LOG_ERROR(APLOG_MARK, APLOG_DEBUG, 0, sp, "vhx_init_handler: itk uid='%d' itk gid='%d' "/*itk username='******'*/, cfg->uid, cfg->gid/*, cfg->username */); } } } #endif /* HAVE_MPM_ITK_SUPPORT */ return OK; }
static int log_fluentd_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) { static APR_OPTIONAL_FN_TYPE(ap_log_set_writer_init) *log_set_writer_init_fn = NULL; static APR_OPTIONAL_FN_TYPE(ap_log_set_writer) *log_set_writer_fn = NULL; log_set_writer_init_fn = APR_RETRIEVE_OPTIONAL_FN(ap_log_set_writer_init); log_set_writer_fn = APR_RETRIEVE_OPTIONAL_FN(ap_log_set_writer); if (log_set_writer_init_fn && log_set_writer_fn) { if (!normal_log_writer_init) { module *mod_log_config = ap_find_linked_module("mod_log_config.c"); normal_log_writer_init = log_set_writer_init_fn(log_fluentd_writer_init); normal_log_writer = log_set_writer_fn(log_fluentd_writer); } } return OK; }
static void child_init(apr_pool_t *p, server_rec *s) { aps_trace_call(s); struct aaa *a = aaa_new(); aaa_set_opt(a, AAA_OPT_USERDATA, (const char *)s); aaa_set_opt(a, AAA_OPT_CUSTOMLOG, (char *)custom_log); for (; s; s = s->next) { struct srv *srv; srv = ap_get_module_config(s->module_config, &MODULE_ENTRY); srv->pid = getpid(); srv->aaa = a; srv->mod_ssl = ap_find_linked_module("mod_ssl.c"); } apr_pool_cleanup_register(p, a, child_fini, child_fini); }
static void embperl_ApacheInitCleanup (void * p) #endif { #ifdef APACHE2 if (bApDebug) ap_log_error (APLOG_MARK, APLOG_WARNING | APLOG_NOERRNO, APLOG_STATUSCODE NULL, "EmbperlDebug: embperl_ApacheInitCleanup [%d/%d]\n", getpid(), gettid()) ; return OK ; #else module * m ; /* make sure embperl module is removed before mod_perl in case mod_perl is loaded dynamicly*/ if ((m = ap_find_linked_module("mod_perl.c"))) { if (m -> dynamic_load_handle) { if (bApDebug) ap_log_error (APLOG_MARK, APLOG_WARNING | APLOG_NOERRNO, APLOG_STATUSCODE NULL, "EmbperlDebug: ApacheInitCleanup: mod_perl.c dynamicly loaded -> remove mod_embperl.c [%d/%d]\n", getpid(), gettid()) ; /*embperl_EndPass1 () ;*/ ap_remove_module (&embperl_module) ; } else { if (bApDebug) ap_log_error (APLOG_MARK, APLOG_WARNING | APLOG_NOERRNO, APLOG_STATUSCODE NULL, "EmbperlDebug: ApacheInitCleanup: mod_perl.c not dynamic loaded [%d/%d]\n", getpid(), gettid()) ; embperl_EndPass1 () ; } } else { if (bApDebug) ap_log_error (APLOG_MARK, APLOG_WARNING | APLOG_NOERRNO, APLOG_STATUSCODE NULL, "EmbperlDebug: ApacheInitCleanup: mod_perl.c not found [%d/%d]\n", getpid(), gettid()) ; embperl_EndPass1 () ; } #endif }
/* * This function will configure MPM-ITK */ static int vhx_itk_post_read(request_rec *r) { uid_t libhome_uid; gid_t libhome_gid; int vhost_found_by_request = DECLINED; vhx_config_rec *vhr = (vhx_config_rec *) ap_get_module_config(r->server->module_config, &vhostx_module); VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_itk_post_read: BEGIN ***,pid=%d",getpid()); vhx_request_t *reqc; reqc = ap_get_module_config(r->request_config, &vhostx_module); if (!reqc) { reqc = (vhx_request_t *)apr_pcalloc(r->pool, sizeof(vhx_request_t)); reqc->vhost_found = VH_VHOST_INFOS_NOT_YET_REQUESTED; ap_set_module_config(r->request_config, &vhostx_module, reqc); } vhx_conn_cfg_t *conn_cfg = (vhx_conn_cfg_t*) ap_get_module_config(r->connection->conn_config, &vhostx_module); if (!conn_cfg) { conn_cfg = apr_pcalloc(r->connection->pool, sizeof(vhx_conn_cfg_t)); conn_cfg->last_vhost = NULL; conn_cfg->last_vhost_status = VH_VHOST_INFOS_NOT_YET_REQUESTED; ap_set_module_config(r->connection->conn_config, &vhostx_module, conn_cfg); } if(r->hostname != NULL) { conn_cfg->last_vhost = apr_pstrdup(r->pool, r->hostname); vhost_found_by_request = getldaphome(r, vhr, r->hostname, reqc); if (vhost_found_by_request == OK) { libhome_uid = atoi(reqc->uid); libhome_gid = atoi(reqc->gid); } else { if (vhr->lamer_mode) { if ((strncasecmp(r->hostname, "www.",4) == 0) && (strlen(r->hostname) > 4)) { VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_itk_post_read: Lamer friendly mode engaged"); char *lhost; lhost = apr_pstrdup(r->pool, r->hostname + 4); VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_itk_post_read: Found a lamer for %s -> %s", r->hostname, lhost); vhost_found_by_request = getldaphome(r, vhr, lhost, reqc); if (vhost_found_by_request == OK) { libhome_uid = atoi(reqc->uid); libhome_gid = atoi(reqc->gid); VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_itk_post_read: lamer for %s -> %s has itk uid='%d' itk gid='%d'", r->hostname, lhost, libhome_uid, libhome_gid); } else { libhome_uid = vhr->itk_defuid; libhome_gid = vhr->itk_defgid; VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_itk_post_read: no lamer found for %s set default itk uid='%d' itk gid='%d'", r->hostname, libhome_uid, libhome_gid); } } else { libhome_uid = vhr->itk_defuid; libhome_gid = vhr->itk_defgid; } } else { libhome_uid = vhr->itk_defuid; libhome_gid = vhr->itk_defgid; } } if (vhost_found_by_request == OK) { conn_cfg->last_vhost_status = VH_VHOST_INFOS_FOUND; /* If ITK support is not enabled, then don't process request */ if (vhr->itk_enable) { module *mpm_itk_module = ap_find_linked_module("itk.c"); if (mpm_itk_module == NULL) { VH_AP_LOG_RERROR(APLOG_MARK, APLOG_ERR, 0, r, "%s: (vhx_itk_post_read) itk.c is not loaded",VH_NAME); return HTTP_INTERNAL_SERVER_ERROR; } itk_conf *cfg = (itk_conf *) ap_get_module_config(r->per_dir_config, mpm_itk_module); VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_itk_post_read: itk uid='%d' itk gid='%d' itk username='******' before change", cfg->uid, cfg->gid, cfg->username); char *itk_username = NULL; struct passwd *pw = getpwuid(libhome_uid); if(pw != NULL) { cfg->uid = libhome_uid; cfg->gid = libhome_gid; /* set the username - otherwise MPM-ITK will not work */ itk_username = apr_pstrdup(r->pool, pw->pw_name); cfg->username = itk_username; //chroot if(vhr->chroot_enable != 0 && reqc->chroot_dir != NULL) { if (ap_is_directory(r->pool, reqc->chroot_dir)) { if(chroot(reqc->chroot_dir)<0) { VH_AP_LOG_RERROR(APLOG_MARK, APLOG_WARNING, 0, r, "%s: (vhx_itk_post_read) couldn't chroot to %s", VH_NAME, reqc->chroot_dir); if(chdir("/")<0) { VH_AP_LOG_RERROR(APLOG_MARK, APLOG_WARNING, 0, r, "vhx_itk_post_read: couldn't chdir to / after chroot to '%s'",reqc->chroot_dir); } } else { VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_itk_post_read: chroot to %s",reqc->chroot_dir); } } else { VH_AP_LOG_RERROR(APLOG_MARK, APLOG_WARNING, 0, r, "%s: (vhx_itk_post_read) chroot directory '%s' does not exist. Skipping chroot", VH_NAME, reqc->chroot_dir); } } else { VH_AP_LOG_RERROR(APLOG_MARK, APLOG_WARNING, 0, r, "vhx_itk_post_read: chroot not enabled or chroot_dir empty. Skipping chroot."); } } VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_itk_post_read: itk uid='%d' itk gid='%d' itk username='******' after change", cfg->uid, cfg->gid, cfg->username); } } else { VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_itk_post_read: set VH_VHOST_INFOS_NOT_FOUND"); reqc->vhost_found = VH_VHOST_INFOS_NOT_FOUND; conn_cfg->last_vhost_status = VH_VHOST_INFOS_NOT_FOUND; } } VH_AP_LOG_RERROR(APLOG_MARK, APLOG_DEBUG, 0, r, "vhx_itk_post_read: END ***"); return OK; }