Skip to content

Fix #51#52

Merged
azubieta merged 3 commits into
AppImageCrafters:masterfrom
TheBrokenRail:master
Apr 14, 2022
Merged

Fix #51#52
azubieta merged 3 commits into
AppImageCrafters:masterfrom
TheBrokenRail:master

Conversation

@TheBrokenRail
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor

@azubieta azubieta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally forgot about library constructors. I guess that apprun_restore_workdir_if_needed would be better in the libapprun_hooks constructor as it will be the first thing executed in the target applications.

@TheBrokenRail
Copy link
Copy Markdown
Contributor Author

My reasoning for making it a global variable was that if something else modifies LD_PRELOAD, it would still keep track of chdir calls and handle appropriately even if libapprun_hooks.so isn't the first thing loaded. I'll definitely change apprun_restore_workdir_if_needed to run in a constructor function instead of the main hook though.

@azubieta
Copy link
Copy Markdown
Contributor

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)

@TheBrokenRail
Copy link
Copy Markdown
Contributor Author

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.

@azubieta azubieta merged commit aed096d into AppImageCrafters:master Apr 14, 2022
@azubieta
Copy link
Copy Markdown
Contributor

Seems good! Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants