Menu

Usage

Bogdan Drozdowski

LibNetBlock won't intercept calls to the mentioned functions just because it is compiled. Even installing the library in a system directory isn't enough. The library needs to be loaded into memory. More strictly, it needs to be PRELOADED (loaded before other libraries). This is achieved easily, if you are using ld.so (or derivatives) to load libraries (like on GNU/Linux).
Just add the following line:

    export LD_PRELOAD=/path/to/libnetblock.so

to your startup scripts (like $HOME/.bashrc, $HOME/.bash_profile). You should change the path to the correct one. If you aren't using bash, consult your shell manual for details on how to export an environment variable.

This will make the dynamic linker, ld.so, load LibNetBlock before loading any other libraries, when starting programs. That is, after the line above gets executed, all programs from that moment start using LibNetBlock.

You can alternatively put the full path to the library in the /etc/ld.so.preload file (NOT recommended, because some good programs may need network access).
No syntax is required, just the path and filename, like this:

/path/to/libnetblock.so

To load LibNetBlock for just one program, type like this (for bash):

    LD_PRELOAD=/path/to/libnetblock.so some-program-name

Related

Wiki: Home