2

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.

3
  • Is this for specific applications? Can you just build a configuration file and store the ip address in the configuration?
    – Zoredache
    Jul 1, 2010 at 23:40
  • it's an application that won't let me store hostnames in its config
    – David
    Jul 1, 2010 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, 2010 at 4:24

2 Answers 2

4

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

2
  • 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, 2010 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, 2012 at 1:07
2

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.

2
  • 1
    don't you need to be root for all those things?
    – David
    Jul 1, 2010 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, 2010 at 23:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .