Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am a user on a Solaris 10 system and I wish to maintain my own version of /etc/hosts. This file will function like a normal /etc/hosts, except it will only resolve hosts from processes that I run.

Since I do not have the ability to write to /etc/hosts and I do not wish to have to ask the adminstrator to reconfigure it for me. (please don't go into this more)

I am open to other alternatives that will allow a non-privileged user the ability to add custom host names. The solution must not involve the superuser doing anything.

share|improve this question
    
Is this for specific applications? Can you just build a configuration file and store the ip address in the configuration? –  Zoredache Jul 1 '10 at 23:40
    
it's an application that won't let me store hostnames in its config –  David Jul 1 '10 at 23:41
    
Can you put the desired IP address into the App? Can you get the administrator to help with initial setup of whatever solution is suggested? –  DrStalker Jul 2 '10 at 4:24

2 Answers 2

up vote 4 down vote accepted

Override gethostbyname. You'll need to control the library path, but that can be done by a user. See here for some neat info:

http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html

share|improve this answer
    
You will need to override more functions than gethostbyname, like gethostent. Depending on the Solaris release, these functions might also differ, like gethostbyname_r and gethostent_r. Also, beware that the link you posted is more directed to Gnu/Linux than Solaris and some information doesn't apply to the latter, like ld.so.preload. LD_PRELOAD is however the way to go with both Gnu/Linux and Solaris. –  jlliagre Jul 2 '10 at 9:21
    
This is the Right Answer but sadly not a simple one. Here's one that someone else prepared earlier: fy.chalmers.se/~appro/LD_*-gallery/libhost.c –  Zanchey Jan 24 '12 at 1:07

A chrooted environment or even a dedicated non global zone might be a solution for you. Otherwise, an interposition library or a dtrace script might also do the job.

share|improve this answer
1  
don't you need to be root for all those things? –  David Jul 1 '10 at 23:41
    
For setting up them yes, outside the interposition library suggestion which requires no privileges but programming skills. I doubt you'd easily find existing code that does precisely that. –  jlliagre Jul 1 '10 at 23:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.