Bug 200263 - www/nginx: version 1.8.0 with modsecurity
Summary: www/nginx: version 1.8.0 with modsecurity
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Sergey A. Osokin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-17 09:47 UTC by Denys Razumov
Modified: 2015-08-10 23:50 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (osa)


Attachments
patch (164 bytes, text/plain)
2015-05-17 09:47 UTC, Denys Razumov
no flags Details
Wrong saving in MS notepad - drop slashes (167 bytes, text/plain)
2015-05-17 11:13 UTC, Denys Razumov
no flags Details
svn diff patch file (1001 bytes, patch)
2015-05-28 18:06 UTC, Denys Razumov
no flags Details | Diff
Patch (442 bytes, patch)
2015-07-01 10:52 UTC, Sergey A. Osokin
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Denys Razumov 2015-05-17 09:47:46 UTC
Created attachment 156848 [details]
patch

www/nginx error compilation with enabled modsecurity because wrong patch file extra-patch-nginx-modsecurity-configure
my fix to this is issue in attach and below
add this text

12c12
 @@ -14715,10 +14715,10 @@
---
 @@ -14715,10 +14715,11 @@
17a18
 +    LUA_LDADD=`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-l  sed 'slua-5.1-5.1lua-5.1'`

to file  /usr/ports/www/nginx/files/patch_extra-patch-nginx-modsecurity-configure
Comment 1 Denys Razumov 2015-05-17 11:13:05 UTC
Created attachment 156850 [details]
Wrong saving in MS notepad - drop slashes

Wrong saving in MS notepad - drop slashes
Comment 2 Sergey A. Osokin freebsd_committer freebsd_triage 2015-05-17 18:11:09 UTC
Hi Denys,

could you please run the 'svn diff' command against the current version of www/nginx port and attach a patch to this bug report.

Thanks in advance.
Comment 3 Denys Razumov 2015-05-19 06:32:12 UTC
#svn add /usr/ports/www/nginx/files/patch_extra-patch-nginx-modsecurity-configure
A         www/nginx/files/patch_extra-patch-nginx-modsecurity-configure
#svn diff
Index: www/nginx/files/patch_extra-patch-nginx-modsecurity-configure
===================================================================
--- www/nginx/files/patch_extra-patch-nginx-modsecurity-configure       (revision 0)
+++ www/nginx/files/patch_extra-patch-nginx-modsecurity-configure       (working copy)
@@ -0,0 +1,6 @@
+12c12
+< @@ -14715,10 +14715,10 @@
+---
+> @@ -14715,10 +14715,11 @@
+17a18
+> +    LUA_LDADD="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-l | sed 's/lua-5.1-5.1/lua-5.1/'`"

Property changes on: www/nginx/files/patch_extra-patch-nginx-modsecurity-configure
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Comment 4 Denys Razumov 2015-05-19 07:02:50 UTC
New version of patch(working version in port tree)
# svn diff
Index: files/extra-patch-nginx-modsecurity-configure
===================================================================
--- files/extra-patch-nginx-modsecurity-configure       (revision 386738)
+++ files/extra-patch-nginx-modsecurity-configure       (working copy)
@@ -9,12 +9,13 @@
    *) :
      test_paths="${with_lua}" ;;
  esac
-@@ -14715,10 +14715,10 @@
+@@ -14715,10 +14715,11 @@
      LUA_CFLAGS="`${LUA_CONFIG} ${LUA_PKGNAME} --cflags`"
      if test "$verbose_output" -eq 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: lua CFLAGS: $LUA_CFLAGS" >&5
  $as_echo "$as_me: lua CFLAGS: $LUA_CFLAGS" >&6;}; fi
 -    LUA_LDADD="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-l`"
 +    LUA_LDADD="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-l | sed 's/lua/lua-5.1/'`"
++    LUA_LDADD="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-l | sed 's/lua-5.1-5.1/lua-5.1/'`"
      if test "$verbose_output" -eq 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: lua LDADD: $LUA_LDADD" >&5
  $as_echo "$as_me: lua LDADD: $LUA_LDADD" >&6;}; fi
 -    LUA_LDFLAGS="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-L --libs-only-other`"
Comment 5 Denys Razumov 2015-05-28 18:06:58 UTC
Created attachment 157228 [details]
svn diff patch file
Comment 6 Sergey A. Osokin freebsd_committer freebsd_triage 2015-05-28 22:43:56 UTC
I've just applied the patch and build has been failed:
...
libtool: link: cc -shared  -fPIC -DPIC  .libs/mod_security2_la-acmp.o .libs/mod_security2_la-apache2_config.o .libs/mod_security2_la-apache2_io.o .libs/mod_security2_la-apache2_util.o libinjection/.libs/mod_security2_la-libinjection_html5.o libinjection/.libs/mod_security2_la-libinjection_sqli.o libinjection/.libs/mod_security2_la-libinjection_xss.o .libs/mod_security2_la-mod_security2.o .libs/mod_security2_la-modsecurity.o .libs/mod_security2_la-msc_status_engine.o .libs/mod_security2_la-msc_crypt.o .libs/mod_security2_la-msc_geo.o .libs/mod_security2_la-msc_gsb.o .libs/mod_security2_la-msc_json.o .libs/mod_security2_la-msc_logging.o .libs/mod_security2_la-msc_lua.o .libs/mod_security2_la-msc_multipart.o .libs/mod_security2_la-msc_parsers.o .libs/mod_security2_la-msc_pcre.o .libs/mod_security2_la-msc_release.o .libs/mod_security2_la-msc_remote_rules.o .libs/mod_security2_la-msc_reqbody.o .libs/mod_security2_la-msc_tree.o .libs/mod_security2_la-msc_unicode.o .libs/mod_security2_la-msc_util.o .libs/mod_security2_la-msc_xml.o .libs/mod_security2_la-persist_dbm.o .libs/mod_security2_la-re_actions.o .libs/mod_security2_la-re.o .libs/mod_security2_la-re_operators.o .libs/mod_security2_la-re_tfns.o .libs/mod_security2_la-re_variables.o   -Wl,-rpath -Wl,/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib -lcrypt -lpthread -L/usr/lib -L/usr/local/lib -L/usr/local/lib/db5 -ldb-5.3 /usr/local/lib/libgdbm.so -lexpat -lapr-1 -laprutil-1 -lcurl -lxml2 -lz -llua -lm -lpcre -lyajl  -O2 -Wl,-R/usr/local/lib   -Wl,-soname -Wl,mod_security2.so -o .libs/mod_security2.so
/usr/bin/ld: cannot find -llua
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1

Stop.
make[4]: stopped in /opt/ports/www/nginx/work/modsecurity-2.9.0/apache2
*** Error code 1
Comment 7 Denys Razumov 2015-06-15 19:44:08 UTC
(In reply to Sergey A. Osokin from comment #6)
maybe lua doesn't installed in your system
   /usr/bin/ld: cannot find -llua
I install nginx with mod_lua
Comment 8 Denys Razumov 2015-06-18 06:49:25 UTC
(In reply to Sergey A. Osokin from comment #6)
I was tested my patch again and all is alright.
______
nginx version: nginx/1.8.0
built with OpenSSL 1.0.1j-freebsd 15 Oct 2014
TLS SNI support enabled
configure arguments: --prefix=/usr/local/etc/nginx --with-cc-opt='-I /usr/local/include' --with-ld-opt='-L /usr/local/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --sbin-path=/usr/local/sbin/nginx --pid-path=/var/run/nginx.pid --error-log-path=/var/log/nginx-error.log --user=www --group=www --with-file-aio --with-ipv6 --with-google_perftools_module --http-client-body-temp-path=/var/tmp/nginx/client_body_temp --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi_temp --http-proxy-temp-path=/var/tmp/nginx/proxy_temp --http-scgi-temp-path=/var/tmp/nginx/scgi_temp --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi_temp --http-log-path=/var/log/nginx-access.log --add-module=/usr/ports/www/nginx/work/nginx_accept_language_module-2f69842 --add-module=/usr/ports/www/nginx/work/nginx-accesskey-2.0.3 --with-http_addition_module --add-module=/usr/ports/www/nginx/work/nginx-http-auth-digest-bd1c86a --add-module=/usr/ports/www/nginx/work/nginx-auth-ldap-928856aa95 --add-module=/usr/ports/www/nginx/work/ngx_http_auth_pam_module-1.2 --with-http_auth_request_module --add-module=/usr/ports/www/nginx/work/ngx_cache_purge-2.3 --add-module=/usr/ports/www/nginx/work/echo-nginx-module-0.57 --add-module=/usr/ports/www/nginx/work/headers-more-nginx-module-0.26 --with-http_dav_module --add-module=/usr/ports/www/nginx/work/nginx-dav-ext-module-0.0.3 --add-module=/usr/ports/www/nginx/work/nginx-eval-module-1.0.3 --add-module=/usr/ports/www/nginx/work/ngx-fancyindex-0.3.4 --add-module=/usr/ports/www/nginx/work/nginx-http-footer-filter-1.2.2 --with-http_flv_module --with-http_geoip_module --with-http_gzip_static_module --with-http_gunzip_module --with-http_image_filter_module --add-module=/usr/ports/www/nginx/work/nginx_mogilefs_module-1.0.4 --add-module=/usr/ports/www/nginx/work/nginx_mod_h264_streaming-2.2.7 --add-module=/usr/ports/www/nginx/work/nginx-notice-3c95966 --with-http_perl_module --add-module=/usr/ports/www/nginx/work/nginx_http_push_module-0.692 --add-module=/usr/ports/www/nginx/work/nginx-push-stream-module-0.3.5 --with-http_random_index_module --with-http_realip_module --add-module=/usr/ports/www/nginx/work/ngx_http_redis-0.3.7 --add-module=/usr/ports/www/nginx/work/ngx_http_response-0.3 --add-module=/usr/ports/www/nginx/work/ngx_http_substitutions_filter_module-0.6.2 --with-http_secure_link_module --with-http_stub_status_module --with-http_sub_module --add-module=/usr/ports/www/nginx/work/nginx-upload-module-aba1e3f34c --add-module=/usr/ports/www/nginx/work/nginx-upload-progress-module-0.9.0 --add-module=/usr/ports/www/nginx/work/nginx_upstream_fair-20090923 --add-module=/usr/ports/www/nginx/work/nginx-goodies-nginx-sticky-module-ng-c825ea7c5c91/ --with-http_xslt_module --add-module=/usr/ports/www/nginx/work/mod_zip-1.1.6 --add-module=/usr/ports/www/nginx/work/drizzle-nginx-module-0.1.8 --add-module=/usr/ports/www/nginx/work/ngx_devel_kit-0.2.19 --add-module=/usr/ports/www/nginx/work/encrypted-session-nginx-module-0.03 --add-module=/usr/ports/www/nginx/work/nginx-gridfs-0.8 --add-module=/usr/ports/www/nginx/work/nginx-let-module-0.0.4 --add-module=/usr/ports/www/nginx/work/lua-nginx-module-0.9.15 --add-module=/usr/ports/www/nginx/work/memc-nginx-module-0.15 --add-module=/usr/ports/www/nginx/work/modsecurity-2.9.0/nginx/modsecurity --add-module=/usr/ports/www/nginx/work/naxsi-core-0.50/naxsi_src --with-pcre --add-module=/usr/ports/www/nginx/work/passenger-5.0.10/ext/nginx --add-module=/usr/ports/www/nginx/work/ngx_postgres-1.0rc5-1-g49855a0 --add-module=/usr/ports/www/nginx/work/rds-csv-nginx-module-0.05 --add-module=/usr/ports/www/nginx/work/rds-json-nginx-module-0.13 --add-module=/usr/ports/www/nginx/work/redis2-nginx-module-0.11 --add-module=/usr/ports/www/nginx/work/nginx-rtmp-module-1.1.7 --add-module=/usr/ports/www/nginx/work/set-misc-nginx-module-0.28 --add-module=/usr/ports/www/nginx/work/nginx-sflow-module-0.9.7 --add-module=/usr/ports/www/nginx/work/ngx_slowfs_cache-1.10 --add-module=/usr/ports/www/nginx/work/ngx_small_light-0.6.9 --add-module=/usr/ports/www/nginx/work/srcache-nginx-module-0.29 --add-module=/usr/ports/www/nginx/work/nginx-statsd-b756a12 --add-module=/usr/ports/www/nginx/work/nginx_udplog_module-1.0.0 --add-module=/usr/ports/www/nginx/work/nginx-x-rid-header-0daa3cc --add-module=/usr/ports/www/nginx/work/xss-nginx-module-0.04 --with-threads --with-http_ssl_module --add-module=/usr/ports/www/nginx/work/array-var-nginx-module-0.03 --add-module=/usr/ports/www/nginx/work/form-input-nginx-module-0.07 --add-module=/usr/ports/www/nginx/work/iconv-nginx-module-0.10
______
root@router:/usr/ports/www/nginx # svnlite diff
Index: files/extra-patch-nginx-modsecurity-configure
===================================================================
--- files/extra-patch-nginx-modsecurity-configure       (revision 389901)
+++ files/extra-patch-nginx-modsecurity-configure       (working copy)
@@ -9,12 +9,13 @@
    *) :
      test_paths="${with_lua}" ;;
  esac
-@@ -14715,10 +14715,10 @@
+@@ -14715,10 +14715,11 @@
      LUA_CFLAGS="`${LUA_CONFIG} ${LUA_PKGNAME} --cflags`"
      if test "$verbose_output" -eq 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: lua CFLAGS: $LUA_CFLAGS" >&5
  $as_echo "$as_me: lua CFLAGS: $LUA_CFLAGS" >&6;}; fi
 -    LUA_LDADD="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-l`"
 +    LUA_LDADD="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-l | sed 's/lua/lua-5.1/'`"
++    LUA_LDADD="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-l | sed 's/lua-5.1-5.1/lua-5.1/'`"
      if test "$verbose_output" -eq 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: lua LDADD: $LUA_LDADD" >&5
  $as_echo "$as_me: lua LDADD: $LUA_LDADD" >&6;}; fi
 -    LUA_LDFLAGS="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-L --libs-only-other`"
_____

In my system installed luajit
root@router:/usr/ports/www/nginx # pkg info | grep lua
luajit-2.0.4                   Just-In-Time Compiler for Lua
Comment 9 Sergey A. Osokin freebsd_committer freebsd_triage 2015-06-20 21:40:32 UTC
There three lua-specific packages are installed on my laptop:

% pkg info | grep lua
lua-5.1.5_6                    Small, compilable scripting language providing easy access to C code
lua52-5.2.4                    Small, compilable scripting language providing easy access to C code
luajit-2.0.4                   Just-In-Time Compiler for Lua
Comment 10 Denys Razumov 2015-06-21 08:49:24 UTC
(In reply to Sergey A. Osokin from comment #9)
Show your config options of nginx, please
Comment 11 Sergey A. Osokin freebsd_committer freebsd_triage 2015-06-21 18:25:03 UTC
% grep LUA /var/db/ports/www_nginx/options
_FILE_COMPLETE_OPTIONS_LIST=DEBUG  DEBUGLOG  FILE_AIO  IPV6  GOOGLE_PERFTOOLS  HTTP  HTTP_ADDITION  HTTP_AUTH_REQ  HTTP_CACHE  HTTP_DAV  HTTP_FLV  HTTP_GEOIP  HTTP_GZIP_STATIC  HTTP_GUNZIP_FILTER  HTTP_IMAGE_FILTER  HTTP_PERL  HTTP_RANDOM_INDEX  HTTP_REALIP  HTTP_REWRITE  HTTP_SECURE_LINK  HTTP_SSL  HTTP_STATUS  HTTP_SUB  HTTP_XSLT  MAIL  MAIL_IMAP  MAIL_POP3  MAIL_SMTP  MAIL_SSL  SPDY  THREADS  WWW  AJP  CACHE_PURGE  CLOJURE  ECHO  HEADERS_MORE  HTTP_ACCEPT_LANGUAGE  HTTP_ACCESSKEY  HTTP_AUTH_DIGEST  HTTP_AUTH_KRB5  HTTP_AUTH_LDAP  HTTP_AUTH_PAM  HTTP_DAV_EXT  HTTP_EVAL  HTTP_FANCYINDEX  HTTP_FOOTER  HTTP_MOGILEFS  HTTP_NOTICE  HTTP_PUSH  HTTP_PUSH_STREAM  HTTP_REDIS  HTTP_RESPONSE  HTTP_SUBS_FILTER  HTTP_UPLOAD  HTTP_UPLOAD_PROGRESS  HTTP_UPSTREAM_FAIR  HTTP_UPSTREAM_STICKY  HTTP_ZIP  ARRAYVAR  DRIZZLE  ENCRYPTSESSION  FORMINPUT  GRIDFS  ICONV  LET  LUA  MEMC  MODSECURITY  NAXSI  PASSENGER  POSTGRES  RDS_CSV  RDS_JSON  REDIS2  RTMP  SET_MISC  SFLOW  SLOWFS_CACHE  SMALL_LIGHT  SRCACHE  STATSD  UDPLOG  XRID_HEADER  XSS  VIDEO HTTP_MP4 HTTP_MP4_H264
OPTIONS_FILE_SET+=LUA
Comment 12 Sergey A. Osokin freebsd_committer freebsd_triage 2015-06-21 18:26:56 UTC
I mean:

% grep SECURITY /var/db/ports/www_nginx/options 
_FILE_COMPLETE_OPTIONS_LIST=DEBUG  DEBUGLOG  FILE_AIO  IPV6  GOOGLE_PERFTOOLS  HTTP  HTTP_ADDITION  HTTP_AUTH_REQ  HTTP_CACHE  HTTP_DAV  HTTP_FLV  HTTP_GEOIP  HTTP_GZIP_STATIC  HTTP_GUNZIP_FILTER  HTTP_IMAGE_FILTER  HTTP_PERL  HTTP_RANDOM_INDEX  HTTP_REALIP  HTTP_REWRITE  HTTP_SECURE_LINK  HTTP_SSL  HTTP_STATUS  HTTP_SUB  HTTP_XSLT  MAIL  MAIL_IMAP  MAIL_POP3  MAIL_SMTP  MAIL_SSL  SPDY  THREADS  WWW  AJP  CACHE_PURGE  CLOJURE  ECHO  HEADERS_MORE  HTTP_ACCEPT_LANGUAGE  HTTP_ACCESSKEY  HTTP_AUTH_DIGEST  HTTP_AUTH_KRB5  HTTP_AUTH_LDAP  HTTP_AUTH_PAM  HTTP_DAV_EXT  HTTP_EVAL  HTTP_FANCYINDEX  HTTP_FOOTER  HTTP_MOGILEFS  HTTP_NOTICE  HTTP_PUSH  HTTP_PUSH_STREAM  HTTP_REDIS  HTTP_RESPONSE  HTTP_SUBS_FILTER  HTTP_UPLOAD  HTTP_UPLOAD_PROGRESS  HTTP_UPSTREAM_FAIR  HTTP_UPSTREAM_STICKY  HTTP_ZIP  ARRAYVAR  DRIZZLE  ENCRYPTSESSION  FORMINPUT  GRIDFS  ICONV  LET  LUA  MEMC  MODSECURITY  NAXSI  PASSENGER  POSTGRES  RDS_CSV  RDS_JSON  REDIS2  RTMP  SET_MISC  SFLOW  SLOWFS_CACHE  SMALL_LIGHT  SRCACHE  STATSD  UDPLOG  XRID_HEADER  XSS  VIDEO HTTP_MP4 HTTP_MP4_H264
OPTIONS_FILE_SET+=MODSECURITY
Comment 13 Denys Razumov 2015-06-22 13:35:37 UTC
(In reply to Sergey A. Osokin from comment #12)
Please try to get clean /usr/ports dir from svn and upply my patch
I have already compile nginx in 3 servers with cleanly /usr/ports dir
Comment 14 Sergey A. Osokin freebsd_committer freebsd_triage 2015-06-25 21:10:52 UTC
Could you please explain - what does it mean cleanup ports tree?
Please be more specific, provide a command or list of commands to run.
Comment 15 Sergey A. Osokin freebsd_committer freebsd_triage 2015-06-25 21:13:09 UTC
Please attach the full build.log to this bug report.
Comment 16 Denys Razumov 2015-06-25 21:25:20 UTC
(In reply to Sergey A. Osokin from comment #15)
I don't anderstand what do you wont for me!
My patch fix pach in port tree 
string lua-5.1-5.1 to lua-5.1
in my systems directory and libriary lua-5.1-5.1 not present
Comment 17 Sergey A. Osokin freebsd_committer freebsd_triage 2015-07-01 10:52:01 UTC
Created attachment 158217 [details]
Patch

Could you try following patch.
Comment 18 Denys Razumov 2015-07-01 11:02:48 UTC
(In reply to Sergey A. Osokin from comment #17)
I dont understand what you want to do this patch!
In /usr/ports/www/nginx/file placed patch extra-patch-nginx-modsecurity-configure with following text
--- ../modsecurity-2.9.0/configure.orig 2014-04-15 16:44:15.000000000 +0400
+++ ../modsecurity-2.9.0/configure      2014-08-10 21:24:00.000000000 +0400
@@ -14664,7 +14664,7 @@
   no) :
     test_paths= ;; #(
   yes) :
-    test_paths="/usr/local/liblua /usr/local/lua /usr/local /opt/liblua /opt/lua /opt /usr" ;; #(
+    test_paths="%%PREFIX%%/liblua %%PREFIX%%/lua %%PREFIX%% /opt/liblua /opt/lua /opt /usr" ;; #(
   *) :
     test_paths="${with_lua}" ;;
 esac
@@ -14715,10 +14715,11 @@
     LUA_CFLAGS="`${LUA_CONFIG} ${LUA_PKGNAME} --cflags`"
     if test "$verbose_output" -eq 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: lua CFLAGS: $LUA_CFLAGS" >&5
 $as_echo "$as_me: lua CFLAGS: $LUA_CFLAGS" >&6;}; fi
-    LUA_LDADD="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-l`"
+    LUA_LDADD="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-l | sed 's/lua/lua-5.1/'`"
     if test "$verbose_output" -eq 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: lua LDADD: $LUA_LDADD" >&5
 $as_echo "$as_me: lua LDADD: $LUA_LDADD" >&6;}; fi
-    LUA_LDFLAGS="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-L --libs-only-other`"
+    LUA_LDFLAGS="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-L --libs-only-other | sed 's/\/lua51//'`"
     if test "$verbose_output" -eq 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: lua LDFLAGS: $LUA_LDFLAGS" >&5
 $as_echo "$as_me: lua LDFLAGS: $LUA_LDFLAGS" >&6;}; fi
 else


In this text string 
+    LUA_LDADD="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-l | sed 's/lua/lua-5.1/'`"
do a wrong replacement all words lua to lua-5.1(lua-5.1 -> lua-5.1-5.1)
my patch fix this wrong replacement
Your patch not need, because in /usr/ports/www/nginx/Makefile this string presents already
# grep -rn luajit /usr/ports/www/nginx/*
/usr/ports/www/nginx/Makefile:625:LIB_DEPENDS+= libluajit-5.1.so:${PORTSDIR}/lang/luajit
/usr/ports/www/nginx/Makefile:626:CONFIGURE_ENV+=       "LUAJIT_INC=${LOCALBASE}/include/luajit-2.0"
Comment 19 Jamie Landeg-Jones 2015-07-01 12:24:20 UTC
I too discovered this recently, and not finding this bug, emailed Sergey directly.

Thanks to him for pointing me here.

Denys, you are not alone!

For info, here is the email:

Hi, I'm running 10-STABLE from 2 weeks ago, and a current ports tree.

nginx fails to compile when mod_security is enabled.

It fails trying to find liblua-5.1-5.1.so

The problem is with patch file www/nginx/files/extra-patch-nginx-modsecurity-configure

Line 16 and 17 are:

-    LUA_LDADD="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-l`"                                                                        +    LUA_LDADD="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-l | sed 's/lua/lua-5.1/'`"

This patch breaks things. I can only assume the pkg-config result used to be wrong,
but it's currently correct, giving:

2:35 [2] (19) "files" root@catflap# pkg-config lua-5.1 --libs-only-l
-llua-5.1 -lm

The sed in its current form therefore mangles the valid result, returning:
-llua-5.1-5.1 -lm

If the sed is still needed in some curcumstances, may I humbly suggest changing it
to something like:

sed -E 's/lua($| )/lua-5.1\1/'

This will still cover the case served by the patch, but won't break newer builds

cheers, Jamie
Comment 20 Jamie Landeg-Jones 2015-07-01 12:35:16 UTC
Sergey, if you can't reproduce this, I assume the pkg-config output for you is:

# pkg-config lua-5.1 --libs-only-l
-llua -lm

That result for me and Denys is:

13:30 (42) "/tmp" jamie@catflap# pkg-config lua-5.1 --libs-only-l
-llua-5.1 -lm

So the result already has "-5.1" attached to the end, so the original patch ends up producing "llua-5.1-5.1"
Comment 21 Jamie Landeg-Jones 2015-07-01 13:04:44 UTC
Reading the history, it looks like the patch from Denys alters the patchfile to do:

LUA_LDADD="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-l | sed 's/lua/lua-5.1/'`" 
LUA_LDADD="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-l | sed 's/lua-5.1-5.1/lua-5.1/'`"

Unfortunately, the second line overrides the first line, so in Sergey's case, the needed fix '-llua' -> '-llua-5.1' isn't applied, so it ends up trying to find -llua instead of -llua-5.1

The issue appears to be the command " pkg-config lua-5.1 --libs-only-l" which is returning the correct result for Denys and me, and a truncated patch for Sergey.

My small alteration should work in both cases -- only appending the "-5.1" if it's missing.

Of course, this begs the question... Why is pkg-config giving diffferent results for us?!!

My results:

13:49 (214) "android" root@lapcat# pkg info lua'*'
lua51-5.1.5_9
lua52-5.2.4
luajit-2.0.4

13:51 (217) "android" root@lapcat# ptimes | grep lua
Sun 21 Jun 2015 04:29:17 BST lang/lua52 (lua52-5.2.4)
Sun 21 Jun 2015 04:31:22 BST lang/lua51 (lua51-5.1.5_9)
Sun 21 Jun 2015 04:49:26 BST lang/luajit (luajit-2.0.4)

Sergey, note that despite running the same versions of the required lua51, mine is registered as lua51 and yours just "lua" (which is presumably wrong, because in your case, pkg-config is returning an incorrect result)

According to SVN, this change was made over a year ago, so I suspect your install is wrong
__________________________________________________________________

Revision 355360 - (show annotations) (download)
Mon May 26 15:28:28 2014 UTC (13 months ago) by bapt
File MIME type: text/plain
File size: 126 byte(s)

Replace lang/lua with the new lang/lua51

lang/lua51 is working the same way lang/lua52, chase ports using lua 5.1
Make the default lua lua52 
Make all lua ports using USES=lua

Approved by:    portmgr (implicit)
Comment 22 Denys Razumov 2015-07-01 13:13:25 UTC
(In reply to Jamie Landeg-Jones from comment #21)
In my patch first line
LUA_LDADD="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-l | sed 's/lua/lua-5.1/'`"

LUA_LDADD="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-l | sed 's/lua-5.1-5.1/lua-5.1/'`"
don't overrides second, because this two lines need to be in the patch

second line replace wrong lines with double 5.1(5.1-5.1)
on my 5 servers all compiled normaly with my patch
last version of path

--- /usr/ports/www/nginx/files/extra-patch-nginx-modsecurity-configure  (revision 390963)
+++ /usr/ports/www/nginx/files/extra-patch-nginx-modsecurity-configure  (working copy)
@@ -9,12 +9,13 @@
    *) :
      test_paths="${with_lua}" ;;
  esac
-@@ -14715,10 +14715,10 @@
+@@ -14715,10 +14715,11 @@
      LUA_CFLAGS="`${LUA_CONFIG} ${LUA_PKGNAME} --cflags`"
      if test "$verbose_output" -eq 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: lua CFLAGS: $LUA_CFLAGS" >&5
  $as_echo "$as_me: lua CFLAGS: $LUA_CFLAGS" >&6;}; fi
 -    LUA_LDADD="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-l`"
 +    LUA_LDADD="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-l | sed 's/lua/lua-5.1/'`"
++    LUA_LDADD="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-l | sed 's/lua-5.1-5.1/lua-5.1/'`"
      if test "$verbose_output" -eq 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: lua LDADD: $LUA_LDADD" >&5
  $as_echo "$as_me: lua LDADD: $LUA_LDADD" >&6;}; fi
 -    LUA_LDFLAGS="`${LUA_CONFIG} ${LUA_PKGNAME} --libs-only-L --libs-only-other`"
Comment 23 Jamie Landeg-Jones 2015-07-01 13:26:41 UTC
Second line replaces wrong line for us, yes, but it DOES override the first line, which is why your patch fails for Sergey.

Note that the second line reassigns the new result to LUA_LDADD, regardless of what the first line does.

My patch works in both cases, but as I explained, the real issue is whether the patch is needed at all, or whether Sergey has a broken build.
Comment 24 commit-hook freebsd_committer freebsd_triage 2015-08-10 12:04:17 UTC
A commit references this bug:

Author: osa
Date: Mon Aug 10 12:03:28 UTC 2015
New revision: 393858
URL: https://svnweb.freebsd.org/changeset/ports/393858

Log:
  Use luajit instead of lua for third-party modsecurity module, sort list of dependences for it.

  PR:	200263

Changes:
  head/www/nginx/Makefile
  head/www/nginx/files/extra-patch-nginx-modsecurity-configure
  head/www/nginx-devel/Makefile
  head/www/nginx-devel/files/extra-patch-nginx-modsecurity-configure
Comment 25 Sergey A. Osokin freebsd_committer freebsd_triage 2015-08-10 23:50:13 UTC
I've committed my patch, now modsecurity uses lang/luajit instead of lang/lua*.