Mercurial > njs
changeset 2618:35e99cc2e185
Modules: fixed building when http_ssl and stream_ssl unavailable.
This fixes issue introduced in 7b3c8a66.
| author | Dmitry Volyntsev <xeioex@nginx.com> |
|---|---|
| date | Wed, 17 Sep 2025 15:34:19 -0700 |
| parents | 4909fc840713 |
| children | 97f4bc93613a |
| files | .github/workflows/check-pr.yml nginx/ngx_http_js_module.c nginx/ngx_js.c nginx/ngx_js.h nginx/ngx_js_http.c nginx/ngx_stream_js_module.c nginx/t/js_webcrypto.t nginx/t/stream_js_webcrypto.t |
| diffstat | 8 files changed, 74 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/.github/workflows/check-pr.yml Tue Sep 16 18:28:05 2025 -0700 +++ b/.github/workflows/check-pr.yml Wed Sep 17 15:34:19 2025 -0700 @@ -12,7 +12,10 @@ - name: Set the defaults and set up environment run: | - echo NGINX_CONFIGURE_CMD="auto/configure --prefix=/tmp --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-select_module --with-poll_module --with-http_auth_request_module --with-http_v2_module --with-http_slice_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-stream_realip_module --with-threads --with-cpp_test_module --with-compat --with-http_degradation_module --with-http_xslt_module --with-http_image_filter_module --with-http_perl_module --with-http_geoip_module --with-stream_geoip_module" >> $GITHUB_ENV + NGINX_BASE="auto/configure --prefix=/tmp --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-select_module --with-poll_module --with-http_auth_request_module --with-http_v2_module --with-http_slice_module --with-stream --with-stream_realip_module --with-threads --with-cpp_test_module --with-compat --with-http_degradation_module --with-http_xslt_module --with-http_image_filter_module --with-http_perl_module --with-http_geoip_module --with-stream_geoip_module" + SSL_MODULES="--with-http_ssl_module --with-mail_ssl_module --with-stream_ssl_module --with-stream_ssl_preread_module" + echo NGINX_CONFIGURE_CMD="$NGINX_BASE $SSL_MODULES" >> $GITHUB_ENV + echo NGINX_CONFIGURE_CMD_NO_SSL="$NGINX_BASE" >> $GITHUB_ENV export DEB_BUILD_MAINT_OPTIONS="hardening=+all" export DEB_CFLAGS_MAINT_APPEND="-fPIC" export DEB_LDFLAGS_MAINT_APPEND=""-Wl,--as-needed"" @@ -126,6 +129,21 @@ TEST_NGINX_GLOBALS: "load_module ${{ github.workspace }}/nginx-source/objs/ngx_http_js_module.so; load_module ${{ github.workspace }}/nginx-source/objs/ngx_stream_js_module.so;" TEST_NGINX_VERBOSE: 1 + - name: Configure and build nginx and njs modules, no SSL, static modules + run: | + cd nginx-source + NJS_OPENSSL=NO $NGINX_CONFIGURE_CMD_NO_SSL --with-cc-opt="$CC_OPT" --with-ld-opt="$LD_OPT" --add-module=../nginx || cat objs/autoconf.err + $MAKE_UTILITY -j$(nproc) modules + $MAKE_UTILITY -j$(nproc) + + - name: Test njs modules, no SSL, static modules + run: | + ulimit -c unlimited + prove -v -j$(nproc) -Inginx-tests/lib --state=save nginx/t . || prove -v -Inginx-tests/lib --state=failed + env: + TEST_NGINX_BINARY: "${{ github.workspace }}/nginx-source/objs/nginx" + TEST_NGINX_VERBOSE: 1 + - name: Create LSAN suppression file run: | cat << EOF > lsan_suppressions.txt
--- a/nginx/ngx_http_js_module.c Tue Sep 16 18:28:05 2025 -0700 +++ b/nginx/ngx_http_js_module.c Wed Sep 17 15:34:19 2025 -0700 @@ -400,7 +400,7 @@ { ngx_null_string, 0 } }; -#if (NGX_HTTP_SSL) +#if (NGX_SSL) static ngx_conf_bitmask_t ngx_http_js_ssl_protocols[] = { { ngx_string("TLSv1"), NGX_SSL_TLSv1 }, @@ -519,7 +519,7 @@ offsetof(ngx_http_js_loc_conf_t, timeout), NULL }, -#if (NGX_HTTP_SSL) +#if (NGX_SSL) { ngx_string("js_fetch_ciphers"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, @@ -8172,7 +8172,7 @@ return NULL; } -#if (NGX_HTTP_SSL) +#if (NGX_SSL) conf->ssl_verify = NGX_CONF_UNSET; conf->ssl_verify_depth = NGX_CONF_UNSET; #endif
--- a/nginx/ngx_js.c Tue Sep 16 18:28:05 2025 -0700 +++ b/nginx/ngx_js.c Wed Sep 17 15:34:19 2025 -0700 @@ -3996,7 +3996,7 @@ } -#if defined(NGX_HTTP_SSL) || defined(NGX_STREAM_SSL) +#if (NGX_SSL) static ngx_int_t ngx_js_merge_ssl(ngx_conf_t *cf, ngx_js_loc_conf_t *conf, @@ -4122,7 +4122,7 @@ return NGX_CONF_ERROR; } -#if defined(NGX_HTTP_SSL) || defined(NGX_STREAM_SSL) +#if (NGX_SSL) if (ngx_js_merge_ssl(cf, conf, prev) != NGX_OK) { return NGX_CONF_ERROR;
--- a/nginx/ngx_js.h Tue Sep 16 18:28:05 2025 -0700 +++ b/nginx/ngx_js.h Wed Sep 17 15:34:19 2025 -0700 @@ -144,7 +144,7 @@ ngx_queue_t fetch_keepalive_free -#if defined(NGX_HTTP_SSL) || defined(NGX_STREAM_SSL) +#if (NGX_SSL) #define NGX_JS_COMMON_LOC_CONF \ _NGX_JS_COMMON_LOC_CONF; \ \
--- a/nginx/ngx_js_http.c Tue Sep 16 18:28:05 2025 -0700 +++ b/nginx/ngx_js_http.c Wed Sep 17 15:34:19 2025 -0700 @@ -1643,9 +1643,11 @@ continue; } +#if (NGX_SSL) if ((http->ssl != NULL) != (cache->ssl != 0)) { continue; } +#endif if (ngx_strncasecmp(host->data, cache->host, host->len) != 0) { continue; @@ -1775,7 +1777,9 @@ cache->connection = c; +#if (NGX_SSL) cache->ssl = (http->ssl != NULL); +#endif ngx_memcpy(cache->host, http->host.data, http->host.len); cache->host_len = http->host.len; cache->port = http->port;
--- a/nginx/ngx_stream_js_module.c Tue Sep 16 18:28:05 2025 -0700 +++ b/nginx/ngx_stream_js_module.c Wed Sep 17 15:34:19 2025 -0700 @@ -232,7 +232,7 @@ { ngx_null_string, 0 } }; -#if (NGX_STREAM_SSL) +#if (NGX_SSL) static ngx_conf_bitmask_t ngx_stream_js_ssl_protocols[] = { { ngx_string("TLSv1"), NGX_SSL_TLSv1 }, @@ -379,7 +379,7 @@ offsetof(ngx_stream_js_srv_conf_t, fetch_keepalive_timeout), NULL }, -#if (NGX_STREAM_SSL) +#if (NGX_SSL) { ngx_string("js_fetch_ciphers"), NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_TAKE1, @@ -3620,7 +3620,7 @@ return NULL; } -#if (NGX_STREAM_SSL) +#if (NGX_SSL) conf->ssl_verify = NGX_CONF_UNSET; conf->ssl_verify_depth = NGX_CONF_UNSET; #endif
--- a/nginx/t/js_webcrypto.t Tue Sep 16 18:28:05 2025 -0700 +++ b/nginx/t/js_webcrypto.t Wed Sep 17 15:34:19 2025 -0700 @@ -41,6 +41,10 @@ listen 127.0.0.1:8080; server_name localhost; + location /has_crypto { + js_content test.has_crypto; + } + location /random_values_test { js_content test.random_values_test; } @@ -50,6 +54,10 @@ EOF $t->write_file('test.js', <<EOF); + function has_crypto(r) { + r.return(200, (crypto !== undefined).toString()); + } + function count1(v) { return v.toString(2).match(/1/g).length; } @@ -72,11 +80,16 @@ r.return(200, bits1 > (mean - 10 * stdd) && bits1 < (mean + 10 * stdd)); } - export default {random_values_test}; + export default {has_crypto, random_values_test}; EOF -$t->try_run('no njs')->plan(1); +$t->try_run('no njs'); + +plan(skip_all => 'njs crypto module not available') + if http_get('/has_crypto') !~ /true/; + +$t->plan(1); ###############################################################################
--- a/nginx/t/stream_js_webcrypto.t Tue Sep 16 18:28:05 2025 -0700 +++ b/nginx/t/stream_js_webcrypto.t Wed Sep 17 15:34:19 2025 -0700 @@ -23,7 +23,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/stream stream_return/) +my $t = Test::Nginx->new()->has(qw/http stream stream_return/) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -33,6 +33,21 @@ events { } +http { + %%TEST_GLOBALS_HTTP%% + + js_import test.js; + + server { + listen 127.0.0.1:8080; + server_name localhost; + + location /has_crypto { + js_content test.has_crypto; + } + } +} + stream { %%TEST_GLOBALS_STREAM%% @@ -49,6 +64,10 @@ EOF $t->write_file('test.js', <<EOF); + function has_crypto(r) { + r.return(200, (crypto !== undefined).toString()); + } + function count1(v) { return v.toString(2).match(/1/g).length; } @@ -71,10 +90,15 @@ return bits1 > (mean - 10 * stdd) && bits1 < (mean + 10 * stdd); } - export default {random_values_test}; + export default {has_crypto, random_values_test}; EOF -$t->try_run('no stream js_var')->plan(1); +$t->try_run('no stream js_var'); + +plan(skip_all => 'njs crypto module not available') + if http_get('/has_crypto') !~ /true/; + +$t->plan(1); ###############################################################################
