From: William A. Rowe Jr Date: Tue, 16 Oct 2001 02:15:45 +0000 (+0000) Subject: Streamline this function, and append the trailing slash for any directories X-Git-Tag: 2.0.26~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=940a7786c7812b8940b12f7564d393f4de2aa4cf;p=apache Streamline this function, and append the trailing slash for any directories that are resolved. Needs to be more tightly coupled to the dir_walk optimized cache. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91480 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/request.c b/server/request.c index 61a6f040d4..cf55c476a2 100644 --- a/server/request.c +++ b/server/request.c @@ -809,7 +809,8 @@ minimerge2: if ((r->finfo.valid & APR_FINFO_NAME) && strcmp(seg_name, r->finfo.name)) { /* TODO: provide users an option that an internal/external - * redirect is required here? + * redirect is required here? We need to walk the URI and + * filename in tandem to properly correlate these. */ strcpy(seg_name, r->finfo.name); } @@ -1376,28 +1377,22 @@ AP_DECLARE(request_rec *) ap_sub_req_lookup_dirent(const apr_finfo_t *dirent, */ ap_run_create_request(rnew); - fdir = ap_make_dirstr_parent(rnew->pool, r->filename); - - /* - * Special case: we are looking at a relative lookup in the same directory. - * That means we won't have to redo directory_walk, and we may - * not even have to redo access checks. + /* Special case: we are looking at a relative lookup in the same directory. + * This is 100% safe, since dirent->name just came from the filesystem. */ - udir = ap_make_dirstr_parent(rnew->pool, r->uri); - - /* This is 100% safe, since dirent->name just came from the filesystem */ rnew->uri = ap_make_full_path(rnew->pool, udir, dirent->name); + fdir = ap_make_dirstr_parent(rnew->pool, r->filename); rnew->filename = ap_make_full_path(rnew->pool, fdir, dirent->name); if (r->canonical_filename == r->filename) rnew->canonical_filename = rnew->filename; - ap_parse_uri(rnew, rnew->uri); /* fill in parsed_uri values */ - - /* Preserve the apr_stat results, and perhaps we also tag that - * symlinks were tested and/or found for r->filename. + /* XXX This is now less relevant; we will do a full location walk + * these days for this case. Preserve the apr_stat results, and + * perhaps we also tag that symlinks were tested and/or found for + * r->filename. */ - rnew->per_dir_config = r->per_dir_config; + rnew->per_dir_config = r->per_dir_default; if ((dirent->valid & APR_FINFO_MIN) != APR_FINFO_MIN) { /* @@ -1424,6 +1419,29 @@ AP_DECLARE(request_rec *) ap_sub_req_lookup_dirent(const apr_finfo_t *dirent, memcpy (&rnew->finfo, dirent, sizeof(apr_finfo_t)); } + if (rnew->finfo.filetype == APR_LNK) { + /* + * Resolve this symlink. We should tie this back to dir_walk's cache + */ + if (!(res = resolve_symlink(rnew->filename, &rnew->finfo, + ap_allow_options(rnew), rnew->pool)) { + rnew->status = res; + return rnew; + } + } + + if (rnew->finfo.filetype == APR_DIR) { + /* ### Would be real nice if apr_make_full_path overallocated + * the buffer by one character instead of a complete copy. + */ + rnew->filename = apr_pstrcat(rnew->pool, rnew->filename, "/", NULL); + rnew->uri = ap_make_full_path(rnew->pool, rnew->uri, "/", NULL); + if (r->canonical_filename == r->filename) + r->canonical_filename = r->filename; + } + + ap_parse_uri(rnew, rnew->uri); /* fill in parsed_uri values */ + if ((res = ap_process_request_internal(rnew))) { rnew->status = res; }