Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run hook scripts directly from cache directory #136

Merged
merged 1 commit into from
Jul 29, 2023

Conversation

SuperTux88
Copy link
Contributor

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.

@SuperCuber
Copy link
Owner

Looks good, the temp file solution was a quick hack 🙃
I've approved the checks to run, please make sure they pass :)

@SuperTux88 SuperTux88 force-pushed the run-hooks-from-cache branch from 285deb9 to 651474d Compare July 28, 2023 23:01
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.
@SuperTux88 SuperTux88 force-pushed the run-hooks-from-cache branch from 651474d to 01756de Compare July 28, 2023 23:02
@SuperTux88
Copy link
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 perform_template_deploy 🤦‍♂️

So sorry for the red builds, it should hopefully work now. Can you approve the check-run again?

@SuperCuber
Copy link
Owner

Thanks for the contribution ❤️

@SuperCuber SuperCuber merged commit 84587c2 into SuperCuber:master Jul 29, 2023
@SuperTux88 SuperTux88 deleted the run-hooks-from-cache branch July 29, 2023 10:09
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