From: Jim Jagielski Date: Wed, 19 Jan 2011 02:41:49 +0000 (+0000) Subject: Make the balancer shared memory slot more human readable. But we need X-Git-Tag: 2.3.11~163 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a713db09d4447f885dccc1b87905e47bd2b02450;p=thirdparty%2Fapache%2Fhttpd.git Make the balancer shared memory slot more human readable. But we need to make it a "safe" filename, so create 2 funcs which do that. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1060657 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/ap_mmn.h b/include/ap_mmn.h index ac9b43006e5..4add24d42ef 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -297,6 +297,7 @@ * 20110117.0 (2.3.11-dev) Merge sections in separate step (ap_if_walk). * Add core_dir_config->sec_if. Add ap_add_if_conf(). * Add pool argument to ap_add_file_conf(). + * 20110117.1 (2.3.11-dev) Add ap_pstr2alnum() and ap_str2alnum() */ #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */ @@ -304,7 +305,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20110117 #endif -#define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 1 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/include/httpd.h b/include/httpd.h index 7e3920182c4..e85620d0927 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -1828,6 +1828,29 @@ AP_DECLARE(apr_status_t) ap_timeout_parameter_parse( */ AP_DECLARE(int) ap_request_has_body(request_rec *r); +/** + * Cleanup a string. + * We only allow alphanumeric chars. Non-printable + * map to 'x' and all others map to '_' + * + * @param p pool to use to allocate dest + * @param src string to clean up + * @param dest cleaned up, allocated string + * @return Status value indicating whether the cleaning was successful or not. + */ +AP_DECLARE(apr_status_t) ap_pstr2alnum(apr_pool_t *p, const char *src, char **dest); + +/** + * Cleanup a string. + * We only allow alphanumeric chars. Non-printable + * map to 'x' and all others map to '_' + * + * @param src string to clean up + * @param dest cleaned up, pre-allocated string + * @return Status value indicating whether the cleaning was successful or not. + */ +AP_DECLARE(apr_status_t) ap_str2alnum(const char *src, char *dest); + /* Misc system hackery */ /** * Given the name of an object in the file system determine if it is a directory diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index 8e4b6088002..2d956ce0710 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -59,7 +59,6 @@ #include "http_connection.h" #include "util_filter.h" #include "util_ebcdic.h" -#include "util_md5.h" #include "ap_provider.h" #include "ap_slotmem.h" diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index 677ab740239..276ae48b6de 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -736,7 +736,7 @@ static int balancer_post_config(apr_pool_t *pconf, apr_pool_t *plog, ap_slotmem_instance_t *new = NULL; balancer->max_workers = balancer->workers->nelts + balancer->growth; - balancer->sname = ap_md5(pconf, (const unsigned char *)balancer->name); + ap_pstr2alnum(pconf, balancer->name, &balancer->sname); /* Create global mutex */ rv = ap_global_mutex_create(&(balancer->mutex), NULL, balancer_mutex_type, diff --git a/server/util.c b/server/util.c index 3c6630c67b0..d78a075b532 100644 --- a/server/util.c +++ b/server/util.c @@ -2255,3 +2255,27 @@ AP_DECLARE_NONSTD(apr_status_t) ap_pool_cleanup_set_null(void *data_) *ptr = NULL; return APR_SUCCESS; } + +AP_DECLARE(apr_status_t) ap_str2alnum(const char *src, char *dest) { + + for ( ; *src; src++, dest++) + { + if (!apr_isprint(*src)) + *dest = 'x'; + else if (!apr_isalnum(*src)) + *dest = '_'; + else + *dest = (char)*src; + } + *dest = '\0'; + return APR_SUCCESS; + +} + +AP_DECLARE(apr_status_t) ap_pstr2alnum(apr_pool_t *p, const char *src, char **dest) +{ + *dest = apr_palloc(p, strlen(src)+1); + if (!*dest) + return APR_ENOMEM; + return ap_str2alnum(src, *dest); +}