Mercurial > hg > nginx-vendor-1-0
comparison src/core/nginx.c @ 4:4b2dafa26fe2 NGINX_0_1_2
nginx 0.1.2
*) Feature: the --user=USER, --group=GROUP, and --with-ld-opt=OPTIONS
options in configure.
*) Feature: the server_name directive supports *.domain.tld.
*) Bugfix: the portability improvements.
*) Bugfix: if configuration file was set in command line, the
reconfiguration was impossible; bug appeared in 0.1.1.
*) Bugfix: proxy module may get caught in an endless loop when sendfile
is not used.
*) Bugfix: with sendfile the response was not recoded according to the
charset module directives; bug appeared in 0.1.1.
*) Bugfix: very seldom bug in the kqueue processing.
*) Bugfix: the gzip module compressed the proxied responses that was
already compressed.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Thu, 21 Oct 2004 00:00:00 +0400 |
parents | cc9f381affaa |
children | 46833bd150cb |
comparison
equal
deleted
inserted
replaced
3:8beaf7b3241f | 4:4b2dafa26fe2 |
---|---|
102 ngx_int_t i; | 102 ngx_int_t i; |
103 ngx_log_t *log; | 103 ngx_log_t *log; |
104 ngx_cycle_t *cycle, init_cycle; | 104 ngx_cycle_t *cycle, init_cycle; |
105 ngx_core_conf_t *ccf; | 105 ngx_core_conf_t *ccf; |
106 | 106 |
107 #if defined __FreeBSD__ | 107 #if (NGX_FREEBSD) |
108 ngx_debug_init(); | 108 ngx_debug_init(); |
109 #endif | 109 #endif |
110 | 110 |
111 /* TODO */ ngx_max_sockets = -1; | 111 /* TODO */ ngx_max_sockets = -1; |
112 | 112 |
113 ngx_time_init(); | 113 ngx_time_init(); |
114 | 114 |
115 #if (HAVE_PCRE) | 115 #if (NGX_PCRE) |
116 ngx_regex_init(); | 116 ngx_regex_init(); |
117 #endif | 117 #endif |
118 | 118 |
119 ngx_pid = ngx_getpid(); | 119 ngx_pid = ngx_getpid(); |
120 | 120 |
134 | 134 |
135 if (!(init_cycle.pool = ngx_create_pool(1024, log))) { | 135 if (!(init_cycle.pool = ngx_create_pool(1024, log))) { |
136 return 1; | 136 return 1; |
137 } | 137 } |
138 | 138 |
139 if (ngx_getopt(&init_cycle, argc, argv) == NGX_ERROR) { | |
140 return 1; | |
141 } | |
142 | |
143 if (ngx_save_argv(&init_cycle, argc, argv) == NGX_ERROR) { | 139 if (ngx_save_argv(&init_cycle, argc, argv) == NGX_ERROR) { |
140 return 1; | |
141 } | |
142 | |
143 if (ngx_getopt(&init_cycle, argc, ngx_argv) == NGX_ERROR) { | |
144 return 1; | 144 return 1; |
145 } | 145 } |
146 | 146 |
147 if (ngx_test_config) { | 147 if (ngx_test_config) { |
148 log->log_level = NGX_LOG_INFO; | 148 log->log_level = NGX_LOG_INFO; |
173 } | 173 } |
174 | 174 |
175 if (ngx_test_config) { | 175 if (ngx_test_config) { |
176 ngx_log_error(NGX_LOG_INFO, log, 0, | 176 ngx_log_error(NGX_LOG_INFO, log, 0, |
177 "the configuration file %s was tested successfully", | 177 "the configuration file %s was tested successfully", |
178 init_cycle.conf_file.data); | 178 cycle->conf_file.data); |
179 return 0; | 179 return 0; |
180 } | 180 } |
181 | 181 |
182 ngx_os_status(cycle->log); | 182 ngx_os_status(cycle->log); |
183 | 183 |
385 | 385 |
386 ngx_os_argv = (char **) argv; | 386 ngx_os_argv = (char **) argv; |
387 | 387 |
388 ngx_argc = argc; | 388 ngx_argc = argc; |
389 | 389 |
390 #if __FreeBSD__ | 390 #if (NGX_FREEBSD) |
391 | 391 |
392 ngx_argv = (char **) argv; | 392 ngx_argv = (char **) argv; |
393 | 393 |
394 #else | 394 #else |
395 | 395 |
460 ngx_conf_init_size_value(ccf->thread_stack_size, 2 * 1024 * 1024); | 460 ngx_conf_init_size_value(ccf->thread_stack_size, 2 * 1024 * 1024); |
461 #endif | 461 #endif |
462 | 462 |
463 #if !(WIN32) | 463 #if !(WIN32) |
464 | 464 |
465 #if 0 | |
466 if (ccf->user == (uid_t) NGX_CONF_UNSET) { | 465 if (ccf->user == (uid_t) NGX_CONF_UNSET) { |
467 | 466 |
468 pwd = getpwnam("nobody"); | 467 pwd = getpwnam(NGX_USER); |
469 if (pwd == NULL) { | 468 if (pwd == NULL) { |
470 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | 469 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
471 "getpwnam(\"nobody\") failed"); | 470 "getpwnam(\"" NGX_USER "\") failed"); |
472 return NGX_CONF_ERROR; | 471 return NGX_CONF_ERROR; |
473 } | 472 } |
474 | 473 |
475 ccf->user = pwd->pw_uid; | 474 ccf->user = pwd->pw_uid; |
476 | 475 |
477 grp = getgrnam("nobody"); | 476 grp = getgrnam(NGX_GROUP); |
478 if (grp == NULL) { | 477 if (grp == NULL) { |
479 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | 478 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
480 "getgrnam(\"nobody\") failed"); | 479 "getgrnam(\"" NGX_GROUP "\") failed"); |
481 return NGX_CONF_ERROR; | 480 return NGX_CONF_ERROR; |
482 } | 481 } |
483 | 482 |
484 ccf->group = grp->gr_gid; | 483 ccf->group = grp->gr_gid; |
485 } | 484 } |
486 #endif | |
487 | 485 |
488 if (ccf->pid.len == 0) { | 486 if (ccf->pid.len == 0) { |
489 ccf->pid.len = sizeof(NGX_PID_PATH) - 1; | 487 ccf->pid.len = sizeof(NGX_PID_PATH) - 1; |
490 ccf->pid.data = (u_char *) NGX_PID_PATH; | 488 ccf->pid.data = (u_char *) NGX_PID_PATH; |
491 } | 489 } |
520 | 518 |
521 #else | 519 #else |
522 | 520 |
523 ngx_core_conf_t *ccf = conf; | 521 ngx_core_conf_t *ccf = conf; |
524 | 522 |
523 char *group; | |
525 struct passwd *pwd; | 524 struct passwd *pwd; |
526 struct group *grp; | 525 struct group *grp; |
527 ngx_str_t *value; | 526 ngx_str_t *value; |
528 | 527 |
529 if (ccf->user != (uid_t) NGX_CONF_UNSET) { | 528 if (ccf->user != (uid_t) NGX_CONF_UNSET) { |
530 return "is duplicate"; | 529 return "is duplicate"; |
530 } | |
531 | |
532 if (geteuid() != 0) { | |
533 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | |
534 "the \"user\" directive makes sense only " | |
535 "if the master process runs " | |
536 "with super-user privileges, ignored"); | |
537 return NGX_CONF_OK; | |
531 } | 538 } |
532 | 539 |
533 value = (ngx_str_t *) cf->args->elts; | 540 value = (ngx_str_t *) cf->args->elts; |
534 | 541 |
535 pwd = getpwnam((const char *) value[1].data); | 542 pwd = getpwnam((const char *) value[1].data); |
539 return NGX_CONF_ERROR; | 546 return NGX_CONF_ERROR; |
540 } | 547 } |
541 | 548 |
542 ccf->user = pwd->pw_uid; | 549 ccf->user = pwd->pw_uid; |
543 | 550 |
544 if (cf->args->nelts == 2) { | 551 group = (char *) ((cf->args->nelts == 2) ? value[1].data : value[2].data); |
545 return NGX_CONF_OK; | 552 |
546 } | 553 grp = getgrnam(group); |
547 | |
548 grp = getgrnam((const char *) value[2].data); | |
549 if (grp == NULL) { | 554 if (grp == NULL) { |
550 ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno, | 555 ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno, |
551 "getgrnam(\"%s\") failed", value[2].data); | 556 "getgrnam(\"%s\") failed", group); |
552 return NGX_CONF_ERROR; | 557 return NGX_CONF_ERROR; |
553 } | 558 } |
554 | 559 |
555 ccf->group = grp->gr_gid; | 560 ccf->group = grp->gr_gid; |
556 | 561 |