diff options
| author | 2012-02-22 11:52:39 +0000 | |
|---|---|---|
| committer | 2012-02-22 11:52:39 +0000 | |
| commit | bbd23471af66f83df3aed5640df385b3df910bdd (patch) | |
| tree | 8a33eca0213c53dfd66b39bed2cd670404f29dfd /usr.sbin/nginx/src | |
| parent | Mention and explain the /var/run/rc.d/ directory. (diff) | |
| download | wireguard-openbsd-bbd23471af66f83df3aed5640df385b3df910bdd.tar.xz wireguard-openbsd-bbd23471af66f83df3aed5640df385b3df910bdd.zip | |
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/src')
| -rw-r--r-- | usr.sbin/nginx/src/core/ngx_file.c | 28 |
1 files changed, 20 insertions, 8 deletions
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; } } |
