/* * change directory for gprof to plop the gmon.out file * configure in httpd.conf: * GprofDir $RuntimeDir/ -> $ServerRoot/$RuntimeDir/gmon.out * GprofDir $RuntimeDir/% -> $ServerRoot/$RuntimeDir/gprof.$pid/gmon.out */ static void chdir_for_gprof(void) { core_server_config *sconf = ap_get_module_config(ap_server_conf->module_config, &core_module); char *dir = sconf->gprof_dir; const char *use_dir; if(dir) { apr_status_t res; char buf[512]; int len = strlen(sconf->gprof_dir) - 1; if(*(dir + len) == '%') { dir[len] = '\0'; apr_snprintf(buf, sizeof(buf), "%sgprof.%d", dir, (int)getpid()); } use_dir = ap_server_root_relative(pconf, buf[0] ? buf : dir); res = apr_dir_make(use_dir, 0755, pconf); if(res != APR_SUCCESS && !APR_STATUS_IS_EEXIST(res)) { ap_log_error(APLOG_MARK, APLOG_ERR, errno, ap_server_conf, "gprof: error creating directory %s", dir); } } else { use_dir = ap_server_root_relative(pconf, DEFAULT_REL_RUNTIMEDIR); } chdir(use_dir); }
static void *merge_yubiauth_dir_cfg(apr_pool_t *pool, void *BASE, void *ADD) { yubiauth_dir_cfg *base = BASE; yubiauth_dir_cfg *add = ADD; yubiauth_dir_cfg *dir = apr_pcalloc(pool, sizeof (yubiauth_dir_cfg)); /* merge */ dir->timeoutSeconds = (add->timeoutSeconds == UNSET) ? base->timeoutSeconds : add->timeoutSeconds; dir->requireSecure = (add->requireSecure == UNSET) ? base->requireSecure : add->requireSecure; dir->externalErrorPage = (add->externalErrorPage == UNSET) ? base->externalErrorPage : add->externalErrorPage; dir->userAuthDbFilename = (add->userAuthDbFilename == NULL) ? base->userAuthDbFilename : add->userAuthDbFilename; dir->tmpAuthDbFilename = (add->tmpAuthDbFilename == NULL) ? base->tmpAuthDbFilename : add->tmpAuthDbFilename; /* Set defaults configuration here */ if (dir->timeoutSeconds == UNSET) { dir->timeoutSeconds = DEFAULT_TIMEOUT; } if (dir->requireSecure == UNSET) { dir->requireSecure = DEFAULT_REQUIRE_SECURE; } if (dir->externalErrorPage == UNSET) { dir->externalErrorPage = DEFAULT_EXTERNAL_ERROR_PAGE; } if (dir->userAuthDbFilename == NULL) { dir->userAuthDbFilename = ap_server_root_relative(pool, DEFAULT_USER_DB); } if (dir->tmpAuthDbFilename == NULL) { dir->tmpAuthDbFilename = ap_server_root_relative(pool, DEFAULT_TMP_DB); } return dir; }
/* * change directory for gprof to plop the gmon.out file * configure in httpd.conf: * GprofDir $RuntimeDir/ -> $ServerRoot/$RuntimeDir/gmon.out * GprofDir $RuntimeDir/% -> $ServerRoot/$RuntimeDir/gprof.$pid/gmon.out */ static void chdir_for_gprof(void) { core_server_config *sconf = ap_get_module_config(ap_server_conf->module_config, &core_module); char *dir = sconf->gprof_dir; const char *use_dir; if(dir) { apr_status_t res; char *buf = NULL ; int len = strlen(sconf->gprof_dir) - 1; if(*(dir + len) == '%') { dir[len] = '\0'; buf = ap_append_pid(pconf, dir, "gprof."); } use_dir = ap_server_root_relative(pconf, buf ? buf : dir); res = apr_dir_make(use_dir, APR_UREAD | APR_UWRITE | APR_UEXECUTE | APR_GREAD | APR_GEXECUTE | APR_WREAD | APR_WEXECUTE, pconf); if(res != APR_SUCCESS && !APR_STATUS_IS_EEXIST(res)) { ap_log_error(APLOG_MARK, APLOG_ERR, res, ap_server_conf, "gprof: error creating directory %s", dir); } } else { use_dir = ap_server_root_relative(pconf, DEFAULT_REL_RUNTIMEDIR); } chdir(use_dir); }
static void *merge_yubiauth_dir_cfg(apr_pool_t *pool, void *BASE, void *ADD) { yubiauth_dir_cfg *base = BASE; yubiauth_dir_cfg *add = ADD; yubiauth_dir_cfg *dir = apr_pcalloc(pool, sizeof (yubiauth_dir_cfg)); /* merge */ dir->timeoutSeconds = (add->timeoutSeconds == UNSET) ? base->timeoutSeconds : add->timeoutSeconds; dir->requireSecure = (add->requireSecure == UNSET) ? base->requireSecure : add->requireSecure; dir->externalErrorPage = (add->externalErrorPage == UNSET) ? base->externalErrorPage : add->externalErrorPage; dir->userAuthDbFilename = (add->userAuthDbFilename == NULL) ? base->userAuthDbFilename : add->userAuthDbFilename; dir->tmpAuthDbFilename = (add->tmpAuthDbFilename == NULL) ? base->tmpAuthDbFilename : add->tmpAuthDbFilename; dir->validationProtocol = (add->validationProtocol == NULL) ? base->validationProtocol : add->validationProtocol; dir->validationHost = (add->validationHost == NULL) ? base->validationHost : add->validationHost; dir->validationPath = (add->validationPath == NULL) ? base->validationPath : add->validationPath; dir->apiVersion = (add->apiVersion == NULL) ? base->apiVersion : add->apiVersion; dir->shareDb = (add->shareDb == NULL) ? base->shareDb : add->shareDb; /* Set defaults configuration here */ if (dir->timeoutSeconds == UNSET) { dir->timeoutSeconds = DEFAULT_TIMEOUT; } if (dir->requireSecure == UNSET) { dir->requireSecure = DEFAULT_REQUIRE_SECURE; } if (dir->externalErrorPage == UNSET) { dir->externalErrorPage = DEFAULT_EXTERNAL_ERROR_PAGE; } if (dir->userAuthDbFilename == NULL) { dir->userAuthDbFilename = ap_server_root_relative(pool, DEFAULT_USER_DB); } if (dir->tmpAuthDbFilename == NULL) { dir->tmpAuthDbFilename = ap_server_root_relative(pool, DEFAULT_TMP_DB); } if (dir->validationProtocol == NULL) { dir->validationProtocol = "https"; } if (dir->validationHost == NULL) { dir->validationHost = "api.yubico.com"; } if (dir->validationPath == NULL) { dir->validationPath = "wsapi/verify"; } if (dir->shareDb == NULL) { dir->shareDb = DEFAULT_SHARE_DB; } return dir; }
/* ToDo: This function should be made to handle setting up * a scoreboard shared between processes using any IPC technique, * not just a shared memory segment */ static apr_status_t open_scoreboard(apr_pool_t *pconf) { #if APR_HAS_SHARED_MEMORY apr_status_t rv; char *fname = NULL; apr_pool_t *global_pool; /* We don't want to have to recreate the scoreboard after * restarts, so we'll create a global pool and never clean it. */ rv = apr_pool_create(&global_pool, NULL); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, "Fatal error: unable to create global pool " "for use with the scoreboard"); return rv; } /* The config says to create a name-based shmem */ if (ap_scoreboard_fname) { /* make sure it's an absolute pathname */ fname = ap_server_root_relative(pconf, ap_scoreboard_fname); if (!fname) { ap_log_error(APLOG_MARK, APLOG_CRIT, APR_EBADPATH, NULL, "Fatal error: Invalid Scoreboard path %s", ap_scoreboard_fname); return APR_EBADPATH; } return create_namebased_scoreboard(global_pool, fname); } else { /* config didn't specify, we get to choose shmem type */ rv = apr_shm_create(&ap_scoreboard_shm, scoreboard_size, NULL, global_pool); /* anonymous shared memory */ if ((rv != APR_SUCCESS) && (rv != APR_ENOTIMPL)) { ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, "Unable to create or access scoreboard " "(anonymous shared memory failure)"); return rv; } /* Make up a filename and do name-based shmem */ else if (rv == APR_ENOTIMPL) { /* Make sure it's an absolute pathname */ ap_scoreboard_fname = DEFAULT_SCOREBOARD; fname = ap_server_root_relative(pconf, ap_scoreboard_fname); return create_namebased_scoreboard(global_pool, fname); } } #endif /* APR_HAS_SHARED_MEMORY */ return APR_SUCCESS; }
static void* mod_mapcache_create_server_conf(apr_pool_t *pool, server_rec *s) { mapcache_server_cfg *cfg = apr_pcalloc(pool, sizeof(mapcache_server_cfg)); char *mutex_unique_name = apr_psprintf(pool,"mapcachemutex-%d",getpid()); cfg->mutex_name = ap_server_root_relative(pool, mutex_unique_name); cfg->aliases = NULL; return cfg; }
static const char *dso_load(cmd_parms *cmd, apr_dso_handle_t **modhandlep, const char *filename, const char **used_filename) { int retry = 0; const char *fullname = ap_server_root_relative(cmd->temp_pool, filename); char my_error[256]; if (filename != NULL && ap_strchr_c(filename, '/') == NULL) { /* retry on error without path to use dlopen()'s search path */ retry = 1; } if (fullname == NULL && !retry) { return apr_psprintf(cmd->temp_pool, "Invalid %s path %s", cmd->cmd->name, filename); } *used_filename = fullname; if (apr_dso_load(modhandlep, fullname, cmd->pool) == APR_SUCCESS) { return NULL; } if (retry) { *used_filename = filename; if (apr_dso_load(modhandlep, filename, cmd->pool) == APR_SUCCESS) return NULL; } return apr_pstrcat(cmd->temp_pool, "Cannot load ", filename, " into server: ", apr_dso_error(*modhandlep, my_error, sizeof(my_error)), NULL); }
static const char *load_file(cmd_parms *cmd, void *dummy, const char *filename) { apr_dso_handle_t *handle; const char *file; file = ap_server_root_relative(cmd->pool, filename); if (!file) { return apr_pstrcat(cmd->pool, "Invalid LoadFile path ", filename, NULL); } if (apr_dso_load(&handle, file, cmd->pool) != APR_SUCCESS) { char my_error[256]; return apr_pstrcat(cmd->pool, "Cannot load ", filename, " into server: ", apr_dso_error(handle, my_error, sizeof(my_error)), NULL); } ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL, "loaded file %s", filename); return NULL; }
/** * This function is called when the "JSONMatchLog" configuration directive is parsed. */ static const char *set_jsonerrorlog_path(cmd_parms *cmd, void *cfg, const char *arg) { dir_config_t *dcfg = (dir_config_t *) cfg; char *jsonmatchlog_path = apr_pstrdup(cmd->pool, arg); if (jsonmatchlog_path[0] == '|') { const char *pipe_name = jsonmatchlog_path + 1; piped_log *pipe_log; pipe_log = ap_open_piped_log(cmd->pool, pipe_name); if (pipe_log == NULL) return apr_psprintf(cmd->pool, "mod_defender: Failed to open the json match log pipe: %s", pipe_name); dcfg->jsonmatchlog_file = ap_piped_log_write_fd(pipe_log); } else { const char *file_name = ap_server_root_relative(cmd->pool, jsonmatchlog_path); apr_status_t rc; rc = apr_file_open(&dcfg->jsonmatchlog_file, file_name, APR_WRITE | APR_APPEND | APR_CREATE | APR_BINARY, APR_UREAD | APR_UWRITE | APR_GREAD, cmd->pool); if (rc != APR_SUCCESS) return apr_psprintf(cmd->pool, "mod_defender: Failed to open the json match log file: %s", file_name); } return NULL; // success }
const char *ap_mpm_set_coredumpdir(cmd_parms *cmd, void *dummy, const char *arg) { apr_finfo_t finfo; const char *fname; const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { return err; } fname = ap_server_root_relative(cmd->temp_pool, arg); if (!fname) { return apr_pstrcat(cmd->pool, "Invalid CoreDumpDirectory path ", arg, NULL); } if (apr_stat(&finfo, fname, APR_FINFO_TYPE, cmd->pool) != APR_SUCCESS) { return apr_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, " does not exist", NULL); } if (finfo.filetype != APR_DIR) { return apr_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, " is not a directory", NULL); } apr_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir)); ap_coredumpdir_configured = 1; return NULL; }
AP_DECLARE(apr_status_t) ap_replace_stderr_log(apr_pool_t *p, const char *fname) { apr_file_t *stderr_file; apr_status_t rc; char *filename = ap_server_root_relative(p, fname); if (!filename) { ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_CRIT, APR_EBADPATH, NULL, "Invalid -E error log file %s", fname); return APR_EBADPATH; } if ((rc = apr_file_open(&stderr_file, filename, APR_APPEND | APR_WRITE | APR_CREATE | APR_LARGEFILE, APR_OS_DEFAULT, p)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL, "%s: could not open error log file %s.", ap_server_argv0, fname); return rc; } if ((rc = apr_file_open_stderr(&stderr_log, p)) == APR_SUCCESS) { apr_file_flush(stderr_log); if ((rc = apr_file_dup2(stderr_log, stderr_file, p)) == APR_SUCCESS) { apr_file_close(stderr_file); } } if (rc != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_CRIT, rc, NULL, "unable to replace stderr with error_log"); } return rc; }
static const char *load_file(cmd_parms *cmd, void *dummy, char *filename) { ap_os_dso_handle_t handle; char *file; const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { return err; } file = ap_server_root_relative(cmd->pool, filename); if (!(handle = ap_os_dso_load(file))) { const char *my_error = ap_os_dso_error(); return ap_pstrcat (cmd->pool, "Cannot load ", filename, " into server:", my_error ? my_error : "(reason unknown)", NULL); } ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, NULL, "loaded file %s", filename); ap_register_cleanup(cmd->pool, (void *)handle, unload_file, ap_null_cleanup); return NULL; }
static const char *ssl_cmd_check_dir(cmd_parms *parms, const char **dir) { const char *dirpath = ap_server_root_relative(parms->pool, *dir); if (!dirpath) { return apr_pstrcat(parms->pool, parms->cmd->name, ": Invalid dir path ", *dir, NULL); } *dir = dirpath; if (ssl_util_path_check(SSL_FLAGS_CHECK_DIR, *dir, parms->pool)) { return NULL; } char *warn = apr_pstrcat(parms->pool, parms->cmd->name, ": directory '", *dir, "' does not exist", NULL); apn_warning(warn); return NULL; /*return apr_pstrcat(parms->pool, parms->cmd->name, ": directory '", *dir, "' does not exist", NULL); */ }
static const char *ssl_cmd_check_file(cmd_parms *parms, const char **file) { const char *filepath = ap_server_root_relative(parms->pool, *file); if (!filepath) { return apr_pstrcat(parms->pool, parms->cmd->name, ": Invalid file path ", *file, NULL); } *file = filepath; if (ssl_util_path_check(SSL_FLAGS_CHECK_FILE, *file, parms->pool)) { return NULL; } char *warn = apr_pstrcat(parms->pool, parms->cmd->name, ": file '", *file, "' does not exist or is empty", NULL); apn_warning(warn); return NULL; /*return apr_pstrcat(parms->pool, parms->cmd->name, ": file '", *file, "' does not exist or is empty", NULL); */ }
static void open_agent_log(server_rec *s, pool *p) { agent_log_state *cls = ap_get_module_config(s->module_config, &agent_log_module); char *fname = ap_server_root_relative(p, cls->fname); if (cls->agent_fd > 0) return; /* virtual log shared w/main server */ if (*cls->fname == '|') { piped_log *pl; pl = ap_open_piped_log(p, cls->fname + 1); if (pl == NULL) { ap_log_error(APLOG_MARK, APLOG_ERR, s, "couldn't spawn agent log pipe"); exit(1); } cls->agent_fd = ap_piped_log_write_fd(pl); } else if (*cls->fname != '\0') { if ((cls->agent_fd = ap_popenf(p, fname, xfer_flags, xfer_mode)) < 0) { ap_log_error(APLOG_MARK, APLOG_ERR, s, "could not open agent log file %s.", fname); exit(1); } } }
static void *ap_default_log_writer_init(apr_pool_t *p, server_rec *s, const char* name) { if (*name == '|') { piped_log *pl; pl = ap_open_piped_log(p, name + 1); if (pl == NULL) { return NULL;; } return ap_piped_log_write_fd(pl); } else { const char *fname = ap_server_root_relative(p, name); apr_file_t *fd; apr_status_t rv; if (!fname) { ap_log_error(APLOG_MARK, APLOG_ERR, APR_EBADPATH, s, "invalid transfer log path %s.", name); return NULL; } rv = apr_file_open(&fd, fname, xfer_flags, xfer_perms, p); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, "could not open transfer log file %s.", fname); return NULL; } return fd; } }
static const char *php_apache_phpini_set(cmd_parms *cmd, void *mconfig, const char *arg) { if (apache2_php_ini_path_override) { return "Only first PHPINIDir directive honored per configuration tree - subsequent ones ignored"; } apache2_php_ini_path_override = ap_server_root_relative(cmd->pool, arg); return NULL; }
int mod_dirsize_handler(request_rec *r) { BUFF *pipe_output; char buf[MAX_STRING_LEN]; char *sizeink=NULL; regmatch_t pmatch[2]; r->path_info = ap_make_dirstr_parent(r->pool, r->filename); if(!ap_bspawn_child(r->pool,dirsize, (void *) r, kill_after_timeout, NULL, &pipe_output, NULL)) { ap_log_error(APLOG_MARK, APLOG_ERR, r->server, "problems with dirsize subprocess"); return HTTP_INTERNAL_SERVER_ERROR; } ap_bgets(buf, sizeof(buf), pipe_output); regex_t *cpat = ap_pregcomp(r->pool, "^(.+)\t", REG_EXTENDED); if(regexec(cpat, buf, cpat->re_nsub+1, pmatch, 0) == 0) { sizeink = ap_pregsub(r->pool, "$1", buf, cpat->re_nsub+1, pmatch); } #ifdef DEBUG r->content_type = "text/html"; ap_send_http_header(r); ap_rprintf(r, "<html>\n"); ap_rprintf(r, "<head>\n"); ap_rprintf(r, "<title>mod_dirsize</title>\n"); ap_rprintf(r, "</head>\n"); ap_rprintf(r, "<body>\n"); ap_rprintf(r, "Request: %s<br>\n", r->the_request); ap_rprintf(r, "Server Hostname: %s<br>\n", r->server->server_hostname); ap_rprintf(r, "Server Admin: %s<br>\n", r->server->server_admin); ap_rprintf(r, "Filename: %s<br>\n", r->filename); ap_rprintf(r, "ServerRoot: %s<br>\n", ap_server_root_relative(r->pool, "")); ap_rprintf(r, "Path Info: %s<br>\n", r->path_info); ap_send_fb(pipe_output, r); ap_rprintf(r, "</body>\n"); ap_rprintf(r, "</html>\n"); #else r->content_type = "text/xml"; ap_send_http_header(r); ap_rprintf(r, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); ap_rprintf(r, "<dirsize xmlns:html=\"http://www.w3.org/1999/html\">\n"); ap_rprintf(r, "<sizeink>%s</sizeink>\n", sizeink); ap_rprintf(r, "</dirsize>"); #endif ap_bclose(pipe_output); return(OK); }
/** * Parse the server root. */ static const char * cse_config_server_root(cmd_parms *cmd, void *mconfig, char *value) { config_t *config = cse_get_cmd_config(cmd); config->resin_home = ap_server_root_relative(cmd->pool, value); return 0; }
const char *ssl_cmd_SSLPassPhraseDialog(cmd_parms *cmd, void *dcfg, const char *arg) { SSLSrvConfigRec *sc = mySrvConfig(cmd->server); const char *err; int arglen = strlen(arg); if ((err = ap_check_cmd_context(cmd, GLOBAL_ONLY))) { return err; } if (strcEQ(arg, "builtin")) { sc->server->pphrase_dialog_type = SSL_PPTYPE_BUILTIN; sc->server->pphrase_dialog_path = NULL; } else if ((arglen > 5) && strEQn(arg, "exec:", 5)) { sc->server->pphrase_dialog_type = SSL_PPTYPE_FILTER; sc->server->pphrase_dialog_path = ap_server_root_relative(cmd->pool, arg+5); if (!sc->server->pphrase_dialog_path) { return apr_pstrcat(cmd->pool, "Invalid SSLPassPhraseDialog exec: path ", arg+5, NULL); } if (!ssl_util_path_check(SSL_PCM_EXISTS, sc->server->pphrase_dialog_path, cmd->pool)) { char *warn = apr_pstrcat(cmd->pool, "SSLPassPhraseDialog: file '", sc->server->pphrase_dialog_path, "' does not exist", NULL); apn_warning(warn); /*return apr_pstrcat(cmd->pool, "SSLPassPhraseDialog: file '", sc->server->pphrase_dialog_path, "' does not exist", NULL); */ } } else if ((arglen > 1) && (arg[0] == '|')) { sc->server->pphrase_dialog_type = SSL_PPTYPE_PIPE; sc->server->pphrase_dialog_path = arg + 1; char *comment = apr_pstrcat(cmd->pool, "The argument is not supported in Nginx:", arg, NULL); apn_set_unsupport(cmd, comment); } else { return "SSLPassPhraseDialog: Invalid argument"; } return NULL; }
static const char *socache_shmcb_create(ap_socache_instance_t **context, const char *arg, apr_pool_t *tmp, apr_pool_t *p) { ap_socache_instance_t *ctx; char *path, *cp, *cp2; /* Allocate the context. */ *context = ctx = apr_pcalloc(p, sizeof *ctx); ctx->shm_size = 1024*512; /* 512KB */ if (!arg || *arg == '\0') { /* Use defaults. */ return NULL; } ctx->data_file = path = ap_server_root_relative(p, arg); cp = strrchr(path, '('); cp2 = path + strlen(path) - 1; if (cp) { char *endptr; if (*cp2 != ')') { return "Invalid argument: no closing parenthesis or cache size " "missing after pathname with parenthesis"; } *cp++ = '\0'; *cp2 = '\0'; ctx->shm_size = strtol(cp, &endptr, 10); if (endptr != cp2) { return "Invalid argument: cache size not numerical"; } if (ctx->shm_size < 8192) { return "Invalid argument: size has to be >= 8192 bytes"; } if (ctx->shm_size >= SHMCB_MAX_SIZE) { return apr_psprintf(tmp, "Invalid argument: size has " "to be < %d bytes on this platform", SHMCB_MAX_SIZE); } } else if (cp2 >= path && *cp2 == ')') { return "Invalid argument: no opening parenthesis"; } return NULL; }
CStr qEnvApacheServer::MapFullPath(const char *path) { #ifdef APACHE2 ap_pool * p; apr_pool_create_ex(&p,NULL,NULL,NULL); #else ap_pool * p = ap_make_sub_pool(NULL); #endif CStr r = ap_server_root_relative(p, (char *) path); ap_destroy_pool(p); return r; }
AP_DECLARE(apr_status_t) ap_replace_stderr_log(apr_pool_t *p, const char *fname) { apr_file_t *stderr_file; apr_status_t rc; char *filename = ap_server_root_relative(p, fname); if (!filename) { ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_CRIT, APR_EBADPATH, NULL, "Invalid -E error log file %s", fname); return APR_EBADPATH; } if ((rc = apr_file_open(&stderr_file, filename, APR_APPEND | APR_WRITE | APR_CREATE | APR_LARGEFILE, APR_OS_DEFAULT, p)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL, "%s: could not open error log file %s.", ap_server_argv0, fname); return rc; } if (!stderr_pool) { /* This is safe provided we revert it when we are finished. * We don't manager the callers pool! */ stderr_pool = p; } if ((rc = apr_file_open_stderr(&stderr_log, stderr_pool)) == APR_SUCCESS) { apr_file_flush(stderr_log); if ((rc = apr_file_dup2(stderr_log, stderr_file, stderr_pool)) == APR_SUCCESS) { apr_file_close(stderr_file); /* * You might ponder why stderr_pool should survive? * The trouble is, stderr_pool may have s_main->error_log, * so we aren't in a position to destory stderr_pool until * the next recycle. There's also an apparent bug which * is not; if some folk decided to call this function before * the core open error logs hook, this pool won't survive. * Neither does the stderr logger, so this isn't a problem. */ } } /* Revert, see above */ if (stderr_pool == p) stderr_pool = NULL; if (rc != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_CRIT, rc, NULL, "unable to replace stderr with error log file"); } return rc; }
void ap_initConfigDB( TServer *s,const char *configFileName ) { char *fname = 0; if (s == 0 || configFileName == 0 || *configFileName == 0) { return; } fname = (char *)ap_server_root_relative(s, (char *)configFileName); initConfigDB(fname, ap_progname()); }
static const char * ftpd_dbm_cmd_dbmpath(cmd_parms *cmd, void *config, const char *arg) { ftpd_dbm_server_conf *conf = ap_get_module_config(cmd->server->module_config, &ftpd_dbm_module); conf->chrootdb_path = ap_server_root_relative(cmd->pool, arg); if (!conf->chrootdb_path) { return apr_pstrcat(cmd->pool, "Invalid FTPChrootDBM: ", arg, NULL); } return NULL; }
const char *nss_cmd_NSSPassPhraseDialog(cmd_parms *cmd, void *dcfg, const char *arg) { SSLModConfigRec *mc = myModConfig(cmd->server); int arglen = strlen(arg); if (strcEQ(arg, "builtin")) { mc->pphrase_dialog_type = SSL_PPTYPE_BUILTIN; mc->pphrase_dialog_path = NULL; } else if (((arglen > 5) && strEQn(arg, "file:", 5)) || ((arglen > 6) && strEQn(arg, "defer:", 6))) { apr_finfo_t finfo; apr_status_t rc; if (strEQn(arg, "file:", 5)) { mc->pphrase_dialog_type = SSL_PPTYPE_FILE; mc->pphrase_dialog_path = ap_server_root_relative(cmd->pool, arg+5); } else { mc->pphrase_dialog_type = SSL_PPTYPE_DEFER; mc->pphrase_dialog_path = ap_server_root_relative(cmd->pool, arg+6); } if (!mc->pphrase_dialog_path) return apr_pstrcat(cmd->pool, "Invalid NSSPassPhraseDialog file: path ", arg+5, NULL); rc = apr_stat(&finfo, mc->pphrase_dialog_path, APR_FINFO_TYPE|APR_FINFO_SIZE, cmd->pool); if ((rc != APR_SUCCESS) || (finfo.filetype != APR_REG)) { return apr_pstrcat(cmd->pool, "NSSPassPhraseDialog: file '", mc->pphrase_dialog_path, "' does not exist", NULL); } } return NULL; }
static const char *set_dbmfile(cmd_parms *cmd, void *dconf, const char *arg) { express_server_conf *sconf; sconf = ap_get_module_config(cmd->server->module_config, &proxy_express_module); if ((sconf->dbmfile = ap_server_root_relative(cmd->pool, arg)) == NULL) { return apr_pstrcat(cmd->pool, "ProxyExpressDBMFile: bad path to file: ", arg, NULL); } return NULL; }
AP_DECLARE(void) ap_log_pid(apr_pool_t *p, const char *filename) { apr_file_t *pid_file = NULL; apr_finfo_t finfo; static pid_t saved_pid = -1; pid_t mypid; apr_status_t rv; const char *fname; if (!filename) { return; } fname = ap_server_root_relative(p, filename); if (!fname) { ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_CRIT, APR_EBADPATH, NULL, "Invalid PID file path %s, ignoring.", filename); return; } mypid = getpid(); if (mypid != saved_pid && apr_stat(&finfo, fname, APR_FINFO_MTIME, p) == APR_SUCCESS) { /* AP_SIG_GRACEFUL and HUP call this on each restart. * Only warn on first time through for this pid. * * XXX: Could just write first time through too, although * that may screw up scripts written to do something * based on the last modification time of the pid file. */ ap_log_perror(APLOG_MARK, APLOG_WARNING, 0, p, "pid file %s overwritten -- Unclean " "shutdown of previous Apache run?", fname); } if ((rv = apr_file_open(&pid_file, fname, APR_WRITE | APR_CREATE | APR_TRUNCATE, APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD, p)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, "could not create %s", fname); ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, "%s: could not log pid to file %s", ap_server_argv0, fname); exit(1); } apr_file_printf(pid_file, "%ld" APR_EOL_STR, (long)mypid); apr_file_close(pid_file); saved_pid = mypid; }
static void log_sql_module_init(server_rec *s, apr_pool_t *p) #endif { /* TODO: Add local_address, remote_address, server_name, connection_status */ /* Register handlers */ log_sql_register_item(s,p,'A', extract_agent, "agent", 1, 1); log_sql_register_item(s,p,'a', extract_request_query, "request_args", 1, 1); log_sql_register_item(s,p,'b', extract_bytes_sent, "bytes_sent", 0, 0); log_sql_register_item(s,p,'c', extract_cookie, "cookie", 0, 1); /* TODO: Document */ log_sql_register_item(s,p,'f', extract_request_file, "request_file", 0, 1); log_sql_register_item(s,p,'H', extract_request_protocol, "request_protocol", 0, 1); log_sql_register_item(s,p,'h', extract_remote_host, "remote_host", 0, 1); log_sql_register_item(s,p,'I', extract_unique_id, "id", 0, 1); log_sql_register_item(s,p,'l', extract_remote_logname, "remote_logname", 0, 1); log_sql_register_item(s,p,'m', extract_request_method, "request_method", 0, 1); log_sql_register_item(s,p,'M', extract_machine_id, "machine_id", 0, 1); log_sql_register_item(s,p,'P', extract_child_pid, "child_pid", 0, 0); log_sql_register_item(s,p,'p', extract_server_port, "server_port", 0, 0); log_sql_register_item(s,p,'R', extract_referer, "referer", 1, 1); log_sql_register_item(s,p,'r', extract_request_line, "request_line", 1, 1); log_sql_register_item(s,p,'S', extract_request_timestamp, "time_stamp", 0, 0); log_sql_register_item(s,p,'s', extract_status, "status", 1, 0); log_sql_register_item(s,p,'T', extract_request_duration, "request_duration", 1, 0); log_sql_register_item(s,p,'t', extract_request_time, "request_time", 0, 1); log_sql_register_item(s,p,'u', extract_remote_user, "remote_user", 0, 1); log_sql_register_item(s,p,'U', extract_request_uri, "request_uri", 1, 1); log_sql_register_item(s,p,'x', extract_forwarded_for, "remote_host", 0, 1); log_sql_register_item(s,p,'v', extract_virtual_host, "virtual_host", 0, 1); log_sql_register_item(s,p,'V', extract_server_name, "virtual_host", 0, 1); if (global_config.announce) { ap_add_version_component(p, PACKAGE_NAME"/"PACKAGE_VERSION); } /* ap_server_root_relative any default preserve file locations */ { server_rec *cur_s; const char *default_p = ap_server_root_relative(p, DEFAULT_PRESERVE_FILE); for (cur_s = s; cur_s != NULL; cur_s= cur_s->next) { logsql_state *cls = ap_get_module_config(cur_s->module_config, &log_sql_module); if (cls->preserve_file == DEFAULT_PRESERVE_FILE) cls->preserve_file = default_p; } } global_config.db.p = p; #if defined(WITH_APACHE20) return OK; #endif }
apr_status_t ssl_die(server_rec *s) { if (s != NULL && s->is_virtual && s->error_fname != NULL) ap_log_error(APLOG_MARK, APLOG_EMERG, 0, NULL, APLOGNO(02311) "Fatal error initialising mod_ssl, exiting. " "See %s for more information", ap_server_root_relative(s->process->pool, s->error_fname)); else ap_log_error(APLOG_MARK, APLOG_EMERG, 0, NULL, APLOGNO(02312) "Fatal error initialising mod_ssl, exiting."); return APR_EGENERAL; }