MCPcopy Create free account
hub / github.com/apache/httpd / fixup_uds_filename

Function fixup_uds_filename

modules/proxy/proxy_util.c:2444–2516  ·  view source on GitHub ↗

* In the case of the reverse proxy, we need to see if we * were passed a UDS url (eg: from mod_proxy) and adjust uds_path * as required. */

Source from the content-addressed store, hash-verified

2442 * as required.
2443 */
2444static int fixup_uds_filename(request_rec *r)
2445{
2446 char *uds_url = r->filename + 6, *origin_url;
2447
2448 if (!strncmp(r->filename, "proxy:", 6) &&
2449 !ap_cstr_casecmpn(uds_url, "unix:", 5) &&
2450 (origin_url = ap_strchr(uds_url + 5, '|'))) {
2451 char *uds_path = NULL, *col;
2452 apr_uri_t urisock;
2453 apr_status_t rv;
2454
2455 *origin_url = '\0';
2456 rv = apr_uri_parse(r->pool, uds_url, &urisock);
2457 *origin_url++ = '|';
2458
2459 if (rv == APR_SUCCESS && urisock.path && (!urisock.hostname
2460 || !urisock.hostname[0])) {
2461 uds_path = ap_runtime_dir_relative(r->pool, urisock.path);
2462 }
2463 if (!uds_path || !(col = ap_strchr(origin_url, ':'))) {
2464 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(10292)
2465 "Invalid proxy UDS filename (%s)", r->filename);
2466 apr_table_unset(r->notes, "uds_path");
2467 return HTTP_BAD_REQUEST;
2468 }
2469 apr_table_setn(r->notes, "uds_path", uds_path);
2470
2471 ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
2472 "*: fixup UDS from %s: %s (%s)",
2473 r->filename, origin_url, uds_path);
2474
2475 /* The hostname part of the URL is not mandated for UDS though
2476 * the canon_handler hooks will require it. ProxyPass URLs are
2477 * fixed at load time by adding "localhost" automatically in the
2478 * worker URL, but SetHandler "proxy:unix:/udspath|scheme:[//]"
2479 * URLs are not so we have to fix it here the same way.
2480 */
2481 if (!col[1]) {
2482 /* origin_url is "scheme:" */
2483 r->filename = apr_pstrcat(r->pool, "proxy:",
2484 origin_url, "//localhost",
2485 NULL);
2486 }
2487 /* For a SetHandler "proxy:..." in a <Location "/path">, the "/path"
2488 * is appended to r->filename, hence the below origin_url cases too:
2489 */
2490 else if (col[1] == '/' && (col[2] != '/' /* "scheme:/path" */
2491 || col[3] == '/' /* "scheme:///path" */
2492 || !col[3])) { /* "scheme://" */
2493 char *scheme = origin_url;
2494 *col = '\0'; /* nul terminate scheme */
2495 if (col[2] != '/') {
2496 origin_url = col + 1;
2497 }
2498 else {
2499 origin_url = col + 3;
2500 }
2501 r->filename = apr_pstrcat(r->pool, "proxy:",

Callers 2

ap_proxy_canon_urlFunction · 0.85

Calls 3

ap_cstr_casecmpnFunction · 0.85
ap_strchrFunction · 0.85
ap_runtime_dir_relativeFunction · 0.85

Tested by

no test coverage detected