encryption_passcommand in one config file A wrongly used for repo in config file B #555
Labels
No Label
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: borgmatic-collective/borgmatic#555
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
What I'm trying to do and why
I have multiple config files, say A.yaml and B.yaml (sanitized). I want to run borg check on a repo in B.yaml, specifying the repo using
--repository
.Steps to reproduce (if a bug)
Relevant snippets of the config files:
A.yaml:
B.yaml:
No merging/YAML magic in the config files.
Actual behavior (if a bug)
borgmatic --repository /repo/B borg check ...
aborts with "passphrase supplied in BORG_PASSPHRASE, by BORG_PASSCOMMAND or via BORG_PASSPHRASE_FD is incorrect.".strace
shows that borg runs theencryption_passcommand
from A.yaml before aborting.borgmatic --config /etc/borgmatic.d/B.yaml --repository /repo/B borg check ...
Expected behavior (if a bug)
borgmatic --repository /repo/B borg check ...
ignores everything in A.yaml and asks for a passphraseOther notes / implementation ideas
Not sure if this is specific to arbitritrary borg commands / borg check. I vaguely remember that I saw this problem with normal operations in the past but I never really bothered reporting it. I can't try right now because the borg check is in progress now... ;) I can try later if this is relevant.
Environment
borgmatic version: 1.6.4
borgmatic installation method: Arch Linux package
Borg version: 1.1.17
Python version: 3.10.5
operating system and version: Arch Linux
Thank you for bothering to report this! 😄 I have a hunch about what's going on here. Things like Borg passcommands are communicated from borgmatic to Borg via environment variable. So borgmatic is probably setting the passcommand environment variable for repository A and then it's still around when it gets to repository B, causing the behavior you're seeing.
The fix is probably to avoid altering the global environment and instead pass in a local environment specific to each Borg command that it runs. (More specifically,
execute_command(extra_environment=...
.) The trick will be plumbing that through everywhere that needs it set.Okay, it took some doing, but this should be fixed. Environment variables are no longer set globally, so they should be scoped to particular configuration files now. Release forthcoming. Thanks again for reporting this!
Fix released in borgmatic 1.6.5!
Thanks for the quick fix!