annotate src/os/unix/ngx_user.c @ 58:b55cbf18157e NGINX_0_1_29

nginx 0.1.29 *) Feature: the ngx_http_ssi_module supports "include virtual" command. *) Feature: the ngx_http_ssi_module supports the condition command like 'if expr="$NAME"' and "else" and "endif" commands. Only one nested level is supported. *) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and DATE_GMT variables and "config timefmt" command. *) Feature: the "ssi_ignore_recycled_buffers" directive. *) Bugfix: the "echo" command did not show the default value for the empty QUERY_STRING variable. *) Change: the ngx_http_proxy_module was rewritten. *) Feature: the "proxy_redirect", "proxy_pass_request_headers", "proxy_pass_request_body", and "proxy_method" directives. *) Feature: the "proxy_set_header" directive. The "proxy_x_var" was canceled and must be replaced with the proxy_set_header directive. *) Change: the "proxy_preserve_host" is canceled and must be replaced with the "proxy_set_header Host $host" and the "proxy_redirect off" directives, the "proxy_set_header Host $host:$proxy_port" directive and the appropriate proxy_redirect directives. *) Change: the "proxy_set_x_real_ip" is canceled and must be replaced with the "proxy_set_header X-Real-IP $remote_addr" directive. *) Change: the "proxy_add_x_forwarded_for" is canceled and must be replaced with the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for" directive. *) Change: the "proxy_set_x_url" is canceled and must be replaced with the "proxy_set_header X-URL http://$host:$server_port$request_uri" directive. *) Feature: the "fastcgi_param" directive. *) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params" directive are canceled and must be replaced with the fastcgi_param directives. *) Feature: the "index" directive can use the variables. *) Feature: the "index" directive can be used at http and server levels. *) Change: the last index only in the "index" directive can be absolute. *) Feature: the "rewrite" directive can use the variables. *) Feature: the "internal" directive. *) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR, SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME, REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables. *) Change: nginx now passes the invalid lines in a client request headers or a backend response header. *) Bugfix: if the backend did not transfer response for a long time and the "send_timeout" was less than "proxy_read_timeout", then nginx returned the 408 response. *) Bugfix: the segmentation fault was occurred if the backend sent an invalid line in response header; bug appeared in 0.1.26. *) Bugfix: the segmentation fault may occurred in FastCGI fault tolerance configuration. *) Bugfix: the "expires" directive did not remove the previous "Expires" and "Cache-Control" headers. *) Bugfix: nginx did not take into account trailing dot in "Host" header line. *) Bugfix: the ngx_http_auth_module did not work under Linux. *) Bugfix: the rewrite directive worked incorrectly, if the arguments were in a request. *) Bugfix: nginx could not be built on MacOS X.
author Igor Sysoev <http://sysoev.ru>
date Thu, 12 May 2005 00:00:00 +0400
parents bcb5fce0b038
children da9a3b14312d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
52
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
2 /*
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
3 * Copyright (C) Igor Sysoev
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
4 */
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
5
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
6
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
7 #include <ngx_config.h>
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
8 #include <ngx_core.h>
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
9
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
10
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
11 /*
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
12 * Solaris has thread-safe crypt()
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
13 * Linux has crypt_r(); "struct crypt_data" is more than 128K
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
14 * FreeBSD needs the mutex to protect crypt()
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
15 *
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
16 * TODO:
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
17 * ngx_crypt_init() to init mutex
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
18 */
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
19
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
20
54
bcb5fce0b038 nginx 0.1.27
Igor Sysoev <http://sysoev.ru>
parents: 52
diff changeset
21 #if (NGX_CRYPT)
bcb5fce0b038 nginx 0.1.27
Igor Sysoev <http://sysoev.ru>
parents: 52
diff changeset
22
52
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
23 #if (NGX_LINUX)
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
24
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
25 ngx_int_t
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
26 ngx_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted)
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
27 {
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
28 char *value;
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
29 size_t len;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
30 ngx_err_t err;
52
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
31 struct crypt_data cd;
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
32
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
33 ngx_set_errno(0);
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
34
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
35 cd.initialized = 0;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
36
52
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
37 value = crypt_r((char *) key, (char *) salt, &cd);
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
38
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
39 err = ngx_errno;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
40
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
41 if (err == 0) {
52
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
42 len = ngx_strlen(value);
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
43
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
44 *encrypted = ngx_palloc(pool, len);
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
45 if (*encrypted) {
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
46 ngx_memcpy(*encrypted, value, len + 1);
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
47 return NGX_OK;
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
48 }
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
49 }
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
50
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
51 ngx_log_error(NGX_LOG_CRIT, pool->log, err, "crypt_r() failed");
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
52
52
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
53 return NGX_ERROR;
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
54 }
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
55
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
56 #else
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
57
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
58 ngx_int_t
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
59 ngx_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted)
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
60 {
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
61 char *value;
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
62 size_t len;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
63 ngx_err_t err;
52
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
64
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
65 #if (NGX_THREADS && NGX_NONREENTRANT_CRYPT)
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
66
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
67 /* crypt() is a time consuming funtion, so we only try to lock */
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
68
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
69 if (ngx_mutex_trylock(ngx_crypt_mutex) != NGX_OK) {
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
70 return NGX_AGAIN;
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
71 }
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
72
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
73 #endif
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
74
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
75 ngx_set_errno(0);
52
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
76
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
77 value = crypt((char *) key, (char *) salt);
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
78
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
79 if (value) {
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
80 len = ngx_strlen(value);
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
81
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
82 *encrypted = ngx_palloc(pool, len);
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
83 if (*encrypted) {
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
84 ngx_memcpy(*encrypted, value, len + 1);
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
85 }
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
86
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
87 #if (NGX_THREADS && NGX_NONREENTRANT_CRYPT)
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
88 ngx_mutex_unlock(ngx_crypt_mutex);
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
89 #endif
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
90 return NGX_OK;
52
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
91 }
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
92
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
93 err = ngx_errno;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
94
52
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
95 #if (NGX_THREADS && NGX_NONREENTRANT_CRYPT)
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
96 ngx_mutex_unlock(ngx_crypt_mutex);
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
97 #endif
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
98
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
99 ngx_log_error(NGX_LOG_CRIT, pool->log, err, "crypt() failed");
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
100
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 54
diff changeset
101 return NGX_ERROR;
52
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
102 }
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
103
0d75d65c642f nginx 0.1.26
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
104 #endif
54
bcb5fce0b038 nginx 0.1.27
Igor Sysoev <http://sysoev.ru>
parents: 52
diff changeset
105
bcb5fce0b038 nginx 0.1.27
Igor Sysoev <http://sysoev.ru>
parents: 52
diff changeset
106 #endif /* NGX_CRYPT */