Skip to content

Commit 4ea1356

Browse files
committed
Modules: fixed building when http_ssl and stream_ssl unavailable.
This fixes issue introduced in 7b3c8a6.
1 parent 6b12358 commit 4ea1356

File tree

8 files changed

+74
-15
lines changed

8 files changed

+74
-15
lines changed

.github/workflows/check-pr.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ jobs:
1212

1313
- name: Set the defaults and set up environment
1414
run: |
15-
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
15+
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"
16+
SSL_MODULES="--with-http_ssl_module --with-mail_ssl_module --with-stream_ssl_module --with-stream_ssl_preread_module"
17+
echo NGINX_CONFIGURE_CMD="$NGINX_BASE $SSL_MODULES" >> $GITHUB_ENV
18+
echo NGINX_CONFIGURE_CMD_NO_SSL="$NGINX_BASE" >> $GITHUB_ENV
1619
export DEB_BUILD_MAINT_OPTIONS="hardening=+all"
1720
export DEB_CFLAGS_MAINT_APPEND="-fPIC"
1821
export DEB_LDFLAGS_MAINT_APPEND=""-Wl,--as-needed""
@@ -126,6 +129,21 @@ jobs:
126129
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;"
127130
TEST_NGINX_VERBOSE: 1
128131

132+
- name: Configure and build nginx and njs modules, no SSL, static modules
133+
run: |
134+
cd nginx-source
135+
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
136+
$MAKE_UTILITY -j$(nproc) modules
137+
$MAKE_UTILITY -j$(nproc)
138+
139+
- name: Test njs modules, no SSL, static modules
140+
run: |
141+
ulimit -c unlimited
142+
prove -v -j$(nproc) -Inginx-tests/lib --state=save nginx/t . || prove -v -Inginx-tests/lib --state=failed
143+
env:
144+
TEST_NGINX_BINARY: "${{ github.workspace }}/nginx-source/objs/nginx"
145+
TEST_NGINX_VERBOSE: 1
146+
129147
- name: Create LSAN suppression file
130148
run: |
131149
cat << EOF > lsan_suppressions.txt

nginx/ngx_http_js_module.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ static ngx_conf_bitmask_t ngx_http_js_engines[] = {
400400
{ ngx_null_string, 0 }
401401
};
402402

403-
#if (NGX_HTTP_SSL)
403+
#if (NGX_SSL)
404404

405405
static ngx_conf_bitmask_t ngx_http_js_ssl_protocols[] = {
406406
{ ngx_string("TLSv1"), NGX_SSL_TLSv1 },
@@ -519,7 +519,7 @@ static ngx_command_t ngx_http_js_commands[] = {
519519
offsetof(ngx_http_js_loc_conf_t, timeout),
520520
NULL },
521521

522-
#if (NGX_HTTP_SSL)
522+
#if (NGX_SSL)
523523

524524
{ ngx_string("js_fetch_ciphers"),
525525
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)
81728172
return NULL;
81738173
}
81748174

8175-
#if (NGX_HTTP_SSL)
8175+
#if (NGX_SSL)
81768176
conf->ssl_verify = NGX_CONF_UNSET;
81778177
conf->ssl_verify_depth = NGX_CONF_UNSET;
81788178
#endif

nginx/ngx_js.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3996,7 +3996,7 @@ ngx_js_create_conf(ngx_conf_t *cf, size_t size)
39963996
}
39973997

39983998

3999-
#if defined(NGX_HTTP_SSL) || defined(NGX_STREAM_SSL)
3999+
#if (NGX_SSL)
40004000

40014001
static ngx_int_t
40024002
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,
41224122
return NGX_CONF_ERROR;
41234123
}
41244124

4125-
#if defined(NGX_HTTP_SSL) || defined(NGX_STREAM_SSL)
4125+
#if (NGX_SSL)
41264126

41274127
if (ngx_js_merge_ssl(cf, conf, prev) != NGX_OK) {
41284128
return NGX_CONF_ERROR;

nginx/ngx_js.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ typedef struct {
144144
ngx_queue_t fetch_keepalive_free
145145

146146

147-
#if defined(NGX_HTTP_SSL) || defined(NGX_STREAM_SSL)
147+
#if (NGX_SSL)
148148
#define NGX_JS_COMMON_LOC_CONF \
149149
_NGX_JS_COMMON_LOC_CONF; \
150150
\

nginx/ngx_js_http.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,9 +1643,11 @@ ngx_js_http_get_keepalive_connection(ngx_js_http_t *http)
16431643
continue;
16441644
}
16451645

1646+
#if (NGX_SSL)
16461647
if ((http->ssl != NULL) != (cache->ssl != 0)) {
16471648
continue;
16481649
}
1650+
#endif
16491651

16501652
if (ngx_strncasecmp(host->data, cache->host, host->len) != 0) {
16511653
continue;
@@ -1775,7 +1777,9 @@ ngx_js_http_free_keepalive_connection(ngx_js_http_t *http)
17751777

17761778
cache->connection = c;
17771779

1780+
#if (NGX_SSL)
17781781
cache->ssl = (http->ssl != NULL);
1782+
#endif
17791783
ngx_memcpy(cache->host, http->host.data, http->host.len);
17801784
cache->host_len = http->host.len;
17811785
cache->port = http->port;

nginx/ngx_stream_js_module.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static ngx_conf_bitmask_t ngx_stream_js_engines[] = {
232232
{ ngx_null_string, 0 }
233233
};
234234

235-
#if (NGX_STREAM_SSL)
235+
#if (NGX_SSL)
236236

237237
static ngx_conf_bitmask_t ngx_stream_js_ssl_protocols[] = {
238238
{ ngx_string("TLSv1"), NGX_SSL_TLSv1 },
@@ -379,7 +379,7 @@ static ngx_command_t ngx_stream_js_commands[] = {
379379
offsetof(ngx_stream_js_srv_conf_t, fetch_keepalive_timeout),
380380
NULL },
381381

382-
#if (NGX_STREAM_SSL)
382+
#if (NGX_SSL)
383383

384384
{ ngx_string("js_fetch_ciphers"),
385385
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)
36203620
return NULL;
36213621
}
36223622

3623-
#if (NGX_STREAM_SSL)
3623+
#if (NGX_SSL)
36243624
conf->ssl_verify = NGX_CONF_UNSET;
36253625
conf->ssl_verify_depth = NGX_CONF_UNSET;
36263626
#endif

nginx/t/js_webcrypto.t

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ http {
4141
listen 127.0.0.1:8080;
4242
server_name localhost;
4343
44+
location /has_crypto {
45+
js_content test.has_crypto;
46+
}
47+
4448
location /random_values_test {
4549
js_content test.random_values_test;
4650
}
@@ -50,6 +54,10 @@ http {
5054
EOF
5155

5256
$t->write_file('test.js', <<EOF);
57+
function has_crypto(r) {
58+
r.return(200, (crypto !== undefined).toString());
59+
}
60+
5361
function count1(v) {
5462
return v.toString(2).match(/1/g).length;
5563
}
@@ -72,11 +80,16 @@ $t->write_file('test.js', <<EOF);
7280
r.return(200, bits1 > (mean - 10 * stdd) && bits1 < (mean + 10 * stdd));
7381
}
7482
75-
export default {random_values_test};
83+
export default {has_crypto, random_values_test};
7684
7785
EOF
7886

79-
$t->try_run('no njs')->plan(1);
87+
$t->try_run('no njs');
88+
89+
plan(skip_all => 'njs crypto module not available')
90+
if http_get('/has_crypto') !~ /true/;
91+
92+
$t->plan(1);
8093

8194
###############################################################################
8295

nginx/t/stream_js_webcrypto.t

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use Test::Nginx::Stream qw/ stream /;
2323
select STDERR; $| = 1;
2424
select STDOUT; $| = 1;
2525

26-
my $t = Test::Nginx->new()->has(qw/stream stream_return/)
26+
my $t = Test::Nginx->new()->has(qw/http stream stream_return/)
2727
->write_file_expand('nginx.conf', <<'EOF');
2828
2929
%%TEST_GLOBALS%%
@@ -33,6 +33,21 @@ daemon off;
3333
events {
3434
}
3535
36+
http {
37+
%%TEST_GLOBALS_HTTP%%
38+
39+
js_import test.js;
40+
41+
server {
42+
listen 127.0.0.1:8080;
43+
server_name localhost;
44+
45+
location /has_crypto {
46+
js_content test.has_crypto;
47+
}
48+
}
49+
}
50+
3651
stream {
3752
%%TEST_GLOBALS_STREAM%%
3853
@@ -49,6 +64,10 @@ stream {
4964
EOF
5065

5166
$t->write_file('test.js', <<EOF);
67+
function has_crypto(r) {
68+
r.return(200, (crypto !== undefined).toString());
69+
}
70+
5271
function count1(v) {
5372
return v.toString(2).match(/1/g).length;
5473
}
@@ -71,10 +90,15 @@ $t->write_file('test.js', <<EOF);
7190
return bits1 > (mean - 10 * stdd) && bits1 < (mean + 10 * stdd);
7291
}
7392
74-
export default {random_values_test};
93+
export default {has_crypto, random_values_test};
7594
EOF
7695

77-
$t->try_run('no stream js_var')->plan(1);
96+
$t->try_run('no stream js_var');
97+
98+
plan(skip_all => 'njs crypto module not available')
99+
if http_get('/has_crypto') !~ /true/;
100+
101+
$t->plan(1);
78102

79103
###############################################################################
80104

0 commit comments

Comments
 (0)