Mercurial > hg > nginx
annotate src/os/unix/ngx_user.c @ 7230:098bbd076a2d
Upstream: trailers support, u->conf->pass_trailers flag.
Basic trailer headers support allows one to access response trailers
via the $upstream_trailer_* variables.
Additionally, the u->conf->pass_trailers flag was introduced. When the
flag is set, trailer headers from the upstream response are passed to
the client. Like normal headers, trailer headers will be hidden
if present in u->conf->hide_headers_hash.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sat, 17 Mar 2018 23:04:21 +0300 |
parents | 4a670c18e5e6 |
children | eca3e054e978 |
rev | line source |
---|---|
503 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4412 | 4 * Copyright (C) Nginx, Inc. |
503 | 5 */ |
6 | |
7 | |
8 #include <ngx_config.h> | |
9 #include <ngx_core.h> | |
10 | |
11 | |
12 #if (NGX_CRYPT) | |
13 | |
527 | 14 #if (NGX_HAVE_GNU_CRYPT_R) |
503 | 15 |
16 ngx_int_t | |
3922
9c057d5e1c27
"$apr1", "{PLAIN}", and "{SSHA}" password methods in auth basic module
Igor Sysoev <igor@sysoev.ru>
parents:
3796
diff
changeset
|
17 ngx_libc_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted) |
503 | 18 { |
19 char *value; | |
20 size_t len; | |
21 struct crypt_data cd; | |
22 | |
509 | 23 cd.initialized = 0; |
5955
fd6fd02f6a4d
Fixed building with musl libc (ticket #685).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4982
diff
changeset
|
24 #ifdef __GLIBC__ |
529 | 25 /* work around the glibc bug */ |
26 cd.current_salt[0] = ~salt[0]; | |
5955
fd6fd02f6a4d
Fixed building with musl libc (ticket #685).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4982
diff
changeset
|
27 #endif |
509 | 28 |
503 | 29 value = crypt_r((char *) key, (char *) salt, &cd); |
30 | |
4982
6ccd3a50b40f
Core: crypt_r() error handling fixed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
31 if (value) { |
3796
7dec2852e8fd
allocate last zero byte in ngx_crypt()
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
32 len = ngx_strlen(value) + 1; |
503 | 33 |
2049 | 34 *encrypted = ngx_pnalloc(pool, len); |
4982
6ccd3a50b40f
Core: crypt_r() error handling fixed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
35 if (*encrypted == NULL) { |
6ccd3a50b40f
Core: crypt_r() error handling fixed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
36 return NGX_ERROR; |
503 | 37 } |
4982
6ccd3a50b40f
Core: crypt_r() error handling fixed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
38 |
6ccd3a50b40f
Core: crypt_r() error handling fixed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
39 ngx_memcpy(*encrypted, value, len); |
6ccd3a50b40f
Core: crypt_r() error handling fixed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
40 return NGX_OK; |
503 | 41 } |
42 | |
4982
6ccd3a50b40f
Core: crypt_r() error handling fixed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
43 ngx_log_error(NGX_LOG_CRIT, pool->log, ngx_errno, "crypt_r() failed"); |
509 | 44 |
503 | 45 return NGX_ERROR; |
46 } | |
47 | |
48 #else | |
49 | |
50 ngx_int_t | |
3922
9c057d5e1c27
"$apr1", "{PLAIN}", and "{SSHA}" password methods in auth basic module
Igor Sysoev <igor@sysoev.ru>
parents:
3796
diff
changeset
|
51 ngx_libc_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted) |
503 | 52 { |
53 char *value; | |
54 size_t len; | |
509 | 55 ngx_err_t err; |
503 | 56 |
57 value = crypt((char *) key, (char *) salt); | |
58 | |
59 if (value) { | |
3796
7dec2852e8fd
allocate last zero byte in ngx_crypt()
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
60 len = ngx_strlen(value) + 1; |
503 | 61 |
2049 | 62 *encrypted = ngx_pnalloc(pool, len); |
4982
6ccd3a50b40f
Core: crypt_r() error handling fixed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
63 if (*encrypted == NULL) { |
6ccd3a50b40f
Core: crypt_r() error handling fixed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
64 return NGX_ERROR; |
503 | 65 } |
509 | 66 |
4982
6ccd3a50b40f
Core: crypt_r() error handling fixed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
67 ngx_memcpy(*encrypted, value, len); |
509 | 68 return NGX_OK; |
503 | 69 } |
70 | |
509 | 71 err = ngx_errno; |
72 | |
73 ngx_log_error(NGX_LOG_CRIT, pool->log, err, "crypt() failed"); | |
74 | |
75 return NGX_ERROR; | |
503 | 76 } |
77 | |
78 #endif | |
79 | |
80 #endif /* NGX_CRYPT */ |