Closed TheBrokenRail closed 2 years ago
If LD_PRELOAD is changed they can hook things before ours and change the working directory by the must restore it otherwise the app may fail. I guess that it's they responsibility to fix things.
Let's divide this PR in two:
If LD_PRELOAD is changed they can hook things before ours and change the working directory by the must restore it otherwise the app may fail. I guess that it's they responsibility to fix things.
Let's divide this PR in two:
* One replacing the main function hook with the constructor * Other to do the chdir modification (there we could continue the discussion)
The only other things done in the main
hook is debug logging that main
has been called, so I don't think it needs to be switched completely into a constructor function, only the chdir
stuff. For now, I'll just get rid of the global variable.
Seems good! Thanks !
My reasoning for making it a global variable was that if something else modifies
LD_PRELOAD
, it would still keep track ofchdir
calls and handle appropriately even iflibapprun_hooks.so
isn't the first thing loaded. I'll definitely changeapprun_restore_workdir_if_needed
to run in a constructor function instead of themain
hook though.