summaryrefslogtreecommitdiff
path: root/src/tipideed/tipideed.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-12-15 10:35:41 +0000
committerLaurent Bercot <ska@appnovation.com>2023-12-15 10:35:41 +0000
commitd2959364ef8d6bc948474a8facf497788b4e768b (patch)
treee1459c1c94e9b7556c21c0b43d7144a162601b0a /src/tipideed/tipideed.c
parent66844097454a8f2b4eddec64d4f276602c4cdd3a (diff)
downloadtipidee-d2959364ef8d6bc948474a8facf497788b4e768b.tar.xz
Prepare for 0.0.3.0; add XXX_no_translate
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/tipideed/tipideed.c')
-rw-r--r--src/tipideed/tipideed.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/tipideed/tipideed.c b/src/tipideed/tipideed.c
index 0f5d44c..8323db1 100644
--- a/src/tipideed/tipideed.c
+++ b/src/tipideed/tipideed.c
@@ -195,13 +195,16 @@ static inline unsigned int indexify (tipidee_rql const *rql, char const *docroot
static inline void get_resattr (tipidee_rql const *rql, char const *docroot, char const *res, tipidee_resattr *ra)
{
- size_t pos = g.sa.len ;
- if (sarealpath(&g.sa, res) == -1 || !stralloc_0(&g.sa)) die500sys(rql, 111, docroot, "realpath ", res) ;
- if (strncmp(g.sa.s + pos, g.sa.s, g.cwdlen) || g.sa.s[pos + g.cwdlen] != '/')
- die500x(rql, 102, docroot, "resource ", res, " points outside of the server's root") ;
- if (!tipidee_conf_get_resattr(&g.conf, g.sa.s + pos + g.cwdlen + 1, ra))
- die500sys(rql, 102, docroot, "look up resource attributes for ", g.sa.s + pos + g.cwdlen + 1) ;
- g.sa.len = pos ;
+ size_t pos = translate_path(res) ;
+ if (!pos)
+ {
+ if (errno == EPERM)
+ die500x(rql, 102, docroot, "resource ", res, " points outside of the server's root") ;
+ else
+ die500sys(rql, 111, docroot, "path_canonicalize ", res) ;
+ }
+ if (!tipidee_conf_get_resattr(&g.conf, g.sa.s + pos, ra))
+ die500sys(rql, 102, docroot, "look up resource attributes for ", g.sa.s + pos) ;
}
static inline void force_redirect (tipidee_rql const *rql, char const *fn)
@@ -353,6 +356,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
g.maxcgibody = get_uint32("G:max_cgi_body_length") ;
g.logv = get_uint32("G:logv") ;
g.xiscgi = !!get_uint32("G:executable_means_cgi") ;
+ g.flagnoxlate = !!get_uint32("G:XXX_no_translate") ;
n = tipidee_conf_get_argv(&g.conf, "G:index-file", g.indexnames, 16, &g.indexlen) ;
if (!n) strerr_dief3x(102, "bad", " config value for ", "G:index_file") ;
g.indexn = n-1 ;