-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfig
192 lines (166 loc) · 6.77 KB
/
config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# vim: filetype=sh
# If $NGX_IGNORE_RPATH is set to "YES", we will ignore explicit
# library path specification on resulting binary, allowing libmodsecurity.so
# to be relocated across configured library pathes (adjust /etc/ld.so.conf
# or set $LD_LIBRARY_PATH environment variable to manage them)
#
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include <protobuf-c/protobuf-c.h>"
#ngx_feature_libs= #"-lmodsecurity"
ngx_feature_test='printf("hello");'
ngx_protobufc_opt_I=
ngx_protobufc_opt_L=
# for older systems that don't default to this std.
CFLAGS="$CFLAGS -std=gnu99"
# If $PROTOBUFC_INC is specified, lets use it. Otherwise lets try
# the default paths
#
if [ -n "$PROTBUFC_INC" -o -n "$PROTOBUFC_LIB" ]; then
# explicitly set protobuf-c lib path
ngx_feature="Protobuf-c library in \"$PROTOBUFC_LIB\" and \"$PROTOBUFC_INC\" (specified by the PROTOBUFC_LIB and PROTOBUFC_INC env)"
ngx_feature_path="$PROTOBUFC_INC"
ngx_protobufc_opt_I="-I$PROTOBUFC_INC"
ngx_protobufc_opt_L="-L$PROTOBUFC_LIB"
echo "NGX_RPATH is $NGX_RPATH"
echo "NGX_IGNORE_RPATH is $NGX_IGNORE_RPATH"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R$PROTOBUFC_LIB -L$PROTOBUFC_LIB -lprotobuf-c"
elif [ "$NGX_IGNORE_RPATH" != "YES" -a $NGX_SYSTEM = "Linux" ]; then
#ngx_feature_libs="-Wl,-rpath,$PROTOBUFC_LIB -L$PROTOBUFC_LIB -lprotobuf-c"
ngx_feature_libs="$PROTOBUFC_LIB/libprotobuf-c.a"
else
ngx_feature_libs="-L$PROTOBUFC_LIB -lprotobuf-c"
fi
. auto/feature
if [ $ngx_found = no ]; then
cat << END
$0: error: ngx_http_contrast_connector_module requires the protobuf-c
library and PROTOBUFC_LIB is defined as "$PROTOBUFC_LIB" and
PROTOBUFC_INC (path for protobuf-c.h) "$PROTOBUFC_INC", but we cannot
find Protobuf-c there.
END
exit 1
fi
else
# auto-discovery
ngx_feature="Protobuf-c v3 library"
ngx_feature_libs="-lprotobuf-c"
. auto/feature
if [ $ngx_found = no ]; then
ngx_feature="Protobuf-c library in /usr/local/protobuf-c"
ngx_feature_path="/usr/local/protobuf-c/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/usr/local/protobuf-c/lib -L/usr/local/protobuf-c/lib -lprotobuf-c"
elif [ "$NGX_IGNORE_RPATH" != "YES" -a $NGX_SYSTEM = "Linux" ]; then
ngx_feature_libs="-Wl,-rpath,/usr/local/protobuf-c/lib -L/usr/local/protobuf-c/lib -lprotobuf-c"
else
ngx_feature_libs="-L/usr/local/protobuf-c/lib -lprotobuf-c"
fi
. auto/feature
fi
fi
if [ $ngx_found = no ]; then
cat << END
$0: error: ngx_http_contrast_connector_module requires the Protobuf-c v3 library.
END
exit 1
fi
ngx_addon_name=ngx_http_contrast_connector_module
# We must place ngx_http_modsecurity_module after ngx_http_gzip_filter_module
# in load order list to be able to read response body before it gets compressed
# (for filter modules later initialization means earlier execution).
#
# Nginx implements load ordering only for dynamic modules and only a BEFORE part
# of "ngx_module_order". So we list all of the modules that come after
# ngx_http_gzip_filter_module as a BEFORE dependency for
# ngx_http_modsecurity_module.
#
# For static compilation HTTP_FILTER_MODULES will be patched later.
contrast_dependency="ngx_http_postpone_filter_module \
ngx_http_ssi_filter_module \
ngx_http_charset_filter_module \
ngx_http_xslt_filter_module \
ngx_http_image_filter_module \
ngx_http_sub_filter_module \
ngx_http_addition_filter_module \
ngx_http_gunzip_filter_module \
ngx_http_userid_filter_module \
ngx_http_headers_filter_module \
ngx_http_copy_filter_module"
if test -n "$ngx_module_link"; then
ngx_module_type=HTTP_FILTER
ngx_module_name="$ngx_addon_name"
ngx_module_srcs="$ngx_addon_dir/ngx_http_contrast_connector_module.c \
$ngx_addon_dir/ngx_http_contrast_connector_socket.c \
$ngx_addon_dir/ngx_http_contrast_connector_handlers.c \
$ngx_addon_dir/connect.pb-c.c \
"
ngx_module_deps="$ngx_addon_dir/ngx_http_contrast_connector_common.h \
$ngx_addon_dir/ngx_http_contrast_connector_socket.h \
$ngx_addon_dir/module_version.h \
"
ngx_module_libs="$ngx_feature_libs"
ngx_module_incs="$ngx_feature_path"
ngx_module_order="ngx_http_chunked_filter_module \
ngx_http_v2_filter_module \
ngx_http_range_header_filter_module \
ngx_http_gzip_filter_module \
$ngx_module_name \
$contrast_dependency";
. auto/module
else
CFLAGS="$ngx_protobufc_opt_I $CFLAGS"
NGX_LD_OPT="$ngx_protobufc_opt_L $NGX_LD_OPT"
CORE_INCS="$CORE_INCS $ngx_feature_path"
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES ngx_http_contrast_connector_module"
NGX_ADDON_SRCS="\
$NGX_ADDON_SRCS \
$ngx_addon_dir/ngx_http_contrast_connector_module.c \
$ngx_addon_dir/ngx_http_contrast_connector_socket.c \
$ngx_addon_dir/ngx_http_contrast_connector_handlers.c \
$ngx_addon_dir/connect.pb-c.c \
"
NGX_ADDON_DEPS="\
$NGX_ADDON_DEPS \
$ngx_addon_dir/ngx_http_contrast_connector_common.h \
$ngx_addon_dir/ngx_http_contrast_connector_socket.h \
$ngx_addon_dir/module_version.h \
"
fi
#
# Nginx does not provide reliable way to introduce our module into required
# place in static ($ngx_module_link=ADDON) compilation mode, so we must
# explicitly update module "ordering rules".
#
if [ "$ngx_module_link" != DYNAMIC ] ; then
# Reposition modsecurity module to satisfy $contrast_dependency
# (this mimics dependency resolution made by ngx_add_module() function
# though less optimal in terms of computational complexity).
modules=
found=
for module in $HTTP_FILTER_MODULES; do
# skip our module name from the original list
if [ "$module" = "$ngx_addon_name" ]; then
continue
fi
if [ -z "${found}" ]; then
for item in $contrast_dependency; do
if [ "$module" = "$item" ]; then
modules="${modules} $ngx_addon_name"
found=1
break
fi
done
fi
modules="${modules} $module"
done
if [ -z "${found}" ]; then
# This must never happen since ngx_http_copy_filter_module must be in HTTP_FILTER_MODULES
# and we stated dependency on it in $contrast_dependency
echo "$0: error: cannot reposition contrast_connector module in HTTP_FILTER_MODULES list"
exit 1
fi
HTTP_FILTER_MODULES="${modules}"
fi