diff --git a/Makefile b/Makefile index c6ec240..15ac1b8 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,7 @@ test: example $(LIB_FILE) $(CMD_FILE) strip: all strip -s $(LIB_FILE) $(CMD_FILE) +ifeq ($(PLATFORM),Linux) deb: all mkdir -p debian-pkg/usr/bin cp -v $(CMD_FILE) debian-pkg/usr/bin @@ -72,5 +73,6 @@ deb: all sed "s/<>/$$DEB_VER/" debian.control | sed "s/<>/$$DEB_ARCH/" \ > debian-pkg/DEBIAN/control; \ fakeroot dpkg-deb -b debian-pkg "$$DEB_NAME" +endif .PHONY: all clean install uninstall test strip deb diff --git a/README.md b/README.md index ea1928f..1b25ffa 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ _Wow!_ Now you can run a command and fake your hostname! Usage is relatively simple: `fakehostname [ ...]` -For example, +For example on Linux, ``` $ fakehostname joan hostname @@ -18,6 +18,17 @@ $ fakehostname rivers uname -n rivers ``` +Or you can use the library directly, ie with `libfakehostname.so` in the current +directory, + +``` +$ LD_PRELOAD=./libfakehostname.so FAKE_HOSTNAME=joan-rivers hostname +joan-rivers +``` + +Note you _can_ use `fakehostname` on macOS, but it's a little tricky and you +should read the [note below](#important-note-for-apples-macos-darwin). + ### Installation Fetch the source from Github and install! @@ -40,10 +51,10 @@ $ sudo apt-get install -y build-essential The command (`fakehostname`), and its associated library (`libfakehostname`), are a hack that slip between your program and the C standard library to monkey -patch the `uname` and `gethostname` routines provided therein. This is -accomplished via `LD_PRELOAD` environment variables on Linux, and the -`DYLD_INSERT_LIBRARIES` + `DYLD_FORCE_FLAT_NAMESPACE` ones on macOS (see -[note below](#important-note-for-apples-macos-darwin)). +patch the `uname` and `gethostname` functions provided therein. This is +accomplished via the `LD_PRELOAD` environment variables on Linux, and the +`DYLD_INSERT_LIBRARIES` + `DYLD_FORCE_FLAT_NAMESPACE` evironment variables on +macOS (see [important note below](#important-note-for-apples-macos-darwin)). The library reads environment variable `FAKE_HOSTNAME` -- prepped by the command -- and uses that instead of your system's hostname.