I have run a program that accesses some files from the directory /etc/somedir.
What I want to do is whenever it tries to access /etc/somedir/somefile it automatically redirects to /home/arch/someoterdirectory/somefile. Is this possible only for a specific application?.

Please note that I don't want to use symbolic links as I only want to do this for a specific program, rest of the programs can access /etc/somedir as it is.

  • 2
    This problem sounds very much like a XY-Problem. – pLumo Nov 5 '20 at 12:45
  • Yes, that's possible in Linux with a mount namespace and a bind mount. Less reliably, and much messier, it could also be done with a LD_PRELOAD hack. But why not just modify that application in the first place? Even binary applications can have strings changed within them, provided that they're the same size or shorter. – user414777 Nov 5 '20 at 13:02
  • Do you have control of the application (is it a script you can edit?) What kind of access is that (a file argument, reading some lib file hardcoded)? If you provide some more details, you could get an answer tailored to your needs. – thanasisp Nov 5 '20 at 20:50
  • Yes, I have the source code of the program. But the problem is that it is extremely big in size. – Shivam Goyal Nov 6 '20 at 6:59
  • So, it's hard to identify into the code where are all the calls to /etc/somedir/somefile or to other files, but it is probably not difficult to identify where the directory /etc/somedir is configured to be a variable for the script, am I right? – thanasisp Nov 6 '20 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.