The libdothosts.so is a library and user-space script which allows you to use a /etc/hosts file in your home directory.
License
ajdiaz/dothosts
master
Name already in use
Code
-
Clone
Use Git or checkout with SVN using the web URL.
Work fast with our official CLI. Learn more about the CLI.
- Open with GitHub Desktop
- Download ZIP
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
libdothosts.so ============== The dothosts library is a LD_PRELOAD based library which allows you to have a user based hosts file. The library will catch all calls to gethostbyname(3), gethostbyname2(3), getaddrinfo(3),gethostbyname_r(3) and gethostbyname2_r(3) and perform a search of the requested host in a local (i.e. a file into home user directory) to resolve the hostname. If not found in this file, then proceed with the regular resolv mechanism. ---- Install --------------------------------------------------------------- make && make test && make install If you want to use the 'dothosts' helper, just copy the script to your path. The make install proccess will not copy helper script. ---- Usage ----------------------------------------------------------------- To use dothosts just type: export LD_PRELOAD=path/to/libdothosts.so And then new applications will use ~/.hosts file as /etc/hosts (the original /etc/hosts will be also used if host does not match in ~/.hosts). Aditionally, environment variable DOTHOSTS will use to change the path of local .hosts file, for exaple: export DOTHOSTS=~/.config/hosts You can use the dothost utility to run an application with library loaded, in the form: dothosts wget http://test ---- Limitations ---------------------------------------------------------- - Only works for programs that use glibc calls to resolve hostnames. - No working for SUID programs for security reasons. ---- Development ---------------------------------------------------------- The main repo is hosted in sourcehut: https://git.sr.ht/~ajdiaz/dothosts I've a mirror also in github: https://github.com/ajdiaz/dothosts For bug report please send email to the list: ~ajdiaz/public-inbox@lists.sr.ht Any patch is also welcome. Happy Hacking!
About
The libdothosts.so is a library and user-space script which allows you to use a /etc/hosts file in your home directory.