Skip to content

Change passphrase - #269

Open
fflorent wants to merge 4 commits into
testingfrom
change-passphrase
Open

Change passphrase#269
fflorent wants to merge 4 commits into
testingfrom
change-passphrase

Conversation

@fflorent

@fflorent fflorent commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Problem

  1. It needs some tricky steps to change a passphrase (not only run the key change-passphrase command but also change the value in the settings and regenerate the .env file)
  2. The passphrase can contain whitespaces now, as we surround the value with quotes in the .env file. I tested that.

Fixes #257
Fixes #237

Solution

Regarding the modification of the passphrase:

  • Add a switch (a boolean field) in the config panel to prevent unwanted modifications
  • Add a passphrase modification field, hidden until the previous field is enabled, to fill a new passphrase
  • When the passphrase is provided and the changes validated, call the borg key change-passphrase command and store its new value in the app settings and in the env file as well

BTW, it looks like the check for common passwords works out of the box, which is a great feature 😍
https://github.com/YunoHost/yunohost/blob/622991f4a559caee626f2d14567883ef52fc6364/src/utils/form.py#L871

Screenshot showing an error when a common password is chosen as the new borg passphrase in the config panel.

But unfortunately, it is not possible to change the passphrase through the cli:

# yunohost app config set borg main.general.new_passphrase -v WhatEverPassphrase

========================================
>>>> Borg configuration
========================================
Traceback (most recent call last):
  File "/usr/bin/yunohost", line 108, in <module>
    main()
  File "/usr/bin/yunohost", line 97, in main
    yunohost.cli(
  .......
  File "/usr/lib/python3/dist-packages/yunohost/utils/form.py", line 224, in evaluate_simple_js_expression
    return evaluate_simple_ast(node, context)  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yunohost/utils/form.py", line 109, in evaluate_simple_ast
    return context[node.id]
           ~~~~~~~^^^^^^^^^
KeyError: 'change_passphrase'

About the blank space

Also remove the mention in the manifest regarding the blank spaces.

If I am correct, it is not necessary anymore:

# mkdir /tmp/backups
# yunohost app install borg -a "repository=/tmp/backups&passphrase=Hello world'works with quotes as well'&conf=0&data=0&apps=borg&on_calendar=Yearly&mailalert=never"
# chown borg__6: /tmp/backups/
# systemctl start APP_ID
# yunohost app shell APP_ID

$ borg list # Will list the backups successfully

And if you try to enter the passphrase manually:

$ cat .env
# ⚠️ This file is readonly and not meant to be edited: any changes will be lost at the next upgrade.
# Configure the borg app through the webadmin or run the relevant command lines instead to change values.
# https://doc.yunohost.org/en/admin/apps/#application-configuration

BORG_PASSPHRASE='Hello world'"'"'works with quotes as well'"'"''
BORG_REPO='/tmp/backups'
BORG_RELOCATED_REPO_ACCESS_IS_OK='yes'
BORG_RSH='ssh -i /root/.ssh/id_borg__6_ed25519 -oStrictHostKeyChecking=yes '
$ export BORG_REPO='/tmp/backups'
$ export BORG_RELOCATED_REPO_ACCESS_IS_OK='yes'
$ export BORG_RSH='ssh -i /root/.ssh/id_borg__6_ed25519 -oStrictHostKeyChecking=yes '
$ sudo ./venv/bin/borg list # Will ask for the passphrase, enter `Hello world'works with quotes as well'` and it will work

PR Status

  • Code finished and ready to be reviewed/tested
  • The fix/enhancement were manually tested (if applicable)

Automatic tests

Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ after creating the PR, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization)

@fflorent
fflorent changed the base branch from master to testing August 14, 2026 16:17
@fflorent

Copy link
Copy Markdown
Collaborator Author

!testme

@yunohost-bot

Copy link
Copy Markdown
Contributor

CI-ya after the tests!
Test Badge

@fflorent

Copy link
Copy Markdown
Collaborator Author

!trixietestme

@yunohost-bot

Copy link
Copy Markdown
Contributor

🦖
Test Badge

@fflorent

Copy link
Copy Markdown
Collaborator Author

!bump

@fflorent
fflorent requested review from kay0u and zamentur August 14, 2026 16:18
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.

Changing a Passphrase Accepting blank spaces in passwords?

2 participants