The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Operating Systems > SUN Solaris
.
google unix.com



SUN Solaris The Solaris Operating System, usually known simply as Solaris, is a free Unix-based operating system introduced by Sun Microsystems .

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Export Variable navi Shell Programming and Scripting 2 06-10-2008 06:39 AM
Export variable as number zeus101 Shell Programming and Scripting 2 10-16-2007 12:09 AM
problem while setting putenv pgarg High Level Programming 3 09-03-2007 07:16 AM
export variable. its-ashish UNIX for Dummies Questions & Answers 5 02-20-2007 06:24 AM
Export command giving Variable Name vs the Value set for the Variable ParNone UNIX for Dummies Questions & Answers 2 04-03-2006 11:43 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-19-2009
bhanug bhanug is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 2
putenv() doesnt really export the variable

Hi, I am trying to export LD_LIBRARY_PATH variable using putenv() in my code. but when executing the binary, it still prompts for the necessary libraries. But when I export the LD_LIBRARY_PATH from command prompt using export, the binary is able to link to the libraries. Where am I going wrong?
  #2 (permalink)  
Old 08-19-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,720
Let me understand. You call putenv() inside a program that relies on LD_LIBRARY_PATH?

You do know that dld() opens the runtime libraries BEFORE your putenv() code is called?
How else could it access the external code for putenv? putenv is linked as a symbol reference that has to be dereferenced at runtime.

So. Part of exectuable image activation is opening the runtime libraries. Do you have truss or strace or trace on your machine? If so, run your code under it. Note that before the executable runs the stuff you wrote it does a lot of file mapping and file opening. Most of that is shared libraries.

One way -

Instead of all this pain, statically link your exectuable against the library that now requiresLD_LIBRARY_PATH. Usually this means supplying the name of the .a form of the library on the command line (or makefile)

Code:
cc myfile.c /some/odd/path/liboddlibrary.a  -o myfile
Now, you do not need LD_LIBRARY_PATH in order to use liboddlibrary
  #3 (permalink)  
Old 08-20-2009
bhanug bhanug is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 2
Hi Jim, first of all..Thanx for the reply....
The code i am using has to link with shared libraries only. and other thing is that it is using set-uid. I read that when set-uid is used, the binary will ignore LD_LIBRARY_PATH and will look into only standard paths like /usr/lib. One option i am left with is to provide runtime path while compiling. Is there any other option... Please specify
  #4 (permalink)  
Old 08-20-2009
jlliagre jlliagre is offline Forum Advisor  
ɹǝsn sıɹɐlosuǝdo
  
 

Join Date: Dec 2007
Location: Paris
Posts: 1,390
You can extend the trusted library path with crle.
You can explicitly load the shared libraries in your code with dlopen.
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:40 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0