Mercurial > hg > nginx-vendor-0-7
annotate src/os/unix/ngx_user.c @ 366:babd3d9efb62 NGINX_0_6_27
nginx 0.6.27
*) Change: now by default the rtsig method is not built on
Linux 2.6.18+.
*) Change: now a request method is not changed while redirection to a
named location via an "error_page" directive.
*) Feature: the "resolver" and "resolver_timeout" directives in SMTP
proxy.
*) Feature: the "post_action" directive supports named locations.
*) Bugfix: a segmentation fault occurred in worker process, if a
request was redirected from proxy, FastCGI, or memcached location to
static named locations.
*) Bugfix: browsers did not repeat SSL handshake if there is no valid
client certificate in first handshake.
Thanks to Alexander V. Inyukhin.
*) Bugfix: if response code 495-497 was redirected via an "error_page"
directive without code change, then nginx tried to allocate too many
memory.
*) Bugfix: memory leak in long-lived non buffered connections.
*) Bugfix: memory leak in resolver.
*) Bugfix: a segmentation fault occurred in worker process, if a
request was redirected from proxy, FastCGI, or memcached location to
static named locations.
*) Bugfix: in the $proxy_host and $proxy_port variables caching.
Thanks to Sergey Bochenkov.
*) Bugfix: a "proxy_pass" directive with variables used incorrectly the
same port as in another "proxy_pass" directive with the same host
name and without variables.
Thanks to Sergey Bochenkov.
*) Bugfix: an alert "sendmsg() failed (9: Bad file descriptor)" on some
64-bit platforms while reconfiguration.
*) Bugfix: a segmentation fault occurred in worker process, if empty
stub block was used second time in SSI.
*) Bugfix: in copying URI part contained escaped symbols into arguments.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Wed, 12 Mar 2008 00:00:00 +0300 |
parents | 9db7e0b5b27f |
children | 984bb0b1399b |
rev | line source |
---|---|
52 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #include <ngx_config.h> | |
8 #include <ngx_core.h> | |
9 | |
10 | |
11 /* | |
12 * Solaris has thread-safe crypt() | |
13 * Linux has crypt_r(); "struct crypt_data" is more than 128K | |
14 * FreeBSD needs the mutex to protect crypt() | |
15 * | |
16 * TODO: | |
17 * ngx_crypt_init() to init mutex | |
18 */ | |
19 | |
20 | |
54 | 21 #if (NGX_CRYPT) |
22 | |
76 | 23 #if (NGX_HAVE_GNU_CRYPT_R) |
52 | 24 |
25 ngx_int_t | |
26 ngx_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted) | |
27 { | |
28 char *value; | |
29 size_t len; | |
58 | 30 ngx_err_t err; |
52 | 31 struct crypt_data cd; |
32 | |
58 | 33 ngx_set_errno(0); |
34 | |
35 cd.initialized = 0; | |
78 | 36 /* work around the glibc bug */ |
37 cd.current_salt[0] = ~salt[0]; | |
58 | 38 |
52 | 39 value = crypt_r((char *) key, (char *) salt, &cd); |
40 | |
58 | 41 err = ngx_errno; |
42 | |
43 if (err == 0) { | |
52 | 44 len = ngx_strlen(value); |
45 | |
46 *encrypted = ngx_palloc(pool, len); | |
47 if (*encrypted) { | |
48 ngx_memcpy(*encrypted, value, len + 1); | |
49 return NGX_OK; | |
50 } | |
51 } | |
52 | |
58 | 53 ngx_log_error(NGX_LOG_CRIT, pool->log, err, "crypt_r() failed"); |
54 | |
52 | 55 return NGX_ERROR; |
56 } | |
57 | |
58 #else | |
59 | |
60 ngx_int_t | |
61 ngx_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted) | |
62 { | |
63 char *value; | |
64 size_t len; | |
58 | 65 ngx_err_t err; |
52 | 66 |
67 #if (NGX_THREADS && NGX_NONREENTRANT_CRYPT) | |
68 | |
69 /* crypt() is a time consuming funtion, so we only try to lock */ | |
70 | |
71 if (ngx_mutex_trylock(ngx_crypt_mutex) != NGX_OK) { | |
72 return NGX_AGAIN; | |
73 } | |
74 | |
75 #endif | |
76 | |
58 | 77 ngx_set_errno(0); |
52 | 78 |
79 value = crypt((char *) key, (char *) salt); | |
80 | |
81 if (value) { | |
82 len = ngx_strlen(value); | |
83 | |
84 *encrypted = ngx_palloc(pool, len); | |
85 if (*encrypted) { | |
86 ngx_memcpy(*encrypted, value, len + 1); | |
87 } | |
58 | 88 |
89 #if (NGX_THREADS && NGX_NONREENTRANT_CRYPT) | |
90 ngx_mutex_unlock(ngx_crypt_mutex); | |
91 #endif | |
92 return NGX_OK; | |
52 | 93 } |
94 | |
58 | 95 err = ngx_errno; |
96 | |
52 | 97 #if (NGX_THREADS && NGX_NONREENTRANT_CRYPT) |
98 ngx_mutex_unlock(ngx_crypt_mutex); | |
99 #endif | |
100 | |
58 | 101 ngx_log_error(NGX_LOG_CRIT, pool->log, err, "crypt() failed"); |
102 | |
103 return NGX_ERROR; | |
52 | 104 } |
105 | |
106 #endif | |
54 | 107 |
108 #endif /* NGX_CRYPT */ |