comparison src/core/nginx.c @ 440:f390d1775430

nginx-0.1.0-2004-09-27-20:03:21 import
author Igor Sysoev <igor@sysoev.ru>
date Mon, 27 Sep 2004 16:03:21 +0000
parents 8ac40cae79f0
children da8c5707af39
comparison
equal deleted inserted replaced
439:4fe393d82f44 440:f390d1775430
126 126
127 ngx_memzero(&ctx, sizeof(ngx_master_ctx_t)); 127 ngx_memzero(&ctx, sizeof(ngx_master_ctx_t));
128 ctx.argc = argc; 128 ctx.argc = argc;
129 ctx.argv = argv; 129 ctx.argv = argv;
130 130
131 if (ngx_os_init(log) == NGX_ERROR) {
132 return 1;
133 }
134
135 if (!(init_cycle.pool = ngx_create_pool(1024, log))) {
136 return 1;
137 }
138
131 if (ngx_getopt(&ctx, &init_cycle) == NGX_ERROR) { 139 if (ngx_getopt(&ctx, &init_cycle) == NGX_ERROR) {
132 return 1;
133 }
134
135 if (ngx_os_init(log) == NGX_ERROR) {
136 return 1;
137 }
138
139 if (!(init_cycle.pool = ngx_create_pool(1024, log))) {
140 return 1; 140 return 1;
141 } 141 }
142 142
143 if (ngx_add_inherited_sockets(&init_cycle) == NGX_ERROR) { 143 if (ngx_add_inherited_sockets(&init_cycle) == NGX_ERROR) {
144 return 1; 144 return 1;
334 } 334 }
335 335
336 if (cycle->conf_file.data == NULL) { 336 if (cycle->conf_file.data == NULL) {
337 cycle->conf_file.len = sizeof(NGX_CONF_PATH) - 1; 337 cycle->conf_file.len = sizeof(NGX_CONF_PATH) - 1;
338 cycle->conf_file.data = (u_char *) NGX_CONF_PATH; 338 cycle->conf_file.data = (u_char *) NGX_CONF_PATH;
339 }
340
341 if (ngx_conf_full_name(cycle, &cycle->conf_file) == NGX_ERROR) {
342 return NGX_ERROR;
339 } 343 }
340 344
341 return NGX_OK; 345 return NGX_OK;
342 } 346 }
343 347
370 374
371 static char *ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf) 375 static char *ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
372 { 376 {
373 ngx_core_conf_t *ccf = conf; 377 ngx_core_conf_t *ccf = conf;
374 378
379 #if !(WIN32)
380 struct passwd *pwd;
381 struct group *grp;
382 #endif
383
375 ngx_conf_init_value(ccf->daemon, 1); 384 ngx_conf_init_value(ccf->daemon, 1);
376 ngx_conf_init_value(ccf->master, 1); 385 ngx_conf_init_value(ccf->master, 1);
377 ngx_conf_init_value(ccf->worker_processes, 1); 386 ngx_conf_init_value(ccf->worker_processes, 1);
378 387
379 #if (NGX_THREADS) 388 #if (NGX_THREADS)
382 ngx_conf_init_size_value(ccf->thread_stack_size, 2 * 1024 * 1024); 391 ngx_conf_init_size_value(ccf->thread_stack_size, 2 * 1024 * 1024);
383 #endif 392 #endif
384 393
385 #if !(WIN32) 394 #if !(WIN32)
386 395
387 /* TODO: default "nobody" user */ 396 if (ccf->user == (uid_t) NGX_CONF_UNSET) {
397
398 pwd = getpwnam("nobody");
399 if (pwd == NULL) {
400 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
401 "getpwnam(\"nobody\") failed");
402 return NGX_CONF_ERROR;
403 }
404
405 ccf->user = pwd->pw_uid;
406
407 grp = getgrnam("nobody");
408 if (grp == NULL) {
409 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
410 "getgrnam(\"nobody\") failed");
411 return NGX_CONF_ERROR;
412 }
413
414 ccf->group = grp->gr_gid;
415 }
388 416
389 if (ccf->pid.len == 0) { 417 if (ccf->pid.len == 0) {
390 ccf->pid.len = sizeof(NGX_PID_PATH) - 1; 418 ccf->pid.len = sizeof(NGX_PID_PATH) - 1;
391 ccf->pid.data = NGX_PID_PATH; 419 ccf->pid.data = NGX_PID_PATH;
392 ccf->newpid.len = sizeof(NGX_PID_PATH NGX_NEWPID_EXT) - 1; 420 }
393 ccf->newpid.data = NGX_PID_PATH NGX_NEWPID_EXT; 421
394 422 if (ngx_conf_full_name(cycle, &ccf->pid) == NGX_ERROR) {
395 } else { 423 return NGX_CONF_ERROR;
396 ccf->newpid.len = ccf->pid.len + sizeof(NGX_NEWPID_EXT); 424 }
397 425
398 if (!(ccf->newpid.data = ngx_palloc(cycle->pool, ccf->newpid.len))) { 426 ccf->newpid.len = ccf->pid.len + sizeof(NGX_NEWPID_EXT);
399 return NGX_CONF_ERROR; 427
400 } 428 if (!(ccf->newpid.data = ngx_palloc(cycle->pool, ccf->newpid.len))) {
401 429 return NGX_CONF_ERROR;
402 ngx_memcpy(ngx_cpymem(ccf->newpid.data, ccf->pid.data, ccf->pid.len), 430 }
403 NGX_NEWPID_EXT, sizeof(NGX_NEWPID_EXT)); 431
404 } 432 ngx_memcpy(ngx_cpymem(ccf->newpid.data, ccf->pid.data, ccf->pid.len),
433 NGX_NEWPID_EXT, sizeof(NGX_NEWPID_EXT));
434
405 #endif 435 #endif
406 436
407 return NGX_CONF_OK; 437 return NGX_CONF_OK;
408 } 438 }
409 439