YunoHost-Apps / borg_ynh

An experimental Borg implementation for YunoHost
https://www.borgbackup.org/
GNU Affero General Public License v3.0
19 stars 23 forks source link

Password forget what is after a space #49

Closed supermamie closed 3 years ago

supermamie commented 3 years ago

On initialisation, I set my passphrase to

Save of my server !

My last working save is on july 13 Since that, I have errors about passphrase I tried

sudo yunohost app setting borg passphrase

And it only return

Save

I tried to restore it

sudo yunohost app setting borg passphrase -v "Save of my server !"

But the save still fails. I tried a command suggested on the forum to get the actually used password

sudo grep "BORG_PASSPHRASE=" /etc/yunohost/hooks.d/backup_method/05-borg_app | cut -d'"' -f2

And it still returns

Save

So I edited the file, and the code only contains BORG_PASSPHRASE="Save" I replaced it with the real password and now it works.

I don't know how, but my password was truncated.

There were a commit on July 14 containing

export passphrase=$(ynh_app_setting_get $app passphrase)

Maybe this needs some escaping to save the spaces ?

SimonLefort commented 3 years ago

[edit: The problem is different so I created a new issue : https://github.com/YunoHost-Apps/borg_ynh/issues/50 ]

Hello, I had a similar problem and I dug.

The problem is, I think, in this script :

# cat /etc/yunohost/hooks.d/backup_method/05-borg_app
(...)
BORG_PASSPHRASE="RGjauGbbg6d$jj77g*piabfbfGedE"
(...)

(I changed the passphrase, obviously..)

Yunohost saved the complete passphrase :

# yunohost app setting borg passphrase
RGjauGbbg6d$jj77g*piabfbfGedE

But "$jj77g" is considered like an empty variable. Finally, borg used "RGjauGbbg6d*piabfbfGedE". We have to change " -> ' in the script.

$ PASSPHRASE="gaghtbgg$TEXT*gloa"
$ echo $PASSPHRASE 
gaghtbgg*gloa

$ PASSPHRASE='gaghtbgg$TEXT*gloa'
$ echo $PASSPHRASE 
gaghtbgg$TEXT*gloa

Perhaps we should add a warning during installation to say it's better to avoid some special characters ( ' , " , $ , .. ) ?

zamentur commented 3 years ago

Fixed in #71