Skip to content

Commit

Permalink
Formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alighazi288 committed Jan 5, 2025
1 parent 1b40304 commit d07a5ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
7 changes: 2 additions & 5 deletions src/borg/crypto/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,22 +364,19 @@ def detect(cls, repository, manifest_data):
target = key.find_key()
prompt = "Enter passphrase for key %s: " % target
passphrase = Passphrase.env_passphrase()
debug_enabled = os.environ.get("BORG_DEBUG_PASSPHRASE") == "YES"
if passphrase is None:
passphrase = Passphrase()
if not key.load(target, passphrase):
for retry in range(0, 3):
passphrase = Passphrase.getpass(prompt)
if key.load(target, passphrase):
break
elif debug_enabled:
Passphrase.display_debug_info(passphrase)
Passphrase.display_debug_info(passphrase)

Check warning on line 374 in src/borg/crypto/key.py

View check run for this annotation

Codecov / codecov/patch

src/borg/crypto/key.py#L374

Added line #L374 was not covered by tests
else:
raise PasswordRetriesExceeded
else:
if not key.load(target, passphrase):
if debug_enabled:
Passphrase.display_debug_info(passphrase)
Passphrase.display_debug_info(passphrase)

Check warning on line 379 in src/borg/crypto/key.py

View check run for this annotation

Codecov / codecov/patch

src/borg/crypto/key.py#L379

Added line #L379 was not covered by tests
raise PassphraseWrong
key.init_ciphers(manifest_data)
key._passphrase = passphrase
Expand Down
5 changes: 4 additions & 1 deletion src/borg/helpers/passphrase.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import shlex
import subprocess
import sys
import textwrap

from . import bin_to_hex
from . import Error
Expand Down Expand Up @@ -109,13 +110,15 @@ def verification(cls, passphrase):
retry=True,
env_var_override="BORG_DISPLAY_PASSPHRASE",
):
pw_msg = f"""
pw_msg = textwrap.dedent(
f"""
Your passphrase (between double-quotes): "{passphrase}"
Make sure the passphrase displayed above is exactly what you wanted.
Your passphrase (UTF-8 encoding in hex): {bin_to_hex(passphrase.encode("utf-8"))}
It is recommended to keep the UTF-8 encoding in hex together with the passphrase at a safe place.
In case you should ever run into passphrase issues, it could sometimes help debugging them.
"""
)
print(pw_msg, file=sys.stderr)

@staticmethod
Expand Down

0 comments on commit d07a5ba

Please sign in to comment.