Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8d4c3e4

Browse files
zimmerleFelipe Zimmerle
authored and
Felipe Zimmerle
committed
Makes the build system to look for yajl using a macro file
Now searching for yajl using find_yajl.m4 macro file insteadof using pkg-config directly. If YAJL was not found or if itwas disabled in the configure phase, the code will be compiledwithout JSON support.
1 parente90874a commit8d4c3e4

File tree

10 files changed

+242
-26
lines changed

10 files changed

+242
-26
lines changed

‎apache2/Makefile.am‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ mod_security2_la_CFLAGS = @APR_CFLAGS@ \
3838
@LIBXML2_CFLAGS@\
3939
@LUA_CFLAGS@\
4040
@MODSEC_EXTRA_CFLAGS@\
41-
@PCRE_CFLAGS@
41+
@PCRE_CFLAGS@\
42+
@YAJL_CFLAGS@
4243

4344

4445
mod_security2_la_CPPFLAGS = @APR_CPPFLAGS@\
@@ -49,7 +50,8 @@ mod_security2_la_LIBADD = @APR_LDADD@ \
4950
@APU_LDADD@\
5051
@LIBXML2_LDADD@\
5152
@LUA_LDADD@\
52-
@PCRE_LDADD@
53+
@PCRE_LDADD@\
54+
@YAJL_LDADD@
5355

5456
if AIX
5557
mod_security2_la_LDFLAGS = -module -avoid-version\
@@ -58,7 +60,8 @@ mod_security2_la_LDFLAGS = -module -avoid-version \
5860
@APXS_LDFLAGS@\
5961
@LIBXML2_LDFLAGS@\
6062
@LUA_LDFLAGS@\
61-
@PCRE_LDFLAGS@
63+
@PCRE_LDFLAGS@\
64+
@YAJL_LDFLAGS@
6265
endif
6366

6467
if HPUX
@@ -68,7 +71,8 @@ mod_security2_la_LDFLAGS = -module -avoid-version \
6871
@APXS_LDFLAGS@\
6972
@LIBXML2_LDFLAGS@\
7073
@LUA_LDFLAGS@\
71-
@PCRE_LDFLAGS@
74+
@PCRE_LDFLAGS@\
75+
@YAJL_LDFLAGS@
7276
endif
7377

7478
if MACOSX
@@ -78,7 +82,8 @@ mod_security2_la_LDFLAGS = -module -avoid-version \
7882
@APXS_LDFLAGS@\
7983
@LIBXML2_LDFLAGS@\
8084
@LUA_LDFLAGS@\
81-
@PCRE_LDFLAGS@
85+
@PCRE_LDFLAGS@\
86+
@YAJL_LDFLAGS@
8287
endif
8388

8489
if SOLARIS
@@ -88,7 +93,8 @@ mod_security2_la_LDFLAGS = -module -avoid-version \
8893
@APXS_LDFLAGS@\
8994
@LIBXML2_LDFLAGS@\
9095
@LUA_LDFLAGS@\
91-
@PCRE_LDFLAGS@
96+
@PCRE_LDFLAGS@\
97+
@YAJL_LDFLAGS@
9298
endif
9399

94100
if LINUX
@@ -98,7 +104,8 @@ mod_security2_la_LDFLAGS = -no-undefined -module -avoid-version -R @PCRE_LD_PATH
98104
@APXS_LDFLAGS@\
99105
@LIBXML2_LDFLAGS@\
100106
@LUA_LDFLAGS@\
101-
@PCRE_LDFLAGS@
107+
@PCRE_LDFLAGS@\
108+
@YAJL_LDFLAGS@
102109
endif
103110

104111
if FREEBSD
@@ -108,7 +115,8 @@ mod_security2_la_LDFLAGS = -no-undefined -module -avoid-version \
108115
@APXS_LDFLAGS@\
109116
@LIBXML2_LDFLAGS@\
110117
@LUA_LDFLAGS@\
111-
@PCRE_LDFLAGS@
118+
@PCRE_LDFLAGS@\
119+
@YAJL_LDFLAGS@
112120
endif
113121

114122
if OPENBSD
@@ -118,7 +126,8 @@ mod_security2_la_LDFLAGS = -no-undefined -module -avoid-version \
118126
@APXS_LDFLAGS@\
119127
@LIBXML2_LDFLAGS@\
120128
@LUA_LDFLAGS@\
121-
@PCRE_LDFLAGS@
129+
@PCRE_LDFLAGS@\
130+
@YAJL_LDFLAGS@
122131
endif
123132

124133
if NETBSD
@@ -128,7 +137,8 @@ mod_security2_la_LDFLAGS = -no-undefined -module -avoid-version \
128137
@APXS_LDFLAGS@\
129138
@LIBXML2_LDFLAGS@\
130139
@LUA_LDFLAGS@\
131-
@PCRE_LDFLAGS@
140+
@PCRE_LDFLAGS@\
141+
@YAJL_LDFLAGS@
132142
endif
133143

134144
if LINUX

‎apache2/modsecurity.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,10 @@ static apr_status_t modsecurity_tx_cleanup(void *data) {
256256
/* XML processor cleanup. */
257257
if (msr->xml!=NULL)xml_cleanup(msr);
258258

259+
#ifdefWITH_YAJL
259260
/* JSON processor cleanup. */
260261
if (msr->json!=NULL)json_cleanup(msr);
262+
#endif
261263

262264
// TODO: Why do we ignore return code here?
263265
modsecurity_request_body_clear(msr,&my_error_msg);

‎apache2/modsecurity.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ typedef struct msc_parm msc_parm;
5959
#include"msc_lua.h"
6060
#endif
6161

62-
6362
#definePHASE_REQUEST_HEADERS 1
6463
#definePHASE_REQUEST_BODY 2
6564
#definePHASE_RESPONSE_HEADERS 3
@@ -369,7 +368,9 @@ struct modsec_rec {
369368
multipart_data*mpd;/* MULTIPART processor data structure */
370369

371370
xml_data*xml;/* XML processor data structure */
371+
#ifdefWITH_YAJL
372372
json_data*json;/* JSON processor data structure */
373+
#endif
373374

374375
/* audit logging */
375376
char*new_auditlog_boundary;

‎apache2/msc_json.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
#include"msc_json.h"
1616

17+
#ifdefWITH_YAJL
18+
1719
intjson_add_argument(modsec_rec*msr,constchar*value,unsignedlength)
1820
{
1921
msc_arg*arg= (msc_arg*)NULL;
@@ -311,3 +313,4 @@ apr_status_t json_cleanup(modsec_rec *msr) {
311313
return1;
312314
}
313315

316+
#endif

‎apache2/msc_json.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,19 @@
1414

1515
#ifndef_MSC_JSON_H_
1616
#define_MSC_JSON_H_
17+
#ifdefWITH_YAJL
1718

1819
typedefstructjson_datajson_data;
1920

21+
2022
#include"modsecurity.h"
23+
2124
#include<yajl/yajl_parse.h>
25+
//#ifdef WITH_YAJL
26+
//#else
27+
28+
29+
#include"modsecurity.h"
2230

2331
/* Structures */
2432
structjson_data {
@@ -46,3 +54,4 @@ int DSOLOCAL json_complete(modsec_rec *msr, char **error_msg);
4654
apr_status_tDSOLOCALjson_cleanup(modsec_rec*msr);
4755

4856
#endif
57+
#endif

‎apache2/msc_reqbody.c‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,19 @@ apr_status_t modsecurity_request_body_start(modsec_rec *msr, char **error_msg) {
128128
}
129129
}
130130
elseif (strcmp(msr->msc_reqbody_processor,"JSON")==0) {
131+
#ifdefWITH_YAJL
131132
if (json_init(msr,&my_error_msg)<0) {
132133
*error_msg=apr_psprintf(msr->mp,"JSON parsing error (init): %s",my_error_msg);
133134
msr->msc_reqbody_error=1;
134135
msr->msc_reqbody_error_msg=my_error_msg;
135136
msr_log(msr,2,"%s",*error_msg);
136137
}
138+
#else
139+
*error_msg=apr_psprintf(msr->mp,"JSON support was not enabled");
140+
msr->msc_reqbody_error=1;
141+
msr->msc_reqbody_error_msg=my_error_msg;
142+
msr_log(msr,2,"%s",*error_msg);
143+
#endif
137144
}
138145
elseif (strcmp(msr->msc_reqbody_processor,"URLENCODED")==0) {
139146
/* Do nothing, URLENCODED processor does not support streaming yet. */
@@ -356,13 +363,20 @@ apr_status_t modsecurity_request_body_store(modsec_rec *msr,
356363
/* Increase per-request data length counter. */
357364
msr->msc_reqbody_no_files_length+=length;
358365

359-
/* Process data as XML. */
366+
/* Process data as JSON. */
367+
#ifdefWITH_YAJL
360368
if (json_process_chunk(msr,data,length,&my_error_msg)<0) {
361369
*error_msg=apr_psprintf(msr->mp,"JSON parsing error: %s",my_error_msg);
362370
msr->msc_reqbody_error=1;
363371
msr->msc_reqbody_error_msg=*error_msg;
364372
msr_log(msr,2,"%s",*error_msg);
365373
}
374+
#else
375+
*error_msg=apr_psprintf(msr->mp,"JSON support was not enabled");
376+
msr->msc_reqbody_error=1;
377+
msr->msc_reqbody_error_msg=*error_msg;
378+
msr_log(msr,2,"%s",*error_msg);
379+
#endif
366380
}
367381
elseif (strcmp(msr->msc_reqbody_processor,"URLENCODED")==0) {
368382
/* Increase per-request data length counter. */
@@ -622,13 +636,22 @@ apr_status_t modsecurity_request_body_end(modsec_rec *msr, char **error_msg) {
622636
}
623637
}
624638
elseif (strcmp(msr->msc_reqbody_processor,"JSON")==0) {
639+
#ifdefWITH_YAJL
625640
if (json_complete(msr,&my_error_msg)<0) {
626641
*error_msg=apr_psprintf(msr->mp,"JSON parser error: %s",my_error_msg);
627642
msr->msc_reqbody_error=1;
628643
msr->msc_reqbody_error_msg=*error_msg;
629644
msr_log(msr,2,"%s",*error_msg);
630645
return-1;
631646
}
647+
#else
648+
*error_msg=apr_psprintf(msr->mp,"JSON support was not enabled");
649+
msr->msc_reqbody_error=1;
650+
msr->msc_reqbody_error_msg=*error_msg;
651+
msr_log(msr,2,"%s",*error_msg);
652+
return-1;
653+
#endif
654+
632655
}
633656
elseif (strcmp(msr->msc_reqbody_processor,"URLENCODED")==0) {
634657
returnmodsecurity_request_body_end_urlencoded(msr,error_msg);

‎build/find_yajl.m4‎

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
dnl Check for YAJL Libraries
2+
dnl CHECK_YAJL(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
3+
dnl Sets:
4+
dnl YAJL_CFLAGS
5+
dnl YAJL_LDADD
6+
dnl YAJL_LDFLAGS
7+
dnl YAJL_LIBS
8+
9+
AC_DEFUN([CHECK_YAJL],
10+
[dnl
11+
12+
AC_REQUIRE([PKG_PROG_PKG_CONFIG])
13+
14+
YAJL_CONFIG=""
15+
YAJL_VERSION=""
16+
YAJL_CFLAGS=""
17+
YAJL_CPPFLAGS=""
18+
YAJL_LDADD=""
19+
YAJL_LDFLAGS=""
20+
YAJL_CONFIG=${PKG_CONFIG}
21+
YAJL_PKGNAMES="yajl2 yajl"
22+
YAJL_SONAMES="so la sl dll dylib"
23+
24+
AC_ARG_WITH(
25+
yajl,
26+
[AC_HELP_STRING([--with-yajl=PATH],[Path to yajl prefix or config script])]
27+
,,with_yajl=yes)
28+
29+
AS_CASE(["${with_yajl}"],
30+
[no],[test_paths=],
31+
[yes],[test_paths="/usr/local/libyajl /usr/local/yajl /usr/local /opt/libyajl /opt/yajl /opt /usr"],
32+
[test_paths="${with_yajl}"])
33+
34+
AS_IF([test "x${test_paths}" != "x"],[
35+
AC_MSG_CHECKING([for libyajl config script])
36+
for x in ${test_paths}; do
37+
dnl # Determine if the script was specified and use it directly
38+
if test ! -d "$x" -a -e "$x"; then
39+
YAJL_CONFIG=$x
40+
break
41+
fi
42+
43+
dnl # Try known config script names/locations
44+
for y in $YAJL_CONFIG; do
45+
if test -e "${x}/bin/${y}"; then
46+
YAJL_CONFIG="${x}/bin/${y}"
47+
yajl_config="${YAJL_CONFIG}"
48+
break
49+
elif test -e "${x}/${y}"; then
50+
YAJL_CONFIG="${x}/${y}"
51+
yajl_config="${YAJL_CONFIG}"
52+
break
53+
fi
54+
done
55+
if test -n "${yajl_config}"; then
56+
break
57+
fi
58+
done
59+
60+
dnl # Try known package names
61+
if test -n "${YAJL_CONFIG}"; then
62+
YAJL_PKGNAME=""
63+
for x in ${YAJL_PKGNAMES}; do
64+
if ${YAJL_CONFIG} --exists ${x}; then
65+
YAJL_PKGNAME="$x"
66+
break
67+
fi
68+
done
69+
fi
70+
71+
if test -n "${YAJL_PKGNAME}"; then
72+
AC_MSG_RESULT([${YAJL_CONFIG}])
73+
YAJL_VERSION="`${YAJL_CONFIG} ${YAJL_PKGNAME} --modversion`"
74+
if test "$verbose_output" -eq 1; thenAC_MSG_NOTICE(yajlVERSION:$YAJL_VERSION); fi
75+
YAJL_CFLAGS="`${YAJL_CONFIG} ${YAJL_PKGNAME} --cflags`"
76+
if test "$verbose_output" -eq 1; thenAC_MSG_NOTICE(yajlCFLAGS:$YAJL_CFLAGS); fi
77+
YAJL_LDADD="`${YAJL_CONFIG} ${YAJL_PKGNAME} --libs-only-l`"
78+
if test "$verbose_output" -eq 1; thenAC_MSG_NOTICE(yajlLDADD:$YAJL_LDADD); fi
79+
YAJL_LDFLAGS="`${YAJL_CONFIG} ${YAJL_PKGNAME} --libs-only-L --libs-only-other`"
80+
if test "$verbose_output" -eq 1; thenAC_MSG_NOTICE(yajlLDFLAGS:$YAJL_LDFLAGS); fi
81+
else
82+
AC_MSG_RESULT([no])
83+
84+
dnl Hack to just try to find the lib and include
85+
AC_MSG_CHECKING([for yajl install])
86+
for x in ${test_paths}; do
87+
for y in ${YAJL_SONAMES}; do
88+
if test -e "${x}/libyajl.${y}"; then
89+
yajl_lib_path="${x}/"
90+
yajl_lib_name="yajl"
91+
break
92+
else
93+
yajl_lib_path=""
94+
yajl_lib_name=""
95+
fi
96+
done
97+
if test -n "$yajl_lib_path"; then
98+
break
99+
fi
100+
done
101+
for x in ${test_paths}; do
102+
if test -e "${x}/include/yajl.h"; then
103+
yajl_inc_path="${x}/include"
104+
break
105+
elif test -e "${x}/yajl.h"; then
106+
yajl_inc_path="${x}"
107+
break
108+
fi
109+
110+
dnl # Check some sub-paths as well
111+
for yajl_pkg_name in ${yajl_lib_name} ${YAJL_PKGNAMES}; do
112+
if test -e "${x}/include/${yajl_pkg_name}/yajl.h"; then
113+
yajl_inc_path="${x}/include"
114+
break
115+
elif test -e "${x}/${yajl_pkg_name}/yajl.h"; then
116+
yajl_inc_path="${x}"
117+
break
118+
else
119+
yajl_inc_path=""
120+
fi
121+
done
122+
if test -n "$yajl_inc_path"; then
123+
break
124+
fi
125+
done
126+
if test -n "${yajl_lib_path}" -a -n "${yajl_inc_path}"; then
127+
YAJL_CONFIG=""
128+
AC_MSG_RESULT([${yajl_lib_path} ${yajl_inc_path}])
129+
YAJL_VERSION="2"
130+
YAJL_CFLAGS="-I${yajl_inc_path}"
131+
YAJL_LDADD="-l${yajl_lib_name}"
132+
YAJL_LDFLAGS="-L${yajl_lib_path}"
133+
else
134+
YAJL_VERSION=""
135+
AC_MSG_RESULT([no])
136+
fi
137+
fi
138+
139+
])
140+
141+
YAJL_LIBS=${YAJL_LDADD}
142+
AC_SUBST(YAJL_CFLAGS)
143+
AC_SUBST(YAJL_LDADD)
144+
AC_SUBST(YAJL_LIBS)
145+
AC_SUBST(YAJL_LDFLAGS)
146+
if test -z "${YAJL_VERSION}"; then
147+
ifelse([$2], ,AC_MSG_NOTICE([optional yajl library not found]),$2)
148+
else
149+
AC_MSG_NOTICE([using yajl v${YAJL_VERSION}])
150+
YAJL_CFLAGS="-DWITH_YAJL ${YAJL_CFLAGS}"
151+
ifelse([$1], , ,$1)
152+
fi
153+
])

‎configure.ac‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,8 @@ CHECK_CURL()
699699
fi
700700

701701
# Check for YAJL libs (for JSON body processor)
702-
AC_SEARCH_LIBS([yajl_alloc],[yajl])
702+
CHECK_YAJL()
703+
#AC_SEARCH_LIBS([yajl_alloc], [yajl])
703704

704705
AC_CONFIG_FILES([Makefile])
705706
AC_CONFIG_FILES([tools/Makefile])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp