diff options
| author | 2014-05-10 17:48:09 +0000 | |
|---|---|---|
| committer | 2014-05-10 17:48:09 +0000 | |
| commit | a4cfffda63bee266a0f6ef2b2407b16a33896ff8 (patch) | |
| tree | b7e847e5691bc2ab169f873b40e095cfbcc17cd9 /usr.sbin/nginx/src/core/ngx_string.c | |
| parent | Fix v6_defroute() for automatic installation. (diff) | |
| download | wireguard-openbsd-a4cfffda63bee266a0f6ef2b2407b16a33896ff8.tar.xz wireguard-openbsd-a4cfffda63bee266a0f6ef2b2407b16a33896ff8.zip | |
Allow nginx to chroot to a directory other than /var/www
ok henning@
Diffstat (limited to 'usr.sbin/nginx/src/core/ngx_string.c')
| -rw-r--r-- | usr.sbin/nginx/src/core/ngx_string.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/usr.sbin/nginx/src/core/ngx_string.c b/usr.sbin/nginx/src/core/ngx_string.c index a42ee861f03..1d1989da24d 100644 --- a/usr.sbin/nginx/src/core/ngx_string.c +++ b/usr.sbin/nginx/src/core/ngx_string.c @@ -1842,10 +1842,22 @@ ngx_memcpy(void *dst, const void *src, size_t n) void ngx_strip_chroot(ngx_str_t *path) { - if (!ngx_strncmp(path->data, NGX_PREFIX, strlen(NGX_PREFIX))) { + int plen; + u_char *prefix; + + if (ngx_prefix) + prefix = ngx_prefix; + else + prefix = NGX_PREFIX; + + if (prefix[strlen(prefix) - 1] == '/') + plen = strlen(prefix) - 1; + else + plen = strlen(prefix); + + if (!ngx_strncmp(path->data, prefix, strlen(prefix))) { char *x, *buf = malloc(path->len); - x = ngx_cpystrn(buf, path->data + strlen(NGX_PREFIX) - 1, - path->len); + x = ngx_cpystrn(buf, path->data + plen, path->len); path->len = (x - buf); path->data = buf; } |
