For the purpose of this question, let us assume that there is a file (/path/to/file
) in the filesystem with a certain content like this:
$> cat /path/to/file
this is the content of the
file /path/to/file
I am happy with almost all processes running (and having reading access to this file), reading this content.
There should however (and this is the core of the question) be a specific process, which when reading from /path/to/file
should be provided with different file content.
$> cat /path/to/file
this is the DIFFERNT content of the
file /path/to/file
How can I somehow spoof the file content for a specific process?
Some guesses of mine, which road to take would be solitions related to :
- symlinking trick
- (linux) namespaces (filesystem namespace) trick
chroot
trick$LD_PRELOAD
hooking trick- overlayfs
My platform is GNU/linux, but if there is a POSIX way to achieve it that would be even better :)
Update
What would be a good solution/answer?
A criterium for a good solution/answer would be that it is possible to achieve "different file content for specific process", without needing interaction of the root user, eventhough the ideally the spoofed file should not be user-writeable in the first place.
Another good criterium would be that the modification of the file process shown to the process is specific, and ideally without sort of race-condition.
Background
Mozilla firefox uses 2 zip archives /usr/lib/firefox/omni.ja
and /usr/lib/firefox/browser/omni.ja
, which contain a fair deal of firefox' code (mostly the stuff writen in Javascript), by spoofing the file I would be able to modify my version of firefox (include some features I cannot anymore implement as a extension, provided dropped XPCOM support and disliked addon-siging coercion)
/path/to
? Likemount spoof.img /path/to/
. – Guilherme Costa Apr 25 '17 at 14:07/path/to
for all processes not only my specific one? Should I compare henceforth with annamespace
unshare
? – humanityANDpeace Apr 25 '17 at 14:13