Run hook scripts directly from cache directory#136
Merged
SuperCuber merged 1 commit intoSuperCuber:masterfrom Jul 29, 2023
Merged
Run hook scripts directly from cache directory#136SuperCuber merged 1 commit intoSuperCuber:masterfrom
SuperCuber merged 1 commit intoSuperCuber:masterfrom
Conversation
Owner
|
Looks good, the temp file solution was a quick hack 🙃 |
285deb9 to
651474d
Compare
Copying the hooks to temp is a problem if you run dotter with different users, as the file gets left behind and other users don't have permissions to overwrite it. It's also not really needed to copy the file to somewhere else, it can just be run to where it is anyway from the cache directory. It might be also a problem to create the hooks world readable at the temp-directory, where other users can read it, it might contain secrets that aren't expected to be written to outside of the home directory.
651474d to
01756de
Compare
Contributor
Author
|
OK, I was very confused, because I checked that everything was green locally, but it wasn't here ... but it looks like I based my change on an older commit of master, and therefore missed one new usage of So sorry for the red builds, it should hopefully work now. Can you approve the check-run again? |
Owner
|
Thanks for the contribution ❤️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.