Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 12-11-2012, 12:00 PM   #1
Registered: Jul 2010
Distribution: Gentoo, Debian, Mint, Xubuntu
Posts: 150

Rep: Reputation: 35
Sudo -- setting LD_LIBRARY_PATH

I need to run an application via sudo. This application needs access to libraries -- however, sudo strips LD_LIBRARY_PATH, even if you allow it via env_keep or tell it not to wipe the environment.

Sudo allows you to work around this same issue for $PATH via the "secure_path" setting in a sudoers file -- is there an equivalent for the LD_LIBRARY_PATH variable, or am I stick using an alias to do this? I'm aware that there are possible security issues.
Old 12-11-2012, 12:23 PM   #2
Registered: Jul 2011
Distribution: CentOS, Ubuntu, Fedora, Solaris, RHEL, Debian
Posts: 98

Rep: Reputation: 3
From the man page of sudoers(5):

Note that the dynamic linker on most operating systems will remove variables that can control
dynamic linking from the environment of setuid executables, including sudo. Depending on the
operating system this may include _RLD, DYLD_, LD_, LDR_, LIBPATH, SHLIB_PATH, and others.
These type of variables are removed from the environment before sudo even begins execution and, as such,
it is not possible for sudo to preserve them.
I would suggest you create a wrapper script for your application that sets up the environment as needed and then calls your application.

Last edited by blueh2o; 12-11-2012 at 12:25 PM.
Old 12-12-2012, 03:52 PM   #3
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
Originally Posted by blueh2o View Post
create a wrapper script for your application that sets up the environment as needed and then calls your application.
Then configure sudo to call the wrapper.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] trouble setting up sudo to allow su - user zrnaqvi Linux - Security 1 11-16-2009 06:42 PM
Setting the LD_LIBRARY_PATH Mark_667 Linux - Newbie 4 12-17-2008 11:26 AM
sudo not setting defaults brainlesspinkey Linux - Security 4 09-11-2005 11:34 AM
Permanently Set a Export Setting (LD_LIBRARY_PATH) nistelrooy Linux - General 1 11-25-2004 11:33 AM
setting LD_LIBRARY_PATH JonyKyte Linux - Newbie 1 02-14-2004 12:26 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:06 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration