Default systemd credential name is rejected #1044

Closed
opened 2025-03-26 14:31:04 +00:00 by BenWolsieffer · 4 comments

What I'm trying to do and why

I am attempting to use the recently added systemd credential support, using the hardcoded default credential name (borgmatic.pw) in the systemd unit file.

Steps to reproduce

Follow the instructions in the manual for setting up systemd service credentials, using the built-in credential support rather than encryption_passcommand.

Actual behavior

CRITICAL /etc/borgmatic/config.yaml: /etc/borgmatic/config.yaml: Error getting local Borg version
CRITICAL /etc/borgmatic/config.yaml: Cannot load invalid credential name "borgmatic.pw"
CRITICAL /etc/borgmatic/config.yaml: An error occurred
CRITICAL
CRITICAL summary:
CRITICAL An error occurred
CRITICAL /etc/borgmatic/config.yaml: Error getting local Borg version
CRITICAL Cannot load invalid credential name "borgmatic.pw"
CRITICAL
CRITICAL Need some help? https://torsion.org/borgmatic/#issues

Expected behavior

The credential loads successfully.

Other notes / implementation ideas

It looks like this happens because the systemd credential loader requires the name to match the regex ^\w+$. This does not allow the . character, therefore the default credential name is rejected. I think either the regex should be made less restrictive or the default name should be changed.

borgmatic version

1.9.14

borgmatic installation method

Arch Linux package

Borg version

1.4.0

Python version

3.13.2

Database version (if applicable)

No response

Operating system and version

Arch Linux

### What I'm trying to do and why I am attempting to use the recently added systemd credential support, using the hardcoded default credential name (`borgmatic.pw`) in the systemd unit file. ### Steps to reproduce Follow the [instructions in the manual for setting up systemd service credentials](https://torsion.org/borgmatic/docs/how-to/provide-your-passwords/#systemd-service-credentials), using the built-in credential support rather than `encryption_passcommand`. ### Actual behavior ``` CRITICAL /etc/borgmatic/config.yaml: /etc/borgmatic/config.yaml: Error getting local Borg version CRITICAL /etc/borgmatic/config.yaml: Cannot load invalid credential name "borgmatic.pw" CRITICAL /etc/borgmatic/config.yaml: An error occurred CRITICAL CRITICAL summary: CRITICAL An error occurred CRITICAL /etc/borgmatic/config.yaml: Error getting local Borg version CRITICAL Cannot load invalid credential name "borgmatic.pw" CRITICAL CRITICAL Need some help? https://torsion.org/borgmatic/#issues ``` ### Expected behavior The credential loads successfully. ### Other notes / implementation ideas It looks like this happens because the systemd credential loader requires the name to match the regex `^\w+$`. This does not allow the `.` character, therefore the default credential name is rejected. I think either the regex should be made less restrictive or the default name should be changed. ### borgmatic version 1.9.14 ### borgmatic installation method Arch Linux package ### Borg version 1.4.0 ### Python version 3.13.2 ### Database version (if applicable) _No response_ ### Operating system and version Arch Linux
Owner

Thanks for filing this! You are absolutely right about the cause here. I'll make the regular expression less restrictive. (It's so restrictive right now to prevent path injection attacks.)

Thanks for filing this! You are absolutely right about the cause here. I'll make the regular expression less restrictive. (It's so restrictive right now to prevent path injection attacks.)
Owner

This is fixed in main and will be part of the next release! If you want to get the fix locally before then and don't mind modifying your local borgmatic install, you could update the regular expression yourself.

Thanks again!

This is fixed in main and will be part of the next release! If you want to get the fix locally before then and don't mind modifying your local borgmatic install, you could update the [regular expression](https://projects.torsion.org/borgmatic-collective/borgmatic/src/commit/d2714cb706c45ccc05f4890bedfa2d97e4e194ee/borgmatic/hooks/credential/systemd.py#L8) yourself. Thanks again!
witten 2025-03-26 16:56:30 +00:00
  • closed this issue
  • added the
    bug
    label
witten referenced this issue from a commit 2025-03-26 16:58:08 +00:00
Author

Thank you!

Thank you!
Owner

Released in borgmatic 2.0.0!

Released in borgmatic 2.0.0!
Sign in to join this conversation.
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
borgmatic-collective/borgmatic#1044
No description provided.