diff options
author | Valentin Bartenev <vbart@nginx.com> | 2017-07-14 16:08:21 +0300 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2017-07-14 16:08:21 +0300 |
commit | a937047cb8d3255cc451bccf9e8b7cc0671ef9c2 (patch) | |
tree | 43b651f3cb9344922b1225f5be6624558f279167 /src/nxt_master_process.c | |
parent | daaa216e2fe8999b62b057802b35e2ac92ed8cc2 (diff) | |
download | unit-a937047cb8d3255cc451bccf9e8b7cc0671ef9c2.tar.gz unit-a937047cb8d3255cc451bccf9e8b7cc0671ef9c2.tar.bz2 |
Null-terminated user and group.
Diffstat (limited to 'src/nxt_master_process.c')
-rw-r--r-- | src/nxt_master_process.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/nxt_master_process.c b/src/nxt_master_process.c index c5699572..77e720cf 100644 --- a/src/nxt_master_process.c +++ b/src/nxt_master_process.c @@ -306,25 +306,36 @@ static nxt_int_t nxt_master_start_worker_process(nxt_task_t *task, nxt_runtime_t *rt, nxt_common_app_conf_t *app_conf, uint32_t stream) { + char *user, *group; nxt_process_init_t *init; - init = nxt_malloc(sizeof(nxt_process_init_t) + - sizeof(nxt_user_cred_t)); + init = nxt_malloc(sizeof(nxt_process_init_t) + + sizeof(nxt_user_cred_t) + + app_conf->user.length + 1 + + app_conf->group.length + 1); if (nxt_slow_path(init == NULL)) { return NXT_ERROR; } - init->user_cred = (nxt_user_cred_t *) (init + 1); + user = nxt_pointer_to(init->user_cred, sizeof(nxt_user_cred_t)); - init->start = nxt_app_start; - init->name = "worker process"; + nxt_memcpy(user, app_conf->user.start, app_conf->user.length); + user[app_conf->user.length] = '\0'; + + group = nxt_pointer_to(user, app_conf->user.length + 1); + + nxt_memcpy(group, app_conf->group.start, app_conf->group.length); + group[app_conf->group.length] = '\0'; - init->user_cred->user = (char *) app_conf->user.start; - if (nxt_user_cred_get(task, init->user_cred, - (char *) app_conf->group.start) != NXT_OK) { + init->user_cred = (nxt_user_cred_t *) (init + 1); + + init->user_cred->user = user; + if (nxt_user_cred_get(task, init->user_cred, group) != NXT_OK) { return NXT_ERROR; } + init->start = nxt_app_start; + init->name = "worker process"; init->port_handlers = nxt_app_process_port_handlers; init->signals = nxt_worker_process_signals; init->type = NXT_PROCESS_WORKER; |