]> git.kaiwu.me - njs.git/commitdiff
Modules: fixed building when http_ssl and stream_ssl unavailable.
authorDmitry Volyntsev <xeioex@nginx.com>
Wed, 17 Sep 2025 22:34:19 +0000 (15:34 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Thu, 18 Sep 2025 00:36:03 +0000 (17:36 -0700)
This fixes issue introduced in 7b3c8a66.

.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

index c75f3cbe9971b9f885e244c13eeedb63f6bb68a1..d5e0edd2707597bd089b75116d3e004e7c5e02b9 100644 (file)
@@ -12,7 +12,10 @@ jobs:
 
       - 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 @@ jobs:
           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
index f9d9721aa79ace47fd88bad5f235613f2415e682..2f3ce936ea07993a0fb39c29974d4b63e7e92388 100644 (file)
@@ -400,7 +400,7 @@ static ngx_conf_bitmask_t  ngx_http_js_engines[] = {
     { 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 @@ static ngx_command_t  ngx_http_js_commands[] = {
       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 @@ ngx_http_js_create_loc_conf(ngx_conf_t *cf)
         return NULL;
     }
 
-#if (NGX_HTTP_SSL)
+#if (NGX_SSL)
     conf->ssl_verify = NGX_CONF_UNSET;
     conf->ssl_verify_depth = NGX_CONF_UNSET;
 #endif
index efef34674cb5d89a8ee499a8b2387f815e8094c6..053c23c20da74cef9e18d371c3f5b89a0b2ad8db 100644 (file)
@@ -3996,7 +3996,7 @@ ngx_js_create_conf(ngx_conf_t *cf, size_t size)
 }
 
 
-#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 @@ ngx_js_merge_conf(ngx_conf_t *cf, void *parent, void *child,
         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;
index af19e007615eb0fee76fcdc291ce0696f2bf4a57..20ea85b17c8c9f481b87ca050ab009436960662e 100644 (file)
@@ -144,7 +144,7 @@ typedef struct {
     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;                                                  \
                                                                               \
index f07cccebc622d2d46f4413a8b7fd7579bec171d8..35c67842fd239749db0b1550aea49fac5390268c 100644 (file)
@@ -1643,9 +1643,11 @@ ngx_js_http_get_keepalive_connection(ngx_js_http_t *http)
             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 @@ ngx_js_http_free_keepalive_connection(ngx_js_http_t *http)
 
     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;
index ab4e787d64bd2fcd4690745f78a7166bc87f76b4..212af40031fb9246ac7a683fd757276b8137fd2e 100644 (file)
@@ -232,7 +232,7 @@ static ngx_conf_bitmask_t  ngx_stream_js_engines[] = {
     { 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 @@ static ngx_command_t  ngx_stream_js_commands[] = {
       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 @@ ngx_stream_js_create_srv_conf(ngx_conf_t *cf)
         return NULL;
     }
 
-#if (NGX_STREAM_SSL)
+#if (NGX_SSL)
     conf->ssl_verify = NGX_CONF_UNSET;
     conf->ssl_verify_depth = NGX_CONF_UNSET;
 #endif
index f43f9d6d52cd5670386c7577b3619f6e19abb023..33869574d9f27fa2bd2e645ede2ab4a2d72ad8ec 100644 (file)
@@ -41,6 +41,10 @@ http {
         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 @@ http {
 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 @@ $t->write_file('test.js', <<EOF);
         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);
 
 ###############################################################################
 
index d7b34396c6a8e7da190e5e8cb139a2458acf0cd7..619a093d6252b70012aafe7217844622a40ecd50 100644 (file)
@@ -23,7 +23,7 @@ use Test::Nginx::Stream qw/ stream /;
 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 @@ daemon off;
 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 @@ stream {
 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 @@ $t->write_file('test.js', <<EOF);
         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);
 
 ###############################################################################