Commit graph

1992 commits

Author SHA1 Message Date
Oisin Canty
ead6ed999a Ruby: changing deprecated rb_cData to rb_cObject.
Ruby 3.0 deprecated rb_cData with the intention to remove it in release 3.1.
This commit changes references of rb_cData to rb_cObject.  This was done so we
can support distributions that package Ruby 3.0, such as Fedora 34.

We also need to call rb_undef_alloc_func because we're no longer deriving from
rb_cData.  This prevents unnecessary allocations.

See:
https://docs.ruby-lang.org/en/3.0.0/doc/extension_rdoc.html

"It is recommended that klass derives from a special class called Data
(rb_cData) but not from Object or other ordinal classes.  If it doesn't,
you have to call rb_undef_alloc_func(klass)."
2021-05-18 10:14:43 +00:00
Andrey Suvorov
19dfeba86b Fixing a crash after applying the wrong TLS configuration.
When an invalid TLS configuration is applied (such as the conf_commands
feature), nxt_cert_store_get() creates a buffer to send a certificate request
to the main process and adds its default completion handler to an asynchronous
queue to free the allocated buffer.  However, if configuration fails,
nxt_router_conf_error() removes the memory pool used to allocate the buffer,
causing a crash when the completion handler is dispatched.


Assertion "src/nxt_buf.c:208 assertion failed: data == b->parent" is triggered
when is NXT_DEBUG enabled in the configure script.


This patch uses a reference counter to retain the memory pool and redefines the
completion handler to free the buffer before releasing the memory pool.
2021-05-17 14:28:38 -07:00
Andrei Zeliankou
1198118b3b Tests: fixed incorrect "--restart" mode performing. 2021-05-17 15:39:15 +01:00
Max Romanov
c216f26d30 Fixing racing condition on listen socket close in router.
Listen socket is actually closed in the instant timer handler.  This patch moves
the "configuration has been applied" notification to the timer handler to avoid
a situation when the user gets the response from the controller, but the listen
socket is still open in the router.
2021-05-17 17:34:15 +03:00
Andrei Zeliankou
25603eae9f Tests: added test for TLS with IP in SAN. 2021-05-12 14:37:25 +01:00
Oisin Canty
a0c083af20 Node.js: a shim for overriding "http" and "websocket" modules.
Also added stubs for Server.address()
This was done to prevent crashes in some popular frameworks like express

Supports both CommonJS and the new ES Modules system syntax e.g:

app.js:
const http = require('http')

app.mjs:
import http from "http"

Usage on Node 14.16.x and higher:
{
    "type": "external",
    "processes": {"spare": 0},
    "working_directory": '/project',
    "executable": "/usr/bin/env",
    "arguments": [
        "node",
        "--loader",
        "unit-http/require_shim.mjs"
        "--require",
        "unit-http/require_shim",
        "app.js"
    ]
}

Usage on Node 14.15.x and lower:
{
    "type": "external",
    "processes": {"spare": 0},
    "working_directory": '/project',
    "executable": "/usr/bin/env",
    "arguments": [
        "node",
        "--require",
        "unit-http/require_shim",
        "app.js"
    ]
}
2021-05-12 09:26:55 +00:00
Andrei Zeliankou
07c6bf165d Tests: temporary dir removed after tests execution. 2021-05-11 15:30:12 +01:00
Andrei Zeliankou
a17f7e03d4 Tests: added test for TLS with empty Subject field. 2021-05-07 17:42:48 +01:00
Andrei Zeliankou
b9e8d8073c Tests: PHP test with getting variable before the script is loaded. 2021-05-07 16:55:42 +01:00
Valentin Bartenev
b0e32bc015 PHP: forced initialization of $_SERVER in fastcgi_finish_request().
The "auto_globals_jit" PHP option postponed the initialization of the $_SERVER
global variable until the script using it had been loaded (e. g. via the
"include" expression).  As a result, nxt_php_register_variables() could be
called after fastcgi_finish_request() had finished the request and nulled
ctx->req, which thus caused a segmentation fault.
2021-05-07 07:46:25 +03:00
Oisin Canty
6703b68ed0 Tests: MIME filtering 2021-05-06 14:22:36 +00:00
Oisin Canty
b9d5eb285a Static: implemented MIME filtering 2021-05-06 14:22:21 +00:00
Andrei Zeliankou
e0a061955b Tests: added tests for openat2() features. 2021-05-05 12:36:57 +01:00
Zhidao HONG
de631d8c36 Fixed format and arguments mismatches in error log messages. 2021-05-05 17:23:33 +08:00
Zhidao HONG
8bea2977bc Fixed building without openat2(). 2021-05-05 16:30:26 +08:00
Zhidao HONG
53279af5d4 Static: support for openat2() features.
Support for chrooting, rejecting symlinks, and rejecting crossing mounting
points on a per-request basis during static file serving.
2021-04-29 22:04:34 +08:00
Zhidao HONG
113afb09ea Router: grouped app and share fields in nxt_http_action_t.
This is a prerequisite for further introduction of openat2() features.
No functional changes.
2021-04-22 13:13:06 +08:00
Andrei Belov
f90754f84a Packages: switched to common address for package maintainers. 2021-04-21 16:07:26 +03:00
Andrei Zeliankou
5b332cae83 Tests: fixed "skip" descriptors check flag for controller. 2021-04-14 15:56:03 +01:00
Konstantin Pavlov
d5889d7daa Packages: fixed Amazon Linux 2 module packages to use openssl 1.1 2021-04-12 18:39:45 +03:00
Max Romanov
74b1b1fc17 Tests: preserving unit.log when run without restart.
Introducing "unit.log.Log" class for "unit.log" file management.
Moving "findall()" function into TestApplicationProto.
Using "os.kill()" to send signals.
2021-04-08 19:11:11 +03:00
Konstantin Pavlov
30922c5741 Packages: moved Amazon Linux 2 packages to use openssl 1.1 2021-04-08 10:55:30 +03:00
Andrei Zeliankou
6c97a1a069 Tests: style. 2021-04-05 14:03:05 +01:00
Andrei Zeliankou
46d8567dd7 Tests: unset LC_ALL variable in Ruby encoding test.
This change is necessary to set Encoding.default_external value correctly.
2021-04-01 00:05:44 +01:00
Andrei Zeliankou
f43265ba2c Tests: removed skip_alert(). 2021-03-31 23:42:00 +01:00
Valentin Bartenev
a5eca0b83f Packages: fixed "dist" target to include man page in the archive. 2021-03-31 18:39:42 +03:00
Andrei Zeliankou
0ae75733f7 Tests: added file descriptor leak detection. 2021-03-31 03:24:01 +01:00
Andrei Zeliankou
e8577afc21 Tests: SNI. 2021-03-26 21:06:23 +00:00
Andrei Zeliankou
c093ee7ec5 Tests: added test for Ruby default encoding. 2021-03-26 15:42:58 +00:00
Andrei Belov
97b4de0d4a Packages: corrected permissions for /var/log/unit in rpm.
Found by rpmlint.
2021-03-26 18:29:26 +03:00
Andrei Belov
f11ad5288d Corrected man page permissions in manpage-install.
Found by rpmlint.
2021-03-26 18:28:59 +03:00
Valentin Bartenev
1ef72a79fe Version bump. 2021-03-26 11:29:41 +03:00
Valentin Bartenev
3c969905bd Added tag 1.23.0 for changeset 49ee24c03f57 2021-03-25 17:25:18 +03:00
Valentin Bartenev
71d3700951 Generated Dockerfiles for Unit 1.23.0. 2021-03-25 17:15:30 +03:00
Valentin Bartenev
6ecc9e8198 Added version 1.23.0 CHANGES. 2021-03-25 17:14:27 +03:00
Artem Konev
0e91854ad4 Fixed wording in docs/changes.xml for the 1.23.0 release. 2021-03-25 14:03:45 +00:00
Max Romanov
b8052b050e Fixing shm buffer leakage when sending over the port queue.
When the shm buffer is sent over the port queue, it needs to be completed
because it's sent over the port socket.
2021-03-25 16:55:16 +03:00
Valentin Bartenev
067c6096e2 Node.js: used distinct placeholder for version in "package.json".
This makes the "sed" instruction simpler and more portable, as the previous
variant didn't work well on BSD systems due to the "\s" metacharacter.

Thanks to Sergey A. Osokin <osa@FreeBSD.org.ru> for spotting this issue.

Also, this should prevent accidentally creating a version 1.0.0 package.
2021-03-25 16:15:03 +03:00
Max Romanov
c849483862 Node.js: fixing module global installation.
Globally installed modules require a globally installed libunit.
The "binding_pub.gyp" file is the correct version, otherwise linked module
may have unresolved symbols because libunit is not linked.
2021-03-25 16:09:24 +03:00
Max Romanov
9957a959df Releasing shm buffers for large body requests.
This fixes memory and shm file descriptor leakage that occurred when a large
request body was passed via shared memory.  The leakage was caught with the
"test_settings_body_buffer_size" test.  The main condition is the
"body_buffer_size" value exceeding 10 Mb (a shm segment).  Thus, the router was
forced to split the body into several shm segments, but these buffers were not
freed because of dummy completion handlers.
2021-03-25 14:16:30 +03:00
Andrey Suvorov
d2b0882d89 Added ability to configure multiple certificates on a listener.
The certificate is selected by matching the arriving SNI to the common name and
the alternatives names.  If no certificate matches the name, the first bundle in
the array is chosen.
2021-03-24 13:19:36 -07:00
Konstantin Pavlov
d62192738f Packages: added man page on rpm-based systems. 2021-03-24 18:45:45 +03:00
Konstantin Pavlov
4a2dcb46dd Packages: added man page on debian-based systems. 2021-03-24 18:45:45 +03:00
Konstantin Pavlov
b33babceda Added build system support for a man page. 2021-03-24 18:45:45 +03:00
Artem Konev
6d7c6196e1 Added a missing .El directive in man page source. 2021-03-24 16:49:59 +00:00
Artem Konev
4d28ea2e24 Added a man page.
Reviewed at https://rb.nginx.com/r/165/
2021-03-24 15:43:16 +00:00
Valentin Bartenev
699a3ea2eb Certificates: fixed in name attributes processing.
The idea is to put SAN after CN, but the previous version of the code
incorrectly assumed that CN was always present, which caused writes
outside the allocated object if there were no standard name attributes.
2021-03-24 16:55:47 +03:00
Valentin Bartenev
a6c6dcf5f7 Certificates: moved SAN processing to a separate function.
No functional changes.
2021-03-24 16:38:05 +03:00
Valentin Bartenev
f18a41c84b Certficates: fixed counting DNS SAN entries.
Previously, entries of any type were counted during object allocation
but only DNS type entries were actually processed.  As a result,
if some certificate entries had another type, returning information
about the certificate caused uninitialized memory access.
2021-03-24 16:38:05 +03:00
Max Romanov
178f232b3a Tests: fixed racing condition in websocket test 5_15.
Test case: "send a text message split into two fragments, then a continuation
frame with FIN = false where there is nothing to continue, then an unfragmented
text message, all sent in one chop".

The test case investigates immediate connection closing since there is no
message to continue.

The mirror server may send a response for the first frame before the test
сontinuation frame is received by the router.  In this case, the test will
receive a text frame before the close frame.
2021-03-24 11:43:41 +03:00