Skip to content

Commit

Permalink
Core: ngx_conf_set_access_slot() user access (ticket #1096).
Browse files Browse the repository at this point in the history
Previously, user access bits were always set to "rw" unconditionally,
even with "user:r" explicitly specified.  With this change we only add
default user access bits (0600) if they weren't set explicitly.
  • Loading branch information
mdounin committed Oct 7, 2016
1 parent 5289283 commit 4c4fdc4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core/ngx_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ ngx_conf_set_access_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)

u_char *p;
ngx_str_t *value;
ngx_uint_t i, right, shift, *access;
ngx_uint_t i, right, shift, *access, user;

access = (ngx_uint_t *) (confp + cmd->offset);

Expand All @@ -451,7 +451,8 @@ ngx_conf_set_access_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)

value = cf->args->elts;

*access = 0600;
*access = 0;
user = 0600;

for (i = 1; i < cf->args->nelts; i++) {

Expand All @@ -460,6 +461,7 @@ ngx_conf_set_access_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
if (ngx_strncmp(p, "user:", sizeof("user:") - 1) == 0) {
shift = 6;
p += sizeof("user:") - 1;
user = 0;

} else if (ngx_strncmp(p, "group:", sizeof("group:") - 1) == 0) {
shift = 3;
Expand All @@ -486,6 +488,8 @@ ngx_conf_set_access_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
*access |= right << shift;
}

*access |= user;

return NGX_CONF_OK;

invalid:
Expand Down

0 comments on commit 4c4fdc4

Please sign in to comment.