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
My platform is GNU/linux, but if there is a POSIX way to achieve it that would be even better :)
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.
Mozilla firefox uses 2 zip archives