Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to load libsctp.so for non root user

Tags:

c++

c

linux

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.

like image 813
sankoz Avatar asked Oct 15 '25 14:10

sankoz


2 Answers

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
like image 73
Paz Avatar answered Oct 18 '25 08:10

Paz


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.

like image 24
sankoz Avatar answered Oct 18 '25 06:10

sankoz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!