Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mlogc hangs and/or fails to process data #173

Closed
rcbarnett-zz opened this issue Oct 17, 2013 · 45 comments
Closed

mlogc hangs and/or fails to process data #173

rcbarnett-zz opened this issue Oct 17, 2013 · 45 comments
Assignees

Comments

@rcbarnett-zz
Copy link
Contributor

MODSEC-20: when my httpd server is down :

root@trix:/$ ps -ef | grep mlogc
root 17974 17119 0 18:14 pts/0 00:00:00 grep mlogc
18:14:04 root@trix:/$

after service httpd start

root@trix:/$ps -ef | grep mlogc
root 18097 18096 0 18:15 ? 00:00:00 /opt/mlogc/mlogc /etc/mlogc.conf
root 18099 18096 0 18:15 ? 00:00:00 /opt/mlogc/mlogc /etc/mlogc.conf
root 18122 17119 0 18:15 pts/0 00:00:00 grep mlogc
18:15:50 root@trix$

@rcbarnett-zz
Copy link
Contributor Author

Original reporter: zoroo

@rcbarnett-zz
Copy link
Contributor Author

brectanus: On my system I get this:

$ ps -ef|grep mlogc
root 15746 15745 0 09:30 ? 00:00:00 /bin/sh -c /usr/local/bin/mlogc /usr/local/apache2/conf/mlogc-console.conf
root 15747 15746 0 09:30 ? 00:00:00 /usr/local/bin/mlogc /usr/local/apache2/conf/mlogc-console.conf

$ ps -fp15745
UID PID PPID C STIME TTY TIME CMD
root 15745 1 0 09:30 ? 00:00:00 /usr/local/apache2/bin/httpd -e D

What flavor and version of bourne shell is /bin/sh on your system? On mine it is "dash", but some it may be bash, ksh, pdksh, etc.

$ ls -lad /bin/*sh
-rwxr-xr-x 1 root root 813912 2008-05-12 11:36 /bin/bash
-rwxr-xr-x 1 root root 100856 2008-03-12 04:52 /bin/dash
lrwxrwxrwx 1 root root 4 2008-07-18 17:11 /bin/rbash -> bash
lrwxrwxrwx 1 root root 4 2008-07-18 17:12 /bin/sh -> dash

You might try linking /bin/sh to bash (or another shell) and see if that helps.

@rcbarnett-zz
Copy link
Contributor Author

zoroo: if you need another information I can give :)

@ghost ghost assigned zimmerle Oct 17, 2013
@rcbarnett-zz
Copy link
Contributor Author

zoroo: $ ps -fp18096
UID PID PPID C STIME TTY TIME CMD
root 18096 1 0 Sep16 ? 00:00:01 /opt/httpd/bin/httpd

it's good ???

$ ls -lad /bin/*sh
-rwxr-xr-x 1 root root 801504 mai 24 23:18 /bin/bash
lrwxrwxrwx 1 root root 4 jui 23 10:55 /bin/csh -> tcsh
-rwxr-xr-x 1 root root 1107216 mai 24 18:46 /bin/ksh
lrwxrwxrwx 1 root root 4 jui 23 11:26 /bin/sh -> bash
-rwxr-xr-x 1 root root 352912 mar 15 2007 /bin/tcsh

bash --version
GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.

@rcbarnett-zz
Copy link
Contributor Author

brectanus: I cannot duplicate this.

ModSecurity calls an Apache API function (ap_open_piped_log()) to execute mlogc. So, the bug seems to lie within this API or, more likely, in an underlying APR/APR-Util call for your platform. What apr/apr-util are you using (httpd -V)?

I suggest you try the latest Apache httpd with the latest APU/APR-Util and see if this fixes the issue. These are working fine for me:

Linux Ubuntu 8.04.1 (hardy) x86_64 with httpd 2.2.9 with either of these sets of apr libs:

  • APR 1.2.11, APR-Util 1.2.12 (package installed)
  • APR 1.3.2, APR-Util 1.3.2 (src installed)

If the upgrade does not solve it, then I'll do some more digging.

@rcbarnett-zz
Copy link
Contributor Author

zoroo: hello,

/opt/httpd/bin/httpd -V
Server version: Apache/2.2.8 (Unix)
Server built: Sep 5 2008 10:32:20
Server's Module Magic Number: 20051115:11
Server loaded: APR 1.2.7, APR-Util 1.2.7
Compiled using: APR 1.2.7, APR-Util 1.2.7
Architecture: 64-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/opt/httpd228"
-D SUEXEC_BIN="/opt/httpd228/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"

@rcbarnett-zz
Copy link
Contributor Author

brectanus: Have you been able to try a more recent Apache and/or APR/APR-Util to see if this resolves the issue?

@rcbarnett-zz
Copy link
Contributor Author

brectanus: Dropping priority as I cannot duplicate and am no longer getting feedback.

@rcbarnett-zz
Copy link
Contributor Author

michaelcaplan: I'm working with a similar environment (centOS 5.2, custom compiled Apache 2.2.10, PHP 5.2.6, mlogc compiled from ModSecurity v2.5.7).

I'm seeing mlogc processes growing with each apache start and stop:

[root@linux-dev sloccount-2.26]# ps aux | grep mlogc
root 26306 0.0 0.2 4296 648 pts/2 S+ 13:46 0:00 grep mlogc
[root@linux-dev sloccount-2.26]# /usr/local/apache2/bin/apachectl start
[root@linux-dev sloccount-2.26]# ps aux | grep mlogc
root 26325 0.1 0.6 5984 1760 pts/2 S 13:47 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 26327 0.1 0.6 6616 1764 ? S 13:47 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 26350 0.0 0.2 4356 644 pts/2 R+ 13:47 0:00 grep mlogc
[root@linux-dev sloccount-2.26]# /usr/local/apache2/bin/apachectl stop
[root@linux-dev sloccount-2.26]# ps aux | grep mlogc
root 26325 0.0 0.6 5984 1760 pts/2 S 13:47 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 26327 0.0 0.6 6616 1764 ? S 13:47 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 26354 0.0 0.6 5052 1768 pts/2 S 13:47 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 26356 0.0 0.2 5376 644 pts/2 R+ 13:47 0:00 grep mlogc
[root@linux-dev sloccount-2.26]# /usr/local/apache2/bin/apachectl start
[root@linux-dev sloccount-2.26]# ps aux | grep mlogc
root 26325 0.0 0.6 5984 1760 pts/2 S 13:47 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 26327 0.0 0.6 6616 1764 ? S 13:47 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 26354 0.0 0.6 5052 1768 pts/2 S 13:47 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 26360 0.3 0.6 5900 1760 pts/2 S 13:47 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 26362 0.3 0.6 6652 1760 ? S 13:47 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 26385 0.0 0.2 4812 648 pts/2 S+ 13:47 0:00 grep mlogc
[root@linux-dev sloccount-2.26]# /usr/local/apache2/bin/apachectl stop
[root@linux-dev sloccount-2.26]# ps aux | grep mlogc
root 26325 0.0 0.6 5984 1760 pts/2 S 13:47 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 26327 0.0 0.6 6616 1764 ? S 13:47 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 26354 0.0 0.6 5052 1768 pts/2 S 13:47 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 26360 0.1 0.6 5900 1760 pts/2 S 13:47 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 26362 0.1 0.6 6652 1760 ? S 13:47 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 26389 0.3 0.6 4748 1760 pts/2 S 13:47 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 26404 0.0 0.2 4940 640 pts/2 R+ 13:47 0:00 grep mlogc

@rcbarnett-zz
Copy link
Contributor Author

brectanus: What APR/APR-Util is your Apache instance using (httpd -V)?

How was Apache compiled (should be at the top of your config.log where you compiled apache)?

Are you using any NFS mounts for the audit logs?

@rcbarnett-zz
Copy link
Contributor Author

michaelcaplan: # /usr/local/apache2/bin/httpd -V
Server version: Apache/2.2.10 (Unix)
Server built: Oct 23 2008 09:05:23
Server's Module Magic Number: 20051115:18
Server loaded: APR 1.3.3, APR-Util 1.3.4
Compiled using: APR 1.3.3, APR-Util 1.3.4
Architecture: 32-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/usr/local/apache2"
-D SUEXEC_BIN="/usr/local/apache2/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"

apache was configured as follows:

./configure --enable-so --with-mpm=prefork --enable-ssl --enable-rewrite --enable-unique-id --disable-include --disable-userdir --enable-deflate --with-pcre=/usr

No NSF mounts

modsecurity configured as follows:

./configure --with-apxs=/usr/local/apache2/bin/apxs --with-lua=/usr/local --with-pcre=/usr --with-apr=/usr/local/apache2 --with-apu=/usr/local/apache2

Anything else I can provide to better diagnose the problem?

@rcbarnett-zz
Copy link
Contributor Author

brectanus: Thanks. I'll build a setup as you have described and see if I can duplicate it.

@rcbarnett-zz
Copy link
Contributor Author

brectanus: I built a centos 5.2 box from scratch, built Apache httpd from source and built ModSecurity 2.5.7 from source:

$ uname -a
Linux brian-centos 2.6.18-92.el5 #1 SMP Tue Jun 10 18:49:47 EDT 2008 i686 i686 i386 GNU/Linux

$ cat /etc/redhat-release
CentOS release 5.2 (Final)

$ /usr/local/apache2/bin/httpd -V
Server version: Apache/2.2.10 (Unix)
Server built: Oct 28 2008 11:30:07
Server's Module Magic Number: 20051115:18
Server loaded: APR 1.3.3, APR-Util 1.3.4
Compiled using: APR 1.3.3, APR-Util 1.3.4
Architecture: 32-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/usr/local/apache2"
-D SUEXEC_BIN="/usr/local/apache2/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"

Here is what I did:

sudo yum install pcre-devel
sudo yum install libxml2-devel
tar zxf apr-1.3.3.tar.gz
tar zxf apr-util-1.3.4.tar.gz
tar zxf httpd-2.2.10.tar.gz
tar zxf modsecurity-apache_2.5.7.tar.gz

cd apr-1.3.3
./configure
make && sudo make install

cd ../apr-util-1.3.4
./configure --with-apr=/usr/local/apr

cd ../httpd-2.2.10
./configure --enable-so --with-mpm=prefork --enable-ssl --enable-rewrite --enable-unique-id --disable-include --disable-userdir --enable-deflate --with-pcre=/usr
make && sudo make install

cd ../modsecurity-apache_2.5.7/apache2
./configure --with-apxs=/usr/local/apache2/bin/apxs --without-lua --with-apr=/usr/local/apr/ --with-apu=/usr/local/apr
make && make test && sudo make install
make mlogc
sudo cp ../tools/mlogc /usr/local/bin
sudo chown root:root /usr/local/bin/mlogc
sudo chmod 755 /usr/local/bin/mlogc

I will attach a tarball of the config I am using (contents of /home/user/httpd_root).

This install works just fine for me. The mlogc binary is executed (and stopped) correctly and alerts are sent to the console correctly.

I get this after starting httpd:

$ sudo /usr/local/apache2/bin/apachectl -f /home/user/httpd_root/conf/httpd.conf -k start
$ ps -ef|grep 'mlogc|httpd'
root 19480 1 0 12:31 ? 00:00:00 /usr/local/apache2/bin/httpd -f /home/user/httpd_root/conf/httpd.conf -k start
root 19481 19480 0 12:31 ? 00:00:00 /usr/local/bin/mlogc /home/user/httpd_root/conf/mlogc.conf
user 19484 19480 0 12:31 ? 00:00:00 /usr/local/apache2/bin/httpd -f /home/user/httpd_root/conf/httpd.conf -k start
user 19485 19480 0 12:31 ? 00:00:00 /usr/local/apache2/bin/httpd -f /home/user/httpd_root/conf/httpd.conf -k start
user 19486 19480 0 12:31 ? 00:00:00 /usr/local/apache2/bin/httpd -f /home/user/httpd_root/conf/httpd.conf -k start
user 19487 19480 0 12:31 ? 00:00:00 /usr/local/apache2/bin/httpd -f /home/user/httpd_root/conf/httpd.conf -k start
user 19488 19480 0 12:31 ? 00:00:00 /usr/local/apache2/bin/httpd -f /home/user/httpd_root/conf/httpd.conf -k start
user 19489 19480 0 12:31 ? 00:00:00 /usr/local/apache2/bin/httpd -f /home/user/httpd_root/conf/httpd.conf -k start
user 19490 19480 0 12:31 ? 00:00:00 /usr/local/apache2/bin/httpd -f /home/user/httpd_root/conf/httpd.conf -k start
user 19491 19480 0 12:31 ? 00:00:00 /usr/local/apache2/bin/httpd -f /home/user/httpd_root/conf/httpd.conf -k start

(fixed a typo in my original comment)

@rcbarnett-zz
Copy link
Contributor Author

brectanus: Attached the httpd_root I used in my previous example. Should work if you extract to /home/user.

@rcbarnett-zz
Copy link
Contributor Author

michaelcaplan: Brian,

Thanks for the great work trying to reproduce the problem. In review of your efforts, I discovered that the OS I am having issues with mlogc is not actually centOS 5.2, but 4.7 -- the pains of not keeping dev / staging / production machines in sync. Sorry for the bad information.

I went through the same exercise of compiling on a fresh centOS 5.2 box yesterday. Without actually piping content through from apache, mlogc appears to be functioning fine. It is responsive to system signals, which was an issue on the centOS 4.7 box. My configuration on the 5.2 box differs slightly, in that I used the apr and apr-utils libs compiled by apache.

I did go back to the 4.7 box and tried to recompile against separately compiled apr and apr-utils libs, as you did. Unfortunately, this had the same effect. mlogc was unresponsive after loading, and could only be terminated with a SIGKILL.

I'm going to migrate my 4.7 box to 5.2. It appears that will solve my problems.

Thanks,

Mike

@rcbarnett-zz
Copy link
Contributor Author

mark.parsons: Brian,
I too am having the same issue below is my information from my system that I think might be helpful.

uname -a
Linux devhost 2.6.9-78.0.1.EL #1 Tue Jul 22 18:11:48 EDT 2008 i686 athlon i386 GNU/Linux

cat /etc/redhat-release
Red Hat Enterprise Linux ES release 4 (Nahant Update 7)

/usr/local/apache-2.2.9/bin/httpd -V
Server version: Apache/2.2.9 (Unix)
Server built: Jul 22 2008 10:04:01
Server's Module Magic Number: 20051115:15
Server loaded: APR 1.3.0, APR-Util 1.3.0
Compiled using: APR 1.3.0, APR-Util 1.3.0
Architecture: 32-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/usr/local/apache-2.2.9"
-D SUEXEC_BIN="/usr/local/apache-2.2.9/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"

here is what I did:

sudo yum install pcre-devel
sudo yum install libxml2-devel
tar zxvf httpd-2.2.9.tar.gz
tar zxvf modsecurity-apache_2.5.7.tar.gz

cd httpd-2.2.9
./configure --prefix=/usr/local/apache-2.2.9 --enable-authnz-ldap=shared --enable-dav=shared --enable-dav-fs=shared --enable-auth-ldap=shared --enable-ldap=shared --enable-proxy=shared --enable-rewrite=shared --enable-ssl=shared --enable-vhost-alias=shared --enable-deflate=shared --enable-unique-id=shared --with-included-apr --with-ldap --with-ldap-lib="/usr/local/openldap-2.4.8/lib" --with-ldap-include="/usr/local/openldap-2.4.8/include" --with-ssl="/usr/local/openssl-0.9.8g"
make
make install

cd ../modsecurity-apache_2.5.7/apache2
./configure --with-apxs=/usr/local/apache-2.2.9/bin/apxs --without-lua --with-apr=/usr/local/apache-2.2.9 --with-apu=/usr/local/apache-2.2.9
make
make test
make install
make mlogc
cp ../tools/mlogc /usr/local/bin
chown root:root /usr/local/bin/mlogc
chmod 7555 /usr/local/bin/mlogc

Configured httpd.conf and modsecurity and mlogc.conf

Started apache /usr/local/apache-2.2.9/bin/apachectl start

ps-ef|grep 'mlogc|httpd'
root 1698 1 0 17:09 pts/0 00:00:00 /usr/local/bin/mlogc /usr/local/etc/mlogc.conf
root 1699 1 0 17:09 ? 00:00:00 /usr/local/apache-2.2.9/bin/httpd -k start
root 1700 1699 0 17:09 ? 00:00:00 /usr/local/bin/mlogc /usr/local/etc/mlogc.conf
apache 1701 1699 0 17:09 ? 00:00:00 /usr/local/apache-2.2.9/bin/httpd -k start
apache 1702 1699 0 17:09 ? 00:00:00 /usr/local/apache-2.2.9/bin/httpd -k start
apache 1703 1699 0 17:09 ? 00:00:00 /usr/local/apache-2.2.9/bin/httpd -k start
apache 1704 1699 0 17:09 ? 00:00:00 /usr/local/apache-2.2.9/bin/httpd -k start
apache 1705 1699 0 17:09 ? 00:00:00 /usr/local/apache-2.2.9/bin/httpd -k start

Looked at where the mlgoc logs are configured to be based on /usr/local/etc/mlogc.confand I only see
mlogc-error.log

Contets of mlogc-error.log are:
[Thu Nov 06 17:09:25 2008] [3] [1698/0] ModSecurity Audit Log Collector 2.5.7 delaying startup for 1000ms
[Thu Nov 06 17:09:26 2008] [3] [1700/0] ModSecurity Audit Log Collector 2.5.7 delaying startup for 1000ms
[Thu Nov 06 17:09:26 2008] [3] [1698/0] ModSecurity Audit Log Collector 2.5.7 started.
[Thu Nov 06 17:09:27 2008] [3] [1700/0] ModSecurity Audit Log Collector 2.5.7 started.

Any help would be very much appreciated.

Thanks,
Mark

@rcbarnett-zz
Copy link
Contributor Author

brectanus: It seems to be an issue with APR/APR-Util libs. You are building httpd with included APR, but building modsecurity with the system apr (I believe). Try building with apr/apr-util from source as I did above.

tar zxf apr-1.3.3.tar.gz
tar zxf apr-util-1.3.4.tar.gz

cd apr-1.3.3
./configure
make && sudo make install

cd ../apr-util-1.3.4
./configure --with-apr=/usr/local/apr

Then make sure the httpd build s using the local apr install. Something like this (--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr):

cd httpd-2.2.9
./configure --prefix=/usr/local/apache-2.2.9 --enable-authnz-ldap=shared --enable-dav=shared --enable-dav-fs=shared --enable-auth-ldap=shared --enable-ldap=shared --enable-proxy=shared --enable-rewrite=shared --enable-ssl=shared --enable-vhost-alias=shared --enable-deflate=shared --enable-unique-id=shared --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr --with-ldap --with-ldap-lib="/usr/local/openldap-2.4.8/lib" --with-ldap-include="/usr/local/openldap-2.4.8/include" --with-ssl="/usr/local/openssl-0.9.8g"
make
make install

@rcbarnett-zz
Copy link
Contributor Author

mark.parsons: Brian,

I tried what you suggested including a new build of the latest Apache here is what I did:

cd apr-1.3.3
LDFLAGS="-L/usr/local/openldap-2.4.8/lib -L/usr/local/openssl-0.9.8g/lib" CPPFLAGS="-I/usr/local/openldap-2.4.8/include -I/usr/local/openssl-0.9.8g/include" ./configure
make
make test
make install

add /usr/local/apr/lib to /etc/ld.so.conf
ldconfig

cd ../
cd apr-util-1.3.4
LDFLAGS="-L/usr/local/openldap-2.4.8/lib -L/usr/local/openssl-0.9.8g/lib" CPPFLAGS="-I/usr/local/openldap-2.4.8/include -I/usr/local/openssl-0.9.8g/include" ./configure --with-ldap --with-ldap-lib="/usr/local/openldap-2.4.8/lib" --with-ldap-include="/usr/local/openldap-2.4.8/include" --with-apr=/usr/local/apr
make
make test
make install

ldconfig

cd httpd-2.2.10
LDFLAGS="-L/usr/local/openldap-2.4.8/lib -L/usr/local/openssl-0.9.8g/lib" CPPFLAGS="-I/usr/local/openldap-2.4.8/include -I/usr/local/openssl-0.9.8g/include" ./configure --prefix=/usr/local/apache-2.2.10 --enable-authnz-ldap=shared --enable-dav=shared --enable-dav-fs=shared --enable-auth-ldap=shared --enable-ldap=shared --enable-proxy=shared --enable-rewrite=shared --enable-ssl=shared --enable-vhost-alias=shared --enable-deflate=shared --enable-unique-id=shared --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr --with-ldap --with-ldap-lib="/usr/local/openldap-2.4.8/lib" --with-ldap-include="/usr/local/openldap-2.4.8/include" --with-ssl="/usr/local/openssl-0.9.8g"
make
make install
cd ../
cd modsecurity-apache_2.5.7
cd apache2/
LDFLAGS="-L/usr/local/openldap-2.4.8/lib -L/usr/local/openssl-0.9.8g/lib" CPPFLAGS="-I/usr/local/openldap-2.4.8/include -I/usr/local/openssl-0.9.8/include" ./configure --with-apxs=/usr/local/apache-2.2.10/bin/apxs --without-lua --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr
make && make test
make install
make mlogc
cp ../tools/mlogc /usr/local/bin/.

I am still seeing the symptoms I was seeing previously prior to this build. Below is the output of the httpd -V for the new build I did.

Server version: Apache/2.2.10 (Unix)
Server built: Nov 7 2008 11:33:25
Server's Module Magic Number: 20051115:18
Server loaded: APR 1.3.3, APR-Util 1.3.4
Compiled using: APR 1.3.3, APR-Util 1.3.4
Architecture: 32-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/usr/local/apache-2.2.10"
-D SUEXEC_BIN="/usr/local/apache-2.2.10/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"

thanks,
Mark

@rcbarnett-zz
Copy link
Contributor Author

michaelcaplan: Hi Mark,

I too saw no difference in mlogc behavior compiling against the apache http bundled apr and apr-util libs, or seperatly compiled apr and apr-util libs -- on CentOS 4.7. (See my comment above).

The only solution found to date (for an unknown reason) was to upgrade to centOS 5 (5.2 specifically) and then compile (either against the apache http bundled apr / apr-util libs or separate).

Mike

@rcbarnett-zz
Copy link
Contributor Author

brectanus: Do you see the same issue using another piped logger with Apache? Try something like this to see if the same thing happens with The =error or access log:

ErrorLog "|/bin/cat - > logs/error_log-test"
CustomLog "|/bin/cat - > logs/access_log-test" combined

Or even try cat in SecAuditLog:

SecAuditLog "|/bin/cat - > logs/modsec_audit-test"

Also check out your shell being used (usually /bin/sh, but whatever SHELL_PATH was defined to) and see if it calls fork() when the -c option is used:

strace /bin/sh -c "echo foobar"

See https://issues.apache.org/bugzilla/show_bug.cgi?id=38989 for why that is bad and what you can do, but you can try changing /bin/sh to be /bin/ksh (or /bin/pdksh) if that shell does not fork.

Other than that I am not sure what else it can be as it seems to be RedHat 4.7 and not Apache or ModSecurity.

In any case, please update the results here so others can benefit.

If it is failing for the error/access logs, then you may want to get with Red Hat support and see if there is a workaround (and post the answer here).

Thanks,
-B

@rcbarnett-zz
Copy link
Contributor Author

brectanus: Mark/Mike, Were either of you able to try my last suggestion?

@rcbarnett-zz
Copy link
Contributor Author

michaelcaplan: Hi Brian,

Sorry for not following up. I've since upgraded my development environment to Centos 5.2 and don't have a 4.7 box at my disposal for testing this out. If there is a need for this type of test, I can do it, but it won't be for about a week.

Thanks,

Mike

@rcbarnett-zz
Copy link
Contributor Author

brectanus: I'll leave it up to the others then. I too don't have time to build a 4.7 box at the moment. Thanks.

@rcbarnett-zz
Copy link
Contributor Author

mark.parsons: Brian,

I haven't had much time recently to do any further testing. I did try using SecAuditLog "|/bin/cat - > logs/modsec_audit-test" and I was able to write logs and the system did not hang and the /bin/cat process was stopped as expected when apache was stopped. I did do a strace /bin/sh -c "echo foobar" and the process did not fork. I have not had a chance to call RedHat or try changing the shell that is used. I hope to have time after the Thanksgiving holiday next week to do some testing.

Thanks,
Mark

@rcbarnett-zz
Copy link
Contributor Author

pfrederiksen: We are also having this same issue. It works in one environment, and doesn't in another. We have the exact same symptoms.

In the environment that it works:

Server version: Apache/2.0.52
Server built: Jan 7 2008 10:03:05
Server's Module Magic Number: 20020903:9
Architecture: 32-bit
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"

The environment that it doesn't work:

Server version: Apache/2.2.10 (Unix)
Server built: Oct 21 2008 07:51:36
Server's Module Magic Number: 20051115:18
Server loaded: APR 1.3.3, APR-Util 1.3.4
Compiled using: APR 1.3.3, APR-Util 1.3.4
Architecture: 32-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"

If I can give anymore information, please let me know.

@rcbarnett-zz
Copy link
Contributor Author

brectanus: Paul,

Please try the /bin/cat tests above and report back the results. This should help to indicate if it is an mlogc issue, a ModSecurity issue, or an Apache/APR issue.

Is this RedHat or CentOS? What version?

What version of ModSecurity and mlogc?

What is the exact line you are using to use mlogc (the SecAuditLog line)?

On the first machine you listed, what was the APR/APR-Util version?

Was Apache compiled with the APR included with httpd, a system installed APR, or another custom APR install (for both systems)?

thanks,
-B

@rcbarnett-zz
Copy link
Contributor Author

pfrederiksen: 1) Please try the /bin/cat tests above and report back the results. This should help to indicate if it is an mlogc issue, a ModSecurity issue, or an Apache/APR issue.
The /bin/cat test worked perfectly.

  1. Is this RedHat or CentOS? What version?

cat /etc/redhat-release

Fedora release 10.90 (Rawhide)

  1. What version of ModSecurity and mlogc?
    mod_security 2.5.7 (2.5.5 also did not work)
    mlogc reports 2.5.7 in the mlogc error log as well

This is the only entries in the error log no matter what debug level I give:
[Thu Dec 04 12:49:12 2008] [3] [3473/0] ModSecurity Audit Log Collector 2.5.7 delaying startup for 1000ms
[Thu Dec 04 12:49:13 2008] [3] [3473/0] ModSecurity Audit Log Collector 2.5.7 started.

  1. What is the exact line you are using to use mlogc (the SecAuditLog line)?
    SecAuditLog "|/usr/bin/mlogc /etc/mlogc.conf"

  2. On the first machine you listed, what was the APR/APR-Util version?
    apr-0.9.4-24.9 (on the first machine)

6)Was Apache compiled with the APR included with httpd, a system installed APR, or another custom APR install (for both systems)?
httpd-2.2.10-2.i386 from the fedora repos

@rcbarnett-zz
Copy link
Contributor Author

wayne: Hi,

I have the same problem here, except that this appears on a Debian Etch System.

Apache 2.2.11
PHP 5.2.9
ModSecurity 2.5.9

www-data@n2:/$ uname -a
Linux n2 2.6.28.7 #1 SMP Mon Mar 2 10:39:18 CET 2009 x86_64 GNU/Linux

www-data@n2:/$ dpkg --list|grep apr
ii libapr1 1.2.7-8.2 The Apache Portable Runtime Library
ii libapr1-dev 1.2.7-8.2 The Apache Portable Runtime Library - Develo
ii libaprutil1 1.2.7+dfsg-2 The Apache Portable Runtime Utility Library
ii libaprutil1-dev 1.2.7+dfsg-2 The Apache Portable Runtime Utility Library

Seems like if it's really a mlogc-Issue. mlogc just starts but does nothing actually:
root 5861 0.0 0.0 24336 2428 ? S 15:59 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 5918 0.0 0.0 24336 2428 pts/0 S 16:01 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 5922 0.0 0.0 24336 2428 pts/0 S 16:01 0:00 /usr/local/bin/mlogc /etc/mlogc.conf

n2:/var/log/mlogc# strace -p 5861
Process 5861 attached - interrupt to quit
futex(0xf54f38, FUTEX_WAIT, 2, NULL

n2:/var/log/mlogc# strace -p 5918
Process 5918 attached - interrupt to quit
futex(0x2482f38, FUTEX_WAIT, 2, NULL

n2:/var/log/mlogc# strace -p 5922
Process 5922 attached - interrupt to quit
futex(0x1816f38, FUTEX_WAIT, 2, NULL

After i restart the Apache Webserver, more mlogc-Processes are started:
root 5861 0.0 0.0 24336 2428 ? S 15:59 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 5918 0.0 0.0 24336 2428 pts/0 S 16:01 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 5922 0.0 0.0 24336 2428 pts/0 S 16:01 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 6038 0.0 0.0 24336 2428 pts/0 S 16:05 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 6042 0.0 0.0 24336 2428 pts/0 S 16:05 0:00 /usr/local/bin/mlogc /etc/mlogc.conf
root 6044 0.0 0.0 24336 2428 ? S 16:05 0:00 /usr/local/bin/mlogc /etc/mlogc.conf

If i cat my audit-Logs by hand, everything is working as expected and the entry is visible in the console:

www-data@n2:/$ strace cat /var/log/mlogc/data/index |/usr/local/bin/mlogc /etc/mlogc.conf
execve("/bin/cat", ["cat", "/var/log/mlogc/data/index"], [/* 13 vars */]) = 0
uname({sys="Linux", node="n2", ...}) = 0
brk(0) = 0x781000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1d7c59e000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=26073, ...}) = 0
mmap(NULL, 26073, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f1d7c597000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\200\305"..., 640) = 640
lseek(3, 624, SEEK_SET) = 624
read(3, "\4\0\0\0\20\0\0\0\1\0\0\0GNU\0\0\0\0\0\2\0\0\0\6\0\0\0"..., 32) = 32
fstat(3, {st_mode=S_IFREG|0755, st_size=1286104, ...}) = 0
mmap(NULL, 2344904, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f1d7c24d000
mprotect(0x7f1d7c36e000, 1161160, PROT_NONE) = 0
mmap(0x7f1d7c46e000, 98304, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x121000) = 0x7f1d7c46e000
mmap(0x7f1d7c486000, 14280, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f1d7c486000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1d7c596000
mprotect(0x7f1d7c46e000, 86016, PROT_READ) = 0
arch_prctl(ARCH_SET_FS, 0x7f1d7c5966d0) = 0
munmap(0x7f1d7c597000, 26073) = 0
brk(0) = 0x781000
brk(0x7a2000) = 0x7a2000
open("/usr/lib/locale/locale-archive", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=69693248, ...}) = 0
mmap(NULL, 69693248, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f1d77fd6000
close(3) = 0
fstat(1, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
open("/var/log/mlogc/data/index", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0770, st_size=10807, ...}) = 0
read(3, "www.domain.com 192.168.0.1 - - "..., 4096) = 4096
write(1, "www.domain.com 192.168.0.1 - - "..., 4096) = 4096
read(3, ".com 192.168.0.1 - - [27/Apr/2"..., 4096) = 4096
write(1, ".com 192.168.0.1 - - [27/Apr/2"..., 4096) = 4096
read(3, "34 - - [27/Apr/2009:15:37:35 +02"..., 4096) = 2615
write(1, "34 - - [27/Apr/2009:15:37:35 +02"..., 2615) = 2615
read(3, "", 4096) = 0
close(3) = 0
close(1) = 0
exit_group(0) = ?
Process 6187 detached

Ciao,
Werner

@rcbarnett-zz
Copy link
Contributor Author

brectanus: Werner,

It looks like mlogc is not running correctly from Apache httpd. It may be that you have compiled Apache httpd with the included libs (apr/apr-util/pcre) but compiled ModSecurity/mlogc with the system libs?

What is the output from apachectl -V (httpd -V)?

Would you mind attaching your Apache httpd config.log? Or at least the configure line showing all the options you used to compile Apache httpd?

Additionally attach the ModSecurity config.log as well.

thanks,
-B

@rcbarnett-zz
Copy link
Contributor Author

wayne: Hi Brian,

thanks for your input so far.

ln2:~# ldd /usr/local/bin/mlogc
libapr-1.so.0 => /usr/lib/libapr-1.so.0 (0x00007f22b320c000)
libcurl.so.3 => /usr/lib/libcurl.so.3 (0x00007f22b30d4000)
libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x00007f22b2fb7000)
libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x00007f22b2e32000)
libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x00007f22b2d0e000)
libcom_err.so.2 => /lib/libcom_err.so.2 (0x00007f22b2c0c000)
libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x00007f22b2b08000)
libresolv.so.2 => /lib/libresolv.so.2 (0x00007f22b29f3000)
libidn.so.11 => /usr/lib/libidn.so.11 (0x00007f22b28c2000)
libssl.so.0.9.8 => /usr/lib/libssl.so.0.9.8 (0x00007f22b277b000)
libcrypto.so.0.9.8 => /usr/lib/libcrypto.so.0.9.8 (0x00007f22b2507000)
libdl.so.2 => /lib/libdl.so.2 (0x00007f22b2404000)
libz.so.1 => /usr/lib/libz.so.1 (0x00007f22b22ee000)
libpcre.so.3 => /usr/lib/libpcre.so.3 (0x00007f22b21c9000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00007f22b20b4000)
libc.so.6 => /lib/libc.so.6 (0x00007f22b1e77000)
libuuid.so.1 => /lib/libuuid.so.1 (0x00007f22b1d74000)
librt.so.1 => /lib/librt.so.1 (0x00007f22b1c6b000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x00007f22b1b37000)
/lib64/ld-linux-x86-64.so.2 (0x00007f22b3333000)

Seems like mlogc is picking the Debian libs for apr/apr-util. What i dont understand is the following:

  • Apache and modsecurity have been build against APR/APR-UTIL provided by the Apache Source,
    if i do remove the Debian-Librarys mlogc tells me the following:

n2:~# /usr/local/bin/mlogc
/usr/local/bin/mlogc: error while loading shared libraries: libapr-1.so.0: cannot open shared object file: No such file or directory

Sure, because it uses the Debian Libs. I've also tried to add /usr/local/apache2/lib to /etc/ld.conf.so, executed ldconfig but mlogc still tries to use the debian libs (also when recompiled) :-(

thank your Brian and regards,
Werner

@rcbarnett-zz
Copy link
Contributor Author

wayne: Hi Brian,

the Apache HTTPD ist starting mlogc-processes. Here is the requested information:

n2:~# httpd -V
Server version: Apache/2.2.11 (Unix)
Server built: Mar 2 2009 14:48:46
Server's Module Magic Number: 20051115:21
Server loaded: APR 1.3.3, APR-Util 1.3.4
Compiled using: APR 1.3.3, APR-Util 1.3.4
Architecture: 64-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/usr/local/apache2"
-D SUEXEC_BIN="/usr/local/apache2/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"

$ ./configure --with-layout=Apache --enable-ssl --enable-rewrite --enable-expires --enable-headers --disable-cgi --disa
ble-asis --disable-imagemap --disable-userdir --enable-so

ModSecurity config.log will follow.

Cheers,
Werner

@rcbarnett-zz
Copy link
Contributor Author

brectanus: It does not work well to use the Apache included libs. You have system wide apr/apu libs installed:

www-data@n2:/$ dpkg --list|grep apr
ii libapr1 1.2.7-8.2 The Apache Portable Runtime Library
ii libapr1-dev 1.2.7-8.2 The Apache Portable Runtime Library - Develo
ii libaprutil1 1.2.7+dfsg-2 The Apache Portable Runtime Utility Library
ii libaprutil1-dev 1.2.7+dfsg-2 The Apache Portable Runtime Utility Library

But you compiled Apache with the included libs:

Server loaded: APR 1.3.3, APR-Util 1.3.4
Compiled using: APR 1.3.3, APR-Util 1.3.4

Mlogc may be picking up the wrong libs when run under apache. What does this give you:

ldd /path/to/mlogc

Then check further by creating a wrapper script for mlogc (use the wrapper in modsec config) that does this:

/path/to/mlogc-wrapper:

#!/bin/sh
ldd /path/to/mlogc > /tmp/mlogc-ldd.txt
exec /path/to/mlogc

And compare the ldd output from running mlogc-wrapper from the shell vs within apache.

You can try removing the Debian installed apr/apr-util packages and see if that helps (you may need to re-configure/re-make modsecurity/mlogc).

However what I would do is to keep things consistent and either:

Use the debian apr/apr-util packages and specify --with-apr=/usr --with-apr-util=/usr when configuring Apache.

OR

Compile/install your own apr/apr-util separately if you want the newer versions and then point both Apache and modsecurity to them via --with-* options.

NOTE: You may have the same issue with pcre libs.

@rcbarnett-zz
Copy link
Contributor Author

brectanus: I added these to help diagnose problems like this: MODSEC-59, MODSEC-60

@rcbarnett-zz
Copy link
Contributor Author

brectanus: Make sure you run ldconfig to update the cache after updating /etc/ld.so.conf (I think you also have the name of that file wrong above).

Did you try setting LD_LIBRARY_PATH=/usr/local/apache2/lib ?

Also, make sure you run "make clean" first.

The build may be a bit wrong for mlogc and not using the correct versions detected in the ModSecurity configure run. I have updated the build system quite a bit for 2.5.10, so you might want to try the 2.5.x branch versions of configure/Makefile.in:

https://mod-security.svn.sourceforge.net/svnroot/mod-security/m2/branches/2.5.x/apache2/

Check the apache2/mlogc-src/Makefile after the configure run and make sure the APR/APU libs are correct.

@rcbarnett-zz
Copy link
Contributor Author

wayne: Hi Brian,

Make sure you run ldconfig to update the cache after updating /etc/ld.so.conf
Yes

Did you try setting LD_LIBRARY_PATH=/usr/local/apache2/lib ?
Tried that also

I've now tried it either way. In the first run, i recompiled the Apache-Webserver with the apr/apu-libs provided by Debian as follows:
./configure --with-layout=Apache --enable-ssl --enable-rewrite --enable-expires --enable-headers --disable-cgi --disable-asis --disable-imagemap --disable-userdir --enable-unique-id --enable-so --with-apr=/usr --with-apr-util=/usr

Subsequent I've recompiled ModSecurity 2.5.9 from scratch - also with the apr/apu-libs provided by Debian as follows:
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-apr=/usr/bin/apr-1-config --with-apu=/usr/bin/apu-1-config

After that I've created mlogc:
n2:/usr/src/modsecurity-apache_2.5.9/apache2/mlogc-src# ldd /usr/local/bin/mlogc
libapr-1.so.0 => /usr/lib/libapr-1.so.0 (0x00007f8f3357c000)
libcurl.so.3 => /usr/lib/libcurl.so.3 (0x00007f8f33444000)
libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x00007f8f33327000)
libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x00007f8f331a2000)
libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x00007f8f3307e000)
libcom_err.so.2 => /lib/libcom_err.so.2 (0x00007f8f32f7c000)
libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x00007f8f32e78000)
libresolv.so.2 => /lib/libresolv.so.2 (0x00007f8f32d63000)
libidn.so.11 => /usr/lib/libidn.so.11 (0x00007f8f32c32000)
libssl.so.0.9.8 => /usr/lib/libssl.so.0.9.8 (0x00007f8f32aeb000)
libcrypto.so.0.9.8 => /usr/lib/libcrypto.so.0.9.8 (0x00007f8f32877000)
libdl.so.2 => /lib/libdl.so.2 (0x00007f8f32774000)
libz.so.1 => /usr/lib/libz.so.1 (0x00007f8f3265e000)
libpcre.so.3 => /usr/lib/libpcre.so.3 (0x00007f8f32539000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00007f8f32424000)
libc.so.6 => /lib/libc.so.6 (0x00007f8f321e7000)
libuuid.so.1 => /lib/libuuid.so.1 (0x00007f8f320e4000)
librt.so.1 => /lib/librt.so.1 (0x00007f8f31fdb000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x00007f8f31ea7000)
/lib64/ld-linux-x86-64.so.2 (0x00007f8f336a3000)

No luck, mlogc is just not sending anything to the console. If I force it "by hand" (strace cat /var/log/mlogc/data/index |/usr/local/bin/mlogc /etc/mlogc.conf ) everything is working fine. Same result If i use the APR/APU-Libs from the Apache-Source :-(

This really drives me nuts :)

regards,
Werner

@rcbarnett-zz
Copy link
Contributor Author

brectanus: Attached a patch to add more debugging and fix a locking issue. This patch will apply to 2.5.9. Please apply, re-run "make mlogc", then copy the mlogc binary to its installed location.

@rcbarnett-zz
Copy link
Contributor Author

nc: Brian's patch fixes the problem here. Thanks.

@rcbarnett-zz
Copy link
Contributor Author

nc: I'm experiencing this same issue, and have found that mlogc is hanging at the apr_global_mutex_lock(gmutex) call in transaction_log_init().

I'm adding a patch that adds a line of debugging output just prior to this call. When applied, and executed with an ErrorLogLevel of at least 4, a deadlock at this line will result in the mlogc-error.log containing the line:

Transaction initialization locking mutex...

but not the follow-up line:

Transaction initialization started.

@rcbarnett-zz
Copy link
Contributor Author

nc: Patch adding a line of debugging output to mlogc.c.

@rcbarnett-zz
Copy link
Contributor Author

brectanus: I just want to verify that when you restart Apache httpd the mlogc processes are terminated correctly (See Michael Caplan's comments above). And, is the parent process now the correct shell/httpd vs '1'?

@rcbarnett-zz
Copy link
Contributor Author

wayne: ModSecurity Config.log

@rcbarnett-zz
Copy link
Contributor Author

nc: Yes, stopping httpd stops any mlogc processes. Previously, I think, the signal thread was never started.

An mlogc process with a PID of '1' appears briefly at startup and shutdown. Other than those transient appearances, the parent process is httpd.

Thanks for the patch.

@rcbarnett-zz
Copy link
Contributor Author

brectanus: The latest patch seems to solve this issue. Please reopen if this is not the case.

@rcbarnett-zz
Copy link
Contributor Author

brectanus: If you are seeing this issue on 2.5.9, please apply the patch, re-run "make mlogc", then copy the mlogc binary to its installed location.

Apply patch from the main modsecurity-apache_2.5.9 directory as follows:

patch -p0 < /path/to/mlogc_2.5.10-dev1.diff

@rcbarnett-zz
Copy link
Contributor Author

brectanus: Reopening to remove obsolete attachments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants