SuperCuber / dotter

A dotfile manager and templater written in rust 🦀
The Unlicense
882 stars 46 forks source link

[FEATURE] Don't ask for an elevation if nothing has changed #66

Open vessd opened 3 years ago

vessd commented 3 years ago

Is your feature request related to a problem? Please describe. I have several files in /etc with root ownership. Every time I deploy to update a configuration based on a template, dotter prompts me for elevation, even if the files in /etc have not changed.

Describe the solution you'd like Prompt for elevation only if the files that require them have changed.

SuperCuber commented 3 years ago

Seems like this is the source of the issue: https://github.com/SuperCuber/dotter/blob/106c2ea5310267ff85bc32aef4a8d715be9c4020/src/actions.rs#L339

The Identical variant should not run perform_template_deploy.

@vessd , can you confirm that this only happens when the file is a template, and not when it's a symlink?

vessd commented 3 years ago

can you confirm that this only happens when the file is a template, and not when it's a symlink?

No, it looks like it's still asking for it

[ WARN] Elevating permissions (Setting owner of "/etc/environment" to Name("root")...)

Hmm, in general I think it shouldn't be allowed to specify the owner for links, since it can't be done correctly. I mean, now I don't need root privileges to edit the /etc/environment file, since root only owns the link.

SuperCuber commented 3 years ago

No, it looks like it's still asking for it

OK, I'll check it in both symlink and template cases when I get to doing this.

Hmm, in general I think it shouldn't be allowed to specify the owner for links, since it can't be done correctly.

This is a good point, but I think I'll keep the ability to do this both for backwards compatibility and because there's not much reason to lock someone out of doing it if they "know what they are doing". A quote that comes to mind is "a system that prevents the user from doing stupid things also prevents the user from doing smart things".

I think it could be useful to have a warning for this though - maybe as a warn! in the create_symlink function, or even simpler - somewhere in the wiki.