summaryrefslogtreecommitdiffstats
path: root/usr.sbin/nginx/src/core/ngx_cycle.c
diff options
context:
space:
mode:
authorrobert <robert@openbsd.org>2011-10-11 22:53:00 +0000
committerrobert <robert@openbsd.org>2011-10-11 22:53:00 +0000
commitc730dea46d0ea6934895cf88c5445d63f180838c (patch)
tree1b1204dcea98747b9ea3fe1fff7fb561bc87da41 /usr.sbin/nginx/src/core/ngx_cycle.c
parentUpdate Digest module to 1.17 (security fix). (diff)
downloadwireguard-openbsd-c730dea46d0ea6934895cf88c5445d63f180838c.tar.xz
wireguard-openbsd-c730dea46d0ea6934895cf88c5445d63f180838c.zip
Add a flag for nginx (-u) to be able to disable chroot and use a better
method for modifying the document root if chrooted, so currently this allows the user to run the same configuration file with a chrooted and an non-chrooted setup.
Diffstat (limited to 'usr.sbin/nginx/src/core/ngx_cycle.c')
-rw-r--r--usr.sbin/nginx/src/core/ngx_cycle.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/usr.sbin/nginx/src/core/ngx_cycle.c b/usr.sbin/nginx/src/core/ngx_cycle.c
index a035fcdc47b..59b70841eb5 100644
--- a/usr.sbin/nginx/src/core/ngx_cycle.c
+++ b/usr.sbin/nginx/src/core/ngx_cycle.c
@@ -1115,6 +1115,7 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user)
ngx_uint_t i;
ngx_list_part_t *part;
ngx_open_file_t *file;
+ char *buf;
part = &cycle->open_files.part;
file = part->elts;
@@ -1136,12 +1137,15 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user)
len = file[i].pos - file[i].buffer;
- if ((ngx_process == NGX_PROCESS_WORKER) && file[i].name.data[0] == '/') {
- ngx_cpystrn(file[i].name.data, file[i].name.data + strlen(NGX_PREFIX),
+ if ((ngx_process == NGX_PROCESS_WORKER) && ngx_chrooted && file[i].name.data[0] == '/') {
+ buf = malloc(file[i].name.len);
+ ngx_cpystrn(buf, file[i].name.data + strlen(NGX_PREFIX),
file[i].name.len);
- while (file[i].name.data[0] == '/') {
- file[i].name.data++;
+ while (buf[0] == '/') {
+ buf++;
}
+ ngx_str_set(&file[i].name, buf);
+ free(buf);
}
if (file[i].buffer && len != 0) {