From f1461c4a1c807cba80453844eecbc64beb73412a Mon Sep 17 00:00:00 2001 From: Justin Erenkrantz Date: Thu, 7 Feb 2002 06:29:57 +0000 Subject: [PATCH] Fix resolve_symlink to save the original symlink name if known. 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 | 3 +++ server/request.c | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 5afc480eb1..4209926a62 100644 --- 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 diff --git a/server/request.c b/server/request.c index f4cb79ca92..030056148f 100644 --- a/server/request.c +++ b/server/request.c @@ -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; } -- 2.40.0