Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a Tomcat webapp that needs LD_LIBRARY_PATH to be set.

I'm using RHEL6 and Tomcat6 (from yum package manager), the webapp is called adore-djatoka.

I'm starting tomcat by using a supplied script that exports a number of environment variables, but it appears that LD_LIBRARY_PATH is being unset, I think this is a security feature, as the init script is run by user "root" but tomcat is running as "tomcat".

When I restart tomcat I see the following line in the logfile "djatoka.log"

2013-01-04/10:25:04.118/EST [main] DEBUG envParams: LD_LIBRARY_PATH=null | null/kdu_compress

Which I read as telling me that the app is expecting LD_LIBRARY_PATH to be set, but finds it to be null, and hence it'll look for kdu_compress in the directory null/.

I have littered the startup script with echo so I can see that LD_LIBRARY_PATH is being set and exported, so I'm assuming it must be being unset.

There are a couple of scripts bundled with the webapp to test it's installed correctly and they run fine from the command line, but they are very short, they simply export the environment vars (including LD_LIBRARY_PATH) and make a call to java.

I've tried adding

LD_LIBRARY_PATH="/opt/adore-djatoka-1.1/lib/Linux-x86-64"
export LD_LIBRARY_PATH

to /usr/share/tomcat6/bin/setenv.sh

I've tried adding

LD_LIBRARY_PATH="/opt/adore-djatoka-1.1/lib/Linux-x86-64"

to `/etc/tomcat6/tomcat6.conf

LD_LIBRARY_PATH is already exported in the startup script which goes on to call /etc/init.d/tomcat6 [start/stop/restart]

I'm quite new to a few subjects here, so some guidance on how to get a better idea of where to look next, or which information would be useful to post will also be appreciated. I've already read "why LD_LIBRARY_PATH is bad"

So my question is how can I start up tomcat, so that it doesn't set LD_LIBRARY_PATH to null? or how can I re-set it to what I want, after it has been set to null? or how can I stop the webapp from being dependent on it?

Cheers,

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I eventually worked-around this issue by grabbing the source of the webapp, hardcoding the required path into the relevant line, compiling and redeploying.

The path in question was simply pulled out as a string in the source, so it wasn't required that it was stored in LD_LIBRARY_PATH.

To make it more portable, I should remove the hardcoding and replace it with a call to a custom environment variable set in a config script.

This means, to the best of my knowledge, the answer to "How do I set LD_LIBRARY_PATH environment variable, after it is unset within the scope of a setuid program" is, "You can't, unless the program itself has a facility for passing in this info after execution".

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.