From c730dea46d0ea6934895cf88c5445d63f180838c Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 11 Oct 2011 22:53:00 +0000 Subject: 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. --- usr.sbin/nginx/src/core/ngx_cycle.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'usr.sbin/nginx/src/core/ngx_cycle.c') 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) { -- cgit v1.2.3-59-g8ed1b