Run hook scripts directly from cache directory #136
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Running dotter with a second user panicked, because it didn't have permission to delete the temp-file that was created by the first user. And I also didn't expect that the hook-scripts get stored world readable outside of the users home. It's not a problem for me, but it might contain secrets from the
local.toml
, which users don't expect to leak somewhere else.Solution
There is no need to copy the hook scripts to somewhere else, it can be run directly from the cache, so that's what I implemented.
Other possible solutions I considered were creating a temp-file with a random name (or containing the username) and delete it again after the hook was run. But that would still leave the problem of maybe causing to leak the rendered hook script unintentionally. As even if the temp-file gets initially created with secure permissions, the permissions get overwritten to the source-file permissions (which is required to maybe make it executable if the source is executable). So users would need to manually make sure their hooks source files aren't world readable, or dotter would need to filter the permissions when copying source-file permissions.
So making the copying to a target optional and run the hooks directly from the cache looked like the best and easiest solution to me.