while I was trying to get the Apache mod_security plugin working, I starting having issue with Including 2 different libraries.

The examples required me to include libxml2 and lua 5

<em>LoadFile /usr/lib/libxml2.so
LoadFile /usr/lib/liblua.so.5.0</em>

Now when I ran a configcheck on Apache after this declaration alone, I kept getting the following error:
<em>/usr/lib/libxml2.so: wrong ELF class: ELFCLASS32</em>

So I started googling this error, and found many people that had the same error, but everyone’s solution was to recompile the library. So first off, I did not want to manually recompile anything when I have yum to do the work for me.

I started looking at the libraries that where present:

<em>root@baselogic: /etc/httpd $ la /usr/lib/libxm*
-rw-r--r-- 1 root root 1534028 Nov 18 07:44 /usr/lib/libxml2.a
lrwxrwxrwx 1 root root      17 Apr 25 03:15 /usr/lib/libxml2.so -&gt; libxml2.so.2.6.26
lrwxrwxrwx 1 root root      17 Apr 25 03:15 /usr/lib/libxml2.so.2 -&gt; libxml2.so.2.6.26
-rwxr-xr-x 1 root root 1248636 Nov 18 07:44 /usr/lib/libxml2.so.2.6.26

Then I ensured that I had the correct libraries installed via yum:
root@baselogic: /etc/httpd $ yum list libxml2
Loaded plugins: fastestmirror, priorities, security
Loading mirror speeds from cached hostfile
* rpmforge: ftp-stud.fht-esslingen.de
* base: mirror.unl.edu
* updates: mirror.raystedman.net
* centosplus: mirror.skiplink.com
* addons: mirrors.tummy.com
* extras: mirror.raystedman.net
Excluding Packages from CentOS-5 - Plus
Reducing CentOS-5 - Plus to included packages only
549 packages excluded due to repository priority protections
Installed Packages
<em><strong>libxml2.i386        2.6.26-        installed</strong></em>

<em><strong>libxml2.x86_64        2.6.26-        installed</strong></em>

Then I started seeing there where 2  versions installed, and they where both for different machine types. i386 as well as x86_64. Now I started thinking back to the other posted errors having a plugin compiled for a 32bit system while running on a 64bit system. I was running on a cloud now, and was unsure what I ws running on, so I looked at the hardware details:
<em>root@baselogic: /etc/httpd $ uname -m

I then started digging for more details on this error, and came across an unrelated posting about someone looking for their 64bit libraries in the /usr/lib64/** directory.

Lets see what I have there:

<em>root@baselogic: /etc/httpd $ la /usr/lib64/libxm*
-rw-r--r-- 1 root root 2067448 Nov 18 07:43 /usr/lib64/libxml2.a
lrwxrwxrwx 1 root root      17 Apr 25 03:16 /usr/lib64/libxml2.so -&gt; libxml2.so.2.6.26
lrwxrwxrwx 1 root root      17 Apr 25 03:16 /usr/lib64/libxml2.so.2 -&gt; libxml2.so.2.6.26
-rwxr-xr-x 1 root root 1297104 Nov 18 07:43 /usr/lib64/libxml2.so.2.6.26</em>

There is my other copy of libxml2 so I then modified my mod_security.conf to load the libraries from a different location:
<em>LoadFile /usr/<strong>lib64</strong>/libxml2.so
LoadFile /usr/<strong>lib64</strong>/liblua.so.5.0</em>

And that was the only thing I had to do to correct this issue.


Even though most examples I have found on the net refers to /usr/lib/**, be sure to know what you are running, and ensure you are trying to access the correct libraries.

This has just bee my road to rebuilding a server from the ground up, and the first time I have done this, so this has been an enlightening experience.

Mick Knutson

Java, JavaEE, J2EE, WebLogic, WebSphere, JBoss, Tomcat, Oracle, Spring, Maven, Architecture, Design, Mentoring, Instructor and Agile Consulting. http://www.baselogic.com/blog/resume

View all posts

Java / JavaEE / Spring Boot Channel

BLiNC Supporters

BLiNC Adsense