Commit Graph

2163 Commits

Author SHA1 Message Date
Andrew Clayton
7d177faf3b Isolation: added core cgroup infrastructure.
Firstly, this is not to be confused with CLONE_NEWCGROUP which unit
already supports and is related to namespaces. To re-cap, namespaces
allow processes to have different views of various parts of the system
such as filesystem mounts, networking, hostname etc.

Whereas cgroup[0] is a Linux kernel facility for collecting a bunch of
processes together to perform some task on the group as a whole, for
example to implement resource limits.

There are two parts to cgroup, the core part of organising processes
into a hierarchy and the controllers which are responsible for enforcing
resource limits etc.

There are currently two versions of the cgroup sub-system, the original
cgroup and a version 2[1] introduced in 3.16 (August 2014) and marked
stable in 4.5 (March 2016).

This commit supports the cgroup V2 API and implements the ability to
place applications into their own cgroup on a per-application basis.
You can put them each into their own cgroup or you can group some
together. The ability to set resource limits can easily be added in
future.

The initial use case of this would be to aid in observability of unit
applications which becomes much easier if you can just monitor them on a
per cgroup basis.

One thing to note about cgroup, is that unlike namespaces which are
controlled via system calls such as clone(2) and unshare(2), cgroups are
setup and controlled through the cgroupfs pseudo-filesystem.

cgroup is Linux only and this support will only be enabled if configure
finds the cgroup2 filesystem mount, e.g

  cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,seclabel,nsdelegate,memory_recursiveprot)

The cgroups are removed on shutdown or as required on reconfiguration.

This commit just adds the basic infrastructure for using cgroups within
unit. Subsequent commits will wire up this support.

It supports creating cgroups relative to the main cgroup root and also
below the cgroup of the main unit process.

[0]: <https://man7.org/linux/man-pages/man7/cgroups.7.html>
[1]: <https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html>

Cc: Alejandro Colomar <alx@nginx.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2022-12-10 14:00:20 +00:00
Andrew Clayton
9466daf9bd Added simple wrappers for fopen(3) and fclose(3).
Add simple wrapper functions for fopen(3) and fclose(3) that are
somewhat akin to the nxt_file_open() and nxt_file_close() wrappers that
log errors.

Suggested-by: Alejandro Colomar <alx@nginx.com>
Reviewed-by: Alejandro Colomar <alx@nginx.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2022-12-10 14:00:20 +00:00
Andrei Zeliankou
55b9a5307d Tests: fixed tests to run as privileged user. 2022-12-09 14:17:49 +00:00
Andrew Clayton
e70653c766 Fix compilation with GCC and -O0.
Andrei reported an issue with building unit when using '-O0' with GCC
producing the following compiler errors

cc -c -pipe -fPIC -fvisibility=hidden -O -W -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wmissing-prototypes -Werror -g -O0  -I src -I build   \
                      \
                     \
-o build/src/nxt_unit.o \
-MMD -MF build/src/nxt_unit.dep -MT build/src/nxt_unit.o \
src/nxt_unit.c
src/nxt_unit.c: In function ‘nxt_unit_log’:
src/nxt_unit.c:6601:9: error: ‘msg’ may be used uninitialized [-Werror=maybe-uninitialized]
 6601 |     p = nxt_unit_snprint_prefix(p, end, pid, level);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/nxt_unit.c:6682:1: note: by argument 2 of type ‘const char *’ to ‘nxt_unit_snprint_prefix’ declared here
 6682 | nxt_unit_snprint_prefix(char *p, const char *end, pid_t pid, int level)
      | ^~~~~~~~~~~~~~~~~~~~~~~
src/nxt_unit.c:6582:22: note: ‘msg’ declared here
 6582 |     char             msg[NXT_MAX_ERROR_STR], *p, *end;
      |                      ^~~
src/nxt_unit.c: In function ‘nxt_unit_req_log’:
src/nxt_unit.c:6645:9: error: ‘msg’ may be used uninitialized [-Werror=maybe-uninitialized]
 6645 |     p = nxt_unit_snprint_prefix(p, end, pid, level);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/nxt_unit.c:6682:1: note: by argument 2 of type ‘const char *’ to ‘nxt_unit_snprint_prefix’ declared here
 6682 | nxt_unit_snprint_prefix(char *p, const char *end, pid_t pid, int level)
      | ^~~~~~~~~~~~~~~~~~~~~~~
src/nxt_unit.c:6625:35: note: ‘msg’ declared here
 6625 |     char                          msg[NXT_MAX_ERROR_STR], *p, *end;
      |                                   ^~~
cc1: all warnings being treated as errors

The above was reproduced with

  $ ./configure --cc-opt=-O0 && ./configure python && make -j4

This warning doesn't happen on clang (15.0.4) or GCC (8.3) and seems to
have been introduced in GCC 11.  The above is from GCC (12.2.1, Fedora
37).

The trigger of this GCC issue is actually part of a commit I introduced
a few months back to constify some function parameters and it seems the
consensus for how to resolve this problem is to simply remove the const
qualifier from the *end parameter to nxt_unit_snprint_prefix().

Reported-by: Andrei Zeliankou <zelenkov@nginx.com>
Link: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100417>
Link: <https://github.com/samtools/htslib/pull/1285>
Link: <https://gcc.gnu.org/gcc-11/changes.html>
Fixes: 4418f99 ("Constified numerous function parameters.")
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2022-12-08 13:45:01 +00:00
Konstantin Pavlov
6afc524116 Packages: added Ubuntu 22.10 "kinetic" support. 2022-11-16 17:05:57 +04:00
Konstantin Pavlov
0feab91c5b Packages: added Fedora 37 support. 2022-11-16 17:06:42 +04:00
Konstantin Pavlov
09ac678943 Used pkg-config to detect njs where available. 2022-11-29 18:10:38 +04:00
Andrei Zeliankou
d862f581db Node.js: added "shortCircuit" option for ES modules hook.
Starting from Node.js v18.6.0 return value from all hooks must have
"shortCircuit: true" option specified.  For more information see:
https://github.com/nodejs/node/commit/10bcad5c6e
2022-12-06 14:30:13 +00:00
Andrew Clayton
491d0f700f Python: Added support for Python 3.11.
Python 3.8 added a new Python initialisation configuration API[0].

Python 3.11 marked the old API as deprecated resulting in the following
compiler warnings which we treat as errors, failing the build

src/python/nxt_python.c: In function ‘nxt_python_start’:
src/python/nxt_python.c:130:13: error: ‘Py_SetProgramName’ is deprecated [-Werror=deprecated-declarations]
  130 |             Py_SetProgramName(nxt_py_home);
      |             ^~~~~~~~~~~~~~~~~
In file included from /opt/python-3.11/include/python3.11/Python.h:94,
                 from src/python/nxt_python.c:7:
/opt/python-3.11/include/python3.11/pylifecycle.h:37:38: note: declared here
   37 | Py_DEPRECATED(3.11) PyAPI_FUNC(void) Py_SetProgramName(const wchar_t *);
      |                                      ^~~~~~~~~~~~~~~~~
src/python/nxt_python.c:134:13: error: ‘Py_SetPythonHome’ is deprecated [-Werror=deprecated-declarations]
  134 |             Py_SetPythonHome(nxt_py_home);
      |             ^~~~~~~~~~~~~~~~
/opt/python-3.11/include/python3.11/pylifecycle.h:40:38: note: declared here
   40 | Py_DEPRECATED(3.11) PyAPI_FUNC(void) Py_SetPythonHome(const wchar_t *);
      |                                      ^~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

We actually have a few config scenarios: Python < 3, Python >= 3.0 < 3.8
and for Python 3 we have two configs where we select one based on
virtual environment setup.

Factor out the Python 3 config initialisation into its own function.  We
actually create two functions, one for Python 3.8+ and one for older
Python 3.  We pick the right function to use at build time.

The new API also has error checking (where the old API doesn't) which we
handle.

[0]: https://peps.python.org/pep-0587/

Closes: <https://github.com/nginx/unit/issues/710>
[ Andrew: Expanded upon patch from @sandeep-gh ]
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2022-12-06 02:51:03 +00:00
Liam Crilly
dfededabdc Added tools/README.md. 2022-12-03 18:11:14 +00:00
Andrei Zeliankou
190691ade8 Tests: NJS. 2022-11-29 01:02:08 +00:00
Zhidao HONG
e3bbf5b3b5 NJS: added http request prototype. 2022-11-22 10:13:18 +08:00
Zhidao HONG
4d6d146e92 Basic njs support. 2022-11-20 23:16:51 +08:00
Zhidao HONG
4735931ace Var: separating nxt_tstr_t from nxt_var_t.
It's for the introduction of njs support.
For each option that supports native variable and JS template literals introduced next,
it's unified as template string.

No functional changes.
2022-11-20 23:15:01 +08:00
Artem Konev
0c9f417aff Added security.txt. 2022-11-24 15:06:54 +00:00
Konstantin Pavlov
e9c1954dc2 Tools: Added setup-unit.
Downloaded from <https://unit.nginx.org/_downloads/setup-unit.sh>.

Acked-by: Artem Konev <a.konev@f5.com>
Acked-by: Konstantin Pavlov <thresh@nginx.com>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2022-11-22 13:55:06 +01:00
Zhidao HONG
3711632c00 Var: improved variable parsing with empty names.
Unit parsed the case of "$uri$$host" into unknown variables.
This commit makes it invalid variable instead.
2022-11-20 23:11:41 +08:00
Konstantin Pavlov
894a2620a7 Propagated NXT_RUBY_CFLAGS to Ruby checks.
This fixes an issue addressed in 651f5a37f5b8 on FreeBSD 12.

The problem manifested itself as:

configuring Ruby module
checking for -fdeclspec ... found
checking for Ruby library ... not found
checking for Ruby library in /usr/local/lib ... not found

./configure: error: no Ruby found.
2022-11-16 18:37:35 +04:00
OutOfFocus4
6902cd14ad Refactored functions that set WSGI variables.
Splitting `nxt_python_add_sptr` into several functions will make future
additions easier.

Signed-off-by: Alejandro Colomar <alx@nginx.com>
2022-11-17 21:49:43 +01:00
OutOfFocus4
3b970ed934 Removed dead code.
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2022-11-17 21:48:56 +01:00
Konstantin Pavlov
2ac4a7527d Packages: relaxed dependencies between modules and base package.
This allows us to update base or single modules packages without
updating the whole set.
2022-11-04 16:52:19 +04:00
Andrei Zeliankou
9ea5ed2813 Tests: fixed _check_processes() checks in "--restart" mode. 2022-11-15 01:07:41 +00:00
Andrei Zeliankou
bb11ef694c Tests: removed migration test.
Migration of "share" behaviour was dropped after b57b4749b993.
2022-11-15 00:56:49 +00:00
Andrei Zeliankou
2c2156e236 Tests: fixed assertion in test_variables_dynamic. 2022-11-15 00:42:12 +00:00
Andrei Zeliankou
0d3b31e671 Tests: features and options checks improved.
Now version output evaluates only once.
OpenSSL checks more carefully.
2022-11-15 00:39:21 +00:00
Andrei Zeliankou
40d75c94a0 Optimization for the "--no-unix-sockets" case. 2022-11-15 00:17:32 +00:00
Konstantin Pavlov
11f416878a Packages: added Python 3.8 and Python 3.9 modules on RHEL 8 clones.
Refs: https://github.com/nginx/unit/issues/778
2022-11-04 13:55:16 +04:00
Alejandro Colomar
ebf02266a2 Removed the unsafe nxt_memchr() wrapper for memchr(3).
The casts are unnecessary, since memchr(3)'s argument is 'const void *'.
It might have been necessary in the times of K&R, where 'void *' didn't
exist.  Nowadays, it's unnecessary, and _very_ unsafe, since casts can
hide all classes of bugs by silencing most compiler warnings.

The changes from nxt_memchr() to memchr(3) were scripted:

$ find src/ -type f \
  | grep '\.[ch]$' \
  | xargs sed -i 's/nxt_memchr/memchr/'

Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2022-11-04 00:30:50 +01:00
Alejandro Colomar
1b05161107 Removed the unsafe nxt_memcmp() wrapper for memcmp(3).
The casts are unnecessary, since memcmp(3)'s arguments are 'void *'.
It might have been necessary in the times of K&R, where 'void *' didn't
exist.  Nowadays, it's unnecessary, and _very_ unsafe, since casts can
hide all classes of bugs by silencing most compiler warnings.

The changes from nxt_memcmp() to memcmp(3) were scripted:

$ find src/ -type f \
  | grep '\.[ch]$' \
  | xargs sed -i 's/nxt_memcmp/memcmp/'

Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2022-11-04 00:30:27 +01:00
Andrew Clayton
a03274456b PHP: allowed to specify URLs without a trailing '/'.
Both @lucatacconi & @mwoodpatrick reported what appears to be the same
issue on GitHub. Namely that when using the PHP language module and
trying to access a URL that is a directory but without specifying the
trailing '/', they were getting a '503 Service Unavailable' error.

Note: This is when _not_ using the 'script' option.

E.g with the following config

  {
      "listeners": {
          "[::1]:8080": {
              "pass": "applications/php"
          }
      },

      "applications": {
          "php": {
              "type": "php",
              "root": "/var/tmp/unit-php"
          }
      }
  }

and with a directory path of /var/tmp/unit-php/foo containing an
index.php, you would see the following

  $ curl http://localhost/foo
  <title>Error 503</title>
  Error 503

However

  $ curl http://localhost/foo/

would work and serve up the index.php

This commit fixes the above so you get the desired behaviour without
specifying the trailing '/' by doing the following

  1] If the URL doesn't end in .php and doesn't have a trailing '/'
     then check if the requested path is a directory.

  2) If it is a directory then create a 301 re-direct pointing to it.
     This matches the behaviour of the likes of nginx, Apache and
     lighttpd.

     This also matches the behaviour of the "share" action in Unit.

This doesn't effect the behaviour of the 'script' option which bypasses
the nxt_php_dynamic_request() function.

This also adds a couple of tests to test/test_php_application.py to
ensure this continues to work.

Closes: <https://github.com/nginx/unit/issues/717>
Closes: <https://github.com/nginx/unit/issues/753>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2022-11-02 14:22:39 +00:00
Andrew Clayton
58248a6220 Fixed some function definitions.
Future releases of GCC will render function definitions like

  func()

invalid by default. See the previous commit 09f88c9 ("Fixed main()
prototypes in auto tests.") for details.

Such functions should be defined like

  func(void)

This is a good thing to do regardless of the upcoming GCC changes.

Reviewed-by: Alejandro Colomar <alx@nginx.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2022-10-28 03:18:33 +01:00
Andrew Clayton
8f0dd9478e Fixed main() prototypes in auto tests.
Future releases of GCC are planning to remove[0] default support for
some old features that were removed from C99 but GCC still accepts.

We can test for these changes by using the following -Werror=
directives

  -Werror=implicit-int
  -Werror=implicit-function-declaration
  -Werror=int-conversion
  -Werror=strict-prototypes
  -Werror=old-style-definition

Doing so revealed an issue with the auto/ tests in that the test
programs always define main as

  int main()

rather than

  int main(void)

which results in a bunch of errors like

build/autotest.c:3:23: error: function declaration isn't a prototype [-Werror=strict-prototypes]
    3 |                   int main() {
      |                       ^~~~
build/autotest.c: In function 'main':
build/autotest.c:3:23: error: old-style function definition [-Werror=old-style-definition]

The fix was easy, it only required fixing the main prototype with

  find -type f -exec sed -i 's/int main() {/int main(void) {/g' {} \;

Regardless of these upcoming GCC changes, this is probably a good thing
to do anyway for correctness.

[0]: https://fedoraproject.org/wiki/Changes/PortingToModernC

Link: <https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/CJXKTLXJUPZ4F2C2VQOTNMEA5JAUPMBD/>
Link: <https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/6SGHPHPAXKCVJ6PUZ57WVDQ5TDBVIRMF/>
Reviewed-by: Alejandro Colomar <alx@nginx.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2022-10-28 03:17:31 +01:00
Alejandro Colomar
a3cb07df20 Fixed path for sed(1).
Some distros provide it in /bin/sed and others in both /bin/sed
and /usr/bin/sed.  Use the more available one.

Reported-by: Konstantin Pavlov <thresh@nginx.com>
Fixes: ac64ffde57 "Improved readability of <docker-entrypoint.sh>."
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2022-10-27 14:30:49 +02:00
javad mnjd
ac64ffde57 Improved readability of <docker-entrypoint.sh>.
Cc: Konstantin Pavlov <thresh@nginx.com>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2022-10-26 16:32:15 +02:00
Andrew Clayton
7a928b33b4 Set git diff driver for C source code files.
Git can be told to apply language-specific rules when generating diffs.
Enable this for C source code files (*.c and *.h) so that function names
are printed right. Specifically, doing so prevents "git diff" from
mistakenly considering unindented goto labels as function names.

This has the same effect as adding

    [diff "default"]
        xfuncname = "^[[:alpha:]$_].*[^:]$"

to your git config file.

e.g get

    @@ -10,7 +10,7 @@ int main(void)

instead of

    @@ -10,7 +10,7 @@ again:

This makes use of the gitattributes(5) infrastructure.

Link: <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=218dd85887da3d7d08119de18e9d325fcf30d7a4>
Link: <https://git.kernel.org/pub/scm/git/git.git/commit/?id=e82675a040d559c56be54255901138a979eeec21>
Reviewed-by: Alejandro Colomar <alx@nginx.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2022-10-26 01:23:02 +01:00
Remi Collet
e096f19d47 TLS: Using ERR_get_error_all() with OpenSSL 3.
Link: <https://www.openssl.org/docs/man3.0/man7/migration_guide.html>
Cc: Andy Postnikov <apostnikov@gmail.com>
Cc: Andrew Clayton <a.clayton@nginx.com>
Signed-off-by: Remi Collet <remi@remirepo.net>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2022-10-21 11:48:08 +02:00
Remi Collet
93d24bb114 Preferring system crypto policy.
If we don't call SSL_CTX_set_cipher_list(), then it uses the
system's default.

Link: <https://fedoraproject.org/wiki/Changes/CryptoPolicy>
Link: <https://docs.fedoraproject.org/en-US/packaging-guidelines/CryptoPolicies/>
Link: <https://www.redhat.com/en/blog/consistent-security-crypto-policies-red-hat-enterprise-linux-8>
Signed-off-by: Remi Collet <remi@remirepo.net>
Acked-by: Andrei Belov <defan@nginx.com>
[ alx: add changelog and tweak commit message ]
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2022-10-20 16:25:15 +02:00
Alex Colomar
f93361979a Avoided modifying existing directories at 'make install'.
'install -d' has an issue compared to 'mkdir -p':  it doesn't
respect existing directories.  It will set the ownership, file
mode, and SELinux contexts (and any other property that would be
set by install(1) to a newly-created directory), overwriting any
existing properties of the existing directory.

'mkdir -p' doesn't have this issue:  it is a no-op if the
directory exists.  However, it's not an ideal solution either,
since it can't be used to set the properties (owner, mode, ...) of
a newly-created directory.

Therefore, the best solution is to use install(1), but only after
making sure that the directory doesn't exist with test(1).

Reported-by: Andrew Clayton <a.clayton@nginx.com>
Reported-by: Alejandro Colomar <alx@nginx.com>
Closes: <https://github.com/nginx/unit/issues/769>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
Tested-by: Andrew Clayton <a.clayton@nginx.com>
Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
2022-10-20 15:50:05 +02:00
Zhidao HONG
bbf1f4da0f Configuration: added the regex status in configure summary. 2022-10-20 12:02:27 +08:00
Zhidao HONG
c03ebf7ffe Configuration: stopped automatic migration to the "share" behavior.
This commit removed the $uri auto-append for the "share" option
introduced in rev be6409cdb028.

The main reason is that it causes problems when preparing Unit configurations
to be loaded at startup from the state directory. E.g. Docker. A valid conf.json
file with $uri references will end up with $uri$uri due to the auto-append.
2022-10-14 14:00:02 +08:00
Remi Collet
db86dc0586 Added parentheses for consistency.
Reported-by: Andrew Clayton <a.clayton@nginx.com>
Signed-off-by: Remi Collet <remi@remirepo.net>
Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2022-10-19 12:59:57 +02:00
Remi Collet
48b6a7b311 PHP: Fixed php_module_startup() call for PHP 8.2.
PHP 8.2 changed the prototype of the function, removing the last
parameter.

Signed-off-by: Remi Collet <remi@remirepo.net>
Cc: Timo Stark <t.stark@nginx.com>
Cc: George Peter Banyard <girgias@php.net>
Tested-by: Andy Postnikov <apostnikov@gmail.com>
Acked-by: Andy Postnikov <apostnikov@gmail.com>
Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2022-10-19 12:59:49 +02:00
Alex Colomar
f2213dbd1b Added missing error checking in the C API.
pthread_mutex_init(3) may fail for several reasons, and failing to
check will cause Undefined Behavior when those errors happen.  Add
missing checks, and correctly deinitialize previously created
stuff before exiting from the API.

Signed-off-by: Alejandro Colomar <alx@nginx.com>
Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Reviewed-by: Zhidao HONG <z.hong@f5.com>
2022-10-14 14:43:04 +02:00
Andrew Clayton
f8b892e1fa Fixed the build on MacOS (and others).
@alejandro-colomar reported that the build was broken on MacOS

cc  -o build/unitd -pipe -fPIC -fvisibility=hidden -O -W -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -fstrict-aliasing -Wstrict-overflow=5 -Wmissing-prototypes -Werror -g   \
		build/src/nxt_main.o  build/libnxt.a \
		    \
                      \
                    -L/usr/local/Cellar/pcre2/10.40/lib -lpcre2-8
Undefined symbols for architecture x86_64:
  "_nxt_fs_mkdir_parent", referenced from:
      _nxt_runtime_pid_file_create in libnxt.a(nxt_runtime.o)
      _nxt_runtime_controller_socket in libnxt.a(nxt_controller.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [build/unitd] Error 1

This was due to commit 57fc920 ("Socket: Created control socket & pid file
directories.").

This happened because this commit introduced the usage of
nxt_fs_mkdir_parent() in core code which uses nxt_fs_mkdir(), both of
these are defined in src/nxt_fs.c. It turns out however that this file
doesn't get built on MacOS (or any system that isn't Linux or that
lacks a FreeBSD compatible nmount(2) system call) due to the following

In auto/sources we have

  if [ $NXT_HAVE_ROOTFS = YES ]; then
      NXT_LIB_SRCS="$NXT_LIB_SRCS src/nxt_fs.c"
  fi

NXT_HAVE_ROOTFS is set in auto/isolation

  If [ $NXT_HAVE_MOUNT = YES -a $NXT_HAVE_UNMOUNT = YES ]; then
      NXT_HAVE_ROOTFS=YES

      cat << END >> $NXT_AUTO_CONFIG_H
  #ifndef NXT_HAVE_ISOLATION_ROOTFS
  #define NXT_HAVE_ISOLATION_ROOTFS  1
  #endif
  END

  fi

While we do have a check for a generic umount(2) which is found on
MacOS, for mount(2) we currently only check for the Linux mount(2) and
FreeBSD nmount(2) system calls. So NXT_HAVE_ROOTFS is set to NO on MacOS
and we don't build src/nxt_fs.c

This fixes the immediate build issue by taking the mount/umount OS
support out of nxt_fs.c into a new nxt_fs_mount.c file which is guarded
by the above while we now build nxt_fs.c unconditionally.

This should fix the build on any _supported_ system.

Reported-by: Alejandro Colomar <alx@nginx.com>
Fixes: 57fc920 ("Socket: Created control socket & pid file directories.")
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2022-10-14 12:25:47 +01:00
Andrei Zeliankou
af5903ff4e Tests: added tests for the $request_time variable. 2022-10-13 10:13:57 +01:00
Zhidao HONG
7aa6b06298 HTTP: added a $request_time variable. 2022-10-12 08:21:02 +08:00
Andrei Zeliankou
08dab702cb Tests: reworked "test_variables.py".
Access log used for the variables testing instead of limited routing.
Added missed test for $status variable.
Some tests moved from "test_access_log.py" to "test_variables.py".
2022-10-11 13:49:44 +01:00
Andrei Zeliankou
8e1e047191 Tests: don't try to return response when "no_recv" is True. 2022-10-11 13:49:10 +01:00
Artem Konev
8d976cac52 Added missing slashes in config section references in README.md. 2022-10-06 12:47:47 +01:00
Andrew Clayton
d806a90609 Ruby: used nxt_ruby_exception_log() in nxt_ruby_rack_init().
For consistency use nxt_ruby_exception_log() rather than nxt_alert() in
nxt_ruby_rack_init().

Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2022-10-04 19:33:11 +01:00