1

I've installed a program, Player, and am now trying to run the player command. The player requires a .cfg file as input, e.g

player create.cfg

I notice that I am able to run the above command fine as a normal user, but when I run it as root,

sudo player create.cfg

I get the following error:

error while loading shared libraries: libplayerdrivers.so.3.0: cannot open shared object file: No such file or directory

My question is, why would the command work when running it as a normal user, but not when running it as a root user? I would understand if it were the other way round. What gives?

More details

I know the error usually means the LD_LIBRARY_PATH is not set right. The shared object in question is in /usr/local/lib, so I put the command

EXPORT LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

in my .bashrc file and sourced it. But running the player command with sudo still fails to find it.

Doing ls -l /usr/local/lib | grep libplayerdrivers gives the following output:

lrwxrwxrwx 1 root root 23 Jun 27 16:34 libplayerdrivers.so -> libplayerdrivers.so.3.0
lrwxrwxrwx 1 root root 25 Jun 27 16:28 libplayerdrivers.so.3.0 -> libplayerdrivers.so.3.0.2
-rw-r--r-- 1 root root 3042066 Jun 27 16:28 libplayerdrivers.so.3.0.2
maditya
  • 8,626
  • 2
  • 28
  • 28

1 Answers1

0

sudo overwrites LD_LIBRARY_PATH, because it is a security risk.

AMADANON Inc.
  • 5,753
  • 21
  • 31
  • You're right, I can confirm that when I `sudo su;` and then `echo $LD_LIBRARY_PATH` the output is blank. So what's the way around this so that I can run both normally and as root? Should I put a symbolic link in /usr/lib that points to the .so in /usr/local/lib? – maditya Jun 27 '13 at 22:14
  • Also could you elaborate on what kinds of security risks occur, or point me to some info? – maditya Jun 27 '13 at 22:16
  • `su` does things with the environment as well - `sudo bash` would be the equivalent. I suggest you run `sudo bash`, then work if setting LD_LIBRARY_PATH solves your problem. If it does, write a bash script (OWNED BY ROOT, not writable by anyone else!) that sets the variables as needed, then runs the program you want. – AMADANON Inc. Jun 27 '13 at 22:21
  • This is interesting. Thank you for your answer! – maditya Jun 28 '13 at 02:27