diff options
author | Robert Nagy <robert@cvs.openbsd.org> | 2012-02-22 11:52:40 +0000 |
---|---|---|
committer | Robert Nagy <robert@cvs.openbsd.org> | 2012-02-22 11:52:40 +0000 |
commit | 7da07a100aed584e772f6fa26e54d85b4a55cda0 (patch) | |
tree | 453d9972efda890947e18669d11c171d4808d9fa /usr.sbin/nginx | |
parent | 652c5f72b552414d00a6c491a8cfdaaca57636e6 (diff) |
create the tmp dirs nginx needs for doing proxying inside the chroot
because these get created before the actual chroot happens
Diffstat (limited to 'usr.sbin/nginx')
-rw-r--r-- | usr.sbin/nginx/README.OpenBSD | 1 | ||||
-rw-r--r-- | usr.sbin/nginx/src/core/ngx_file.c | 28 |
2 files changed, 21 insertions, 8 deletions
diff --git a/usr.sbin/nginx/README.OpenBSD b/usr.sbin/nginx/README.OpenBSD index 297db6e9730..e334eaac31d 100644 --- a/usr.sbin/nginx/README.OpenBSD +++ b/usr.sbin/nginx/README.OpenBSD @@ -3,6 +3,7 @@ Modified files by OpenBSD: - auto/sources - src/core/nginx.c - src/core/ngx_cycle.c +- src/core/ngx_file.c - src/os/unix/ngx_process_cycle.c - src/os/unix/ngx_process_cycle.h - src/pcre/pcre_compile.c diff --git a/usr.sbin/nginx/src/core/ngx_file.c b/usr.sbin/nginx/src/core/ngx_file.c index ce3a0a2827f..38d1c6a2f2b 100644 --- a/usr.sbin/nginx/src/core/ngx_file.c +++ b/usr.sbin/nginx/src/core/ngx_file.c @@ -474,16 +474,28 @@ ngx_create_pathes(ngx_cycle_t *cycle, ngx_uid_t user) ngx_err_t err; ngx_uint_t i; ngx_path_t **path; + char *buf; path = cycle->pathes.elts; for (i = 0; i < cycle->pathes.nelts; i++) { - if (ngx_create_dir(path[i]->name.data, 0700) == NGX_FILE_ERROR) { + if (ngx_chrooted) { + if (chdir(NGX_PREFIX) == -1) { + ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, + "chdir(\"%s\") failed", NGX_PREFIX); + return NGX_ERROR; + } + buf = path[i]->name.data + 1; + } else { + buf = path[i]->name.data; + } + + if (ngx_create_dir(buf, 0700) == NGX_FILE_ERROR) { err = ngx_errno; if (err != NGX_EEXIST) { ngx_log_error(NGX_LOG_EMERG, cycle->log, err, ngx_create_dir_n " \"%s\" failed", - path[i]->name.data); + buf); return NGX_ERROR; } } @@ -496,19 +508,19 @@ ngx_create_pathes(ngx_cycle_t *cycle, ngx_uid_t user) { ngx_file_info_t fi; - if (ngx_file_info((const char *) path[i]->name.data, &fi) + if (ngx_file_info((const char *) buf, &fi) == NGX_FILE_ERROR) { ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, - ngx_file_info_n " \"%s\" failed", path[i]->name.data); + ngx_file_info_n " \"%s\" failed", buf); return NGX_ERROR; } if (fi.st_uid != user) { - if (chown((const char *) path[i]->name.data, user, -1) == -1) { + if (chown((const char *) buf, user, -1) == -1) { ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, "chown(\"%s\", %d) failed", - path[i]->name.data, user); + buf, user); return NGX_ERROR; } } @@ -518,9 +530,9 @@ ngx_create_pathes(ngx_cycle_t *cycle, ngx_uid_t user) { fi.st_mode |= (S_IRUSR|S_IWUSR|S_IXUSR); - if (chmod((const char *) path[i]->name.data, fi.st_mode) == -1) { + if (chmod((const char *) buf, fi.st_mode) == -1) { ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, - "chmod() \"%s\" failed", path[i]->name.data); + "chmod() \"%s\" failed", buf); return NGX_ERROR; } } |