Java on AIX modifying LIBPATH

D

dinrat

Hi
I have a java program which launches another process (an
executable). Now it appears that java 1.4.2 is not passing correct
environment to the executable, it is removing all occurences of
/usr/lib from LIBPATH before passing it to the executable. This is
resulting in large load time for my binary. Does anyone know if this
modifying the LIBPATH thing is a feature for java on AIX and why? Also
I tried with java 1.3.1 and that passes the correct LIBPATH.

Thanks
Dinesh
 
H

Hajo Ehlers

Hi
I have a java program which launches another process (an
executable). Now it appears that java 1.4.2 is not passing correct
environment to the executable, it is removing all occurences of
/usr/lib from LIBPATH before passing it to the executable. This is
resulting in large load time for my binary. Does anyone know if this
modifying the LIBPATH thing is a feature for java on AIX and why? Also
I tried with java 1.3.1 and that passes the correct LIBPATH.

As i remember from reading man ksh:
the ksh is removing any LIBPATH statement during initial execution. You
must set the Libpath in the .profile or even .kshrc ( If ENV is set to
~/.kshrc ) or in any start script for an application.
The reason for this is: ksh is an setuid-programm and a existing
LIB-Path can be a security issue.

Simple test:
Set LIBPATH in the /etc/environment or even /etc/profile
Relogin to the machine with a user account who has a ksh-shell by
default and echo $LIBPATH

A test on AIX 5.1 showed:
LIBPATH for ksh-user is removed
LIBPATH for bash-user is still set


hth
Hajo

P.S I do not know the behaviour of non-interactive scripts.
 
D

dinrat

Thanks for the information ! It does not seem to be related to shell. I
have the LIBPATH set in my environment properly. Besides I tried to get
java.library.path system property from my java code and that is same as
LIBPATH in the shell but when the process is spawned that does not get
the correct LIBPATH. I tried it in csh/ bash and ksh.

Dinesh
 
H

Hajo Ehlers

Thanks for the information ! It does not seem to be related to shell. I
have the LIBPATH set in my environment properly. Besides I tried to get
java.library.path system property from my java code and that is same as
LIBPATH in the shell but when the process is spawned that does not get
the correct LIBPATH. I tried it in csh/ bash and ksh.

Uups, Sorry my mind has been on another thread. But please read in
the thread 'LIBPATH in 5.3L'

The point is: >..then the process is spawned that does not get the
correct LIBPATH.

The LIBPATH will be unset if the process you spawn have more privilege
then the calling process

hth
Hajo
 
R

Roedy Green

I have a java program which launches another process (an
executable). Now it appears that java 1.4.2 is not passing correct
environment to the executable, it is removing all occurences of
/usr/lib from LIBPATH before passing it to the executable.

You might want to track down where the pruning is occurring.
Dump your environment just prior to launching java.exe
dump it just prior to exec with System.getEnv.

Exec has a feature for you to provide your own set Environment.
 
D

dinrat

I did try priniting the environment, in the shell its fine. From my
java code if I get java.library.path System property then its fine.
Now with java 1.4.x System.getEnv() API is deprecated so I cannot get
LIBPATH environment variable value. In my spawned process everything
from original LIBPATH is present except for /usr/lib, /lib etc (even
multiple occurences of /usr/lib are removed). So someone is actually
processing the LIBPATH to remove such paths and I doubt its the JNI
implementation of Runtime.exec() API which is doing this. If I pass the
environment through Runtime.exec(command, envp) API it reaches my
spawned native process fine but that would mean passing environment to
java code thru java -DLIBPATH=xxx... since System.getEnv() is
deprecated.

Dinesh
 
D

dinrat

Thanks a lot for all your help and suggestions!!

I could find the fix, I was using java 1.4.2 GA version but there have
been number of releases after that and in 1.4.2.4 it works fine. So
upgrading to new install would do.

Dinesh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top