]> granicus.if.org Git - apache/commitdiff
Fix resolve_symlink to save the original symlink name if known.
authorJustin Erenkrantz <jerenkrantz@apache.org>
Thu, 7 Feb 2002 06:29:57 +0000 (06:29 +0000)
committerJustin Erenkrantz <jerenkrantz@apache.org>
Thu, 7 Feb 2002 06:29:57 +0000 (06:29 +0000)
We would previously receive APR_INCOMPLETE on symlinks if wanted has
FINFO_NAME set because it isn't supported via apr_stat().  Furthermore, we
don't care what the real name is anyway (even if it apr_stat returned
.name) - we want to call it by the name the symlink says it is.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93328 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
server/request.c

diff --git a/CHANGES b/CHANGES
index 5afc480eb13975820adae2942669756617bd0de1..4209926a62941ef7ba863f0e154dc4071e37f4f7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,8 @@
 Changes with Apache 2.0.32-dev
 
+  *) Fix resolve_symlink to save the original symlink name if known.
+     [Justin Erenkrantz]
+
   *) Be a bit more sane with regard to CanonicalNames.  If the user has
      specified they want to use the CanonicalName, but they have not
      configured a port with the ServerName, then use the same port that 
index f4cb79ca92145438b6bdccff47a9db57124f2939..030056148f51ffb8e6193d3248446c579ed159d5 100644 (file)
@@ -396,18 +396,27 @@ static int resolve_symlink(char *d, apr_finfo_t *lfi, int opts, apr_pool_t *p)
 {
     apr_finfo_t fi;
     int res;
+    const char *savename;
 
     if (!(opts & (OPT_SYM_OWNER | OPT_SYM_LINKS))) {
         return HTTP_FORBIDDEN;
     }
 
+    /* Save the name from the valid bits. */
+    savename = (lfi->valid & APR_FINFO_NAME) ? lfi->name : NULL;
+
     if (opts & OPT_SYM_LINKS) {
-        if ((res = apr_stat(&fi, d, lfi->valid, p)) != APR_SUCCESS) {
+        if ((res = apr_stat(&fi, d, lfi->valid & ~(APR_FINFO_NAME), 
+                            p)) != APR_SUCCESS) {
             return HTTP_FORBIDDEN;
         }
 
         /* Give back the target */
         memcpy(lfi, &fi, sizeof(fi));
+        if (savename) {
+            lfi->name = savename;
+            lfi->valid |= APR_FINFO_NAME;
+        }
         return OK;
     }
 
@@ -422,7 +431,7 @@ static int resolve_symlink(char *d, apr_finfo_t *lfi, int opts, apr_pool_t *p)
         }
     }
 
-    if ((res = apr_stat(&fi, d, lfi->valid, p)) != APR_SUCCESS) {
+    if ((res = apr_stat(&fi, d, lfi->valid & ~(APR_FINFO_NAME), p)) != APR_SUCCESS) {
         return HTTP_FORBIDDEN;
     }
 
@@ -432,6 +441,10 @@ static int resolve_symlink(char *d, apr_finfo_t *lfi, int opts, apr_pool_t *p)
 
     /* Give back the target */
     memcpy(lfi, &fi, sizeof(fi));
+    if (savename) {
+        lfi->name = savename;
+        lfi->valid |= APR_FINFO_NAME;
+    }
     return OK;
 }