I have a Linux application that uses the libsctp.so library. When I run it as root, it runs fine.
But when I run it as an ordinary user, it gives the following error:
error while loading shared libraries: libsctp.so.1: cannot open shared object file: No such file or directory
But, when I do ldd as ordinary user, it is able to see the library:
[sanjeev@devtest6 src]$ ldd myapp
... ... libsctp.so.1 => /usr/local/lib/libsctp.so.1 (0x00d17000)
[sanjeev@devtest6 src]$ ls -lL /usr/local/lib/libsctp.so.1
-rwxrwxrwx 1 root root 27430 2009-06-29 11:26 /usr/local/lib/libsctp.so.1
[sanjeev@devtest6 src]$
What could be wrong? How is the ldd is able to find libsctp.so, but when actually running the app, it is not able to find the same library?
EDIT: Just observed that this problem appears only if setuid bit is set for myapp.
I had the same exception on Ubuntu 18.04, after executing the following code:
SctpServerChannel s = SctpServerChannel.open();
The issue was solved after running:
sudo apt-get install libsctp1
Fixed the problem. I added a new file in /etc/ld.so.conf.d with the followng name:
libsctp.so.1.conf
The contents of libsctp.so.1.conf is as follows:
/usr/local/lib/
And then ran
/sbin/ldconfig
, after which my app ran successfully.
Explanation: Since the setuid bit was set, the program is executed as root, for whom LD_LIBRARY_PATH is not available. Hence it is not able to find libsctp.so. I was not aware of this because when I login as root, .bashrc gets executed and LD_LIBRARY_PATH becomes available.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With