NSS_REDIRECT Syscall Interceptor

Download Trial Version

NSS_REDIRECT Syscall Interceptor allows use files of your choice instead of

ENVIRONMENT VARIABLES

EXAMPLES

EXAMPLE 1

Assume we want google.com resolved to 127.0.0.1, but we either don't have root privileges or this fake resolving should be done only for specific applications.

  1. Create file my_etc_hosts with the content
    127.0.0.1 google.com
    
  2. Run telnet in a normal way:
    [si@localhost]$ telnet google.com
    Trying 216.58.208.46...
    
  3. Run telnet under nss_redirect syscall interceptor:
    [si@localhost]$ SI_ETC_HOSTS=my_etc_hosts nss_redirect.si telnet google.com
    Trying 127.0.0.1...
    telnet: connect to address 127.0.0.1: Connection refused
    

EXAMPLE 2

Run nss_redirect with log level 1

[si@localhost]$ SI_LOG_LEVEL=1 SI_ETC_HOSTS=my_etc_hosts ./nss_redirect.si google.com
nss_redirect.si: [SI_ETC_HOSTS        ] translate '/etc/hosts' to 'my_etc_hosts'
nss_redirect.si: [SI_ETC_NSSWITCH_CONF] do not translate '/etc/nsswitch.conf'
nss_redirect.si: [SI_ETC_RESOLV_CONF  ] do not translate '/etc/resolv.conf'
nss_redirect.si: ORIG_NAME='/etc/hosts', TRANSLATED_NAME='my_etc_hosts'
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused

EXAMPLE 3

Run nss_redirect with log level 2

[si@localhost]$ SI_LOG_LEVEL=2 SI_ETC_HOSTS=my_etc_hosts ./nss_redirect.si google.com
nss_redirect.si: [SI_ETC_HOSTS        ] translate '/etc/hosts' to 'my_etc_hosts'
nss_redirect.si: [SI_ETC_NSSWITCH_CONF] do not translate '/etc/nsswitch.conf'
nss_redirect.si: [SI_ETC_RESOLV_CONF  ] do not translate '/etc/resolv.conf'
nss_redirect.si: open("/usr/lib64/qt-3.3/bin/telnet") = -1 errno=2 (No such file or directory)
nss_redirect.si: open("/usr/local/bin/telnet") = -1 errno=2 (No such file or directory)
nss_redirect.si: open("/usr/local/sbin/telnet") = -1 errno=2 (No such file or directory)
nss_redirect.si: open("/usr/bin/telnet") = 3
nss_redirect.si: open("/lib64/ld-linux-x86-64.so.2") = 4
nss_redirect.si: open("/etc/ld.so.cache") = 3
nss_redirect.si: open("/lib64/libutil.so.1") = 3
nss_redirect.si: open("/lib64/libncurses.so.5") = 3
nss_redirect.si: open("/lib64/libtinfo.so.5") = 3
nss_redirect.si: open("/lib64/libc.so.6") = 3
nss_redirect.si: open("/lib64/libdl.so.2") = 3
nss_redirect.si: open("/etc/nsswitch.conf") = 3
nss_redirect.si: open("/etc/ld.so.cache") = 3
nss_redirect.si: open("/lib64/libnss_files.so.2") = 3
nss_redirect.si: open("/etc/services") = 3
nss_redirect.si: open("/etc/host.conf") = 3
nss_redirect.si: open("/etc/resolv.conf") = 3
nss_redirect.si: ORIG_NAME='/etc/hosts', TRANSLATED_NAME='my_etc_hosts'
nss_redirect.si: open("my_etc_hosts") = 3
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused