Support user directory expansion in credential hooks #422
Labels
No labels
blocked
breaking
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No milestone
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
borgmatic-collective/borgmatic#422
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Apart from
source_directories, none of the configuration options seem to support tilde (~). That is such paths are passed through as is toborgor otherwise acted upon byborgmaticwithout applyingos.path.expanduser. Would be nice to have this feature applied to paths coming from configuration file in general. Perhaps normalizing (sanitizing) paths is also a good idea.This seems reasonable to me, but I'm curious: Are there specific options where you'd like to see expansion applied? Candidates I'm seeing:
patterns_fromexcludes_fromborgmatic_source_directorytemporary_directoryborg_*_directoryrepositoriesandcheck_repositories: Already expands~implicitly for remote repositories due to SSH being used. I suppose it'd be handy to expand for local repository paths too?ssl_*paths.Ones I'd probably omit:
patterns: Would require annoying parsing, as it's not just plain paths. EDIT: Although maybe only "root" patterns could support this, as those are just plain paths?encryption_passcommand: May require parsing so as not to expand command arguments, too.hooks: Same reason.Let me know your thoughts. Thanks!
Though, that's exactly the use case I'm interested in: I have a setup with one special user doing backups, maintaining all data necessary for borg in its home directory and I store passwords there as well. The entire home is stored on an encrypted ZFS, which gets mounted manually, so it's somewhat safe. Therefore, my passcommand looks like the following right now:
While it would be a little easier to have the following instead:
Slightly less typing and things are better prepared against additional backup users or a renamed user or a relocated home directory or alike.
catis even used in the official borg-docs, so supporting~for its arguments makes sense to me.Thanks, that example is helpful. It sounds like it's actually the command arguments that you want expanded! So the way I could see this working is to split the value of
encryption_passcommand(and other options that are passed to Borg via environment variables), expand each individual command/argument in case there are tildes, and then join them back together. I think that would achieve what you're looking for.I want to work on this issue.
Great! A lot has changed since this ticket was originally filed, so here are some thoughts: Instead of trying to split and parse
encryption_passcommand, it might make more sense to instead support directory expansion in these two types of crendential hooks:My rationale is that those two hooks are really intended to replace the use case of
cating a file withencryption_passcommand—and they have distinct file paths that would be easier to expand since they're already parsed.As for other cases for expanding
~, I think that modern borgmaticpatterns(and thereforesource_directories,excludes,patterns_from, etc. which all roll intopatterns) are all already expanded. You could verify that if you wanted to. You could also see if there are any other good candidate options in borgmatic for adding~expansion. But personally, I'd just try to keep this ticket relatively small and scoped rather than trying to add expansion absolutely everywhere.Your call though how you want to approach this. This is just my off-the-cuff brainstorming.
Thanks for the detailed info. I have started working on this issue.But I need some time before submitting a PR as I am working on the proposal.
Oh no worries! Take your time.
Support user directory expansion everywhereto Support user directory expansion in credential hooksReleased in borgmatic 2.0.0!