mail-in-a-box / mailinabox

Mail-in-a-Box helps individuals take back control of their email by defining a one-click, easy-to-deploy SMTP+everything else server: a mail server in a box.
https://mailinabox.email/
Creative Commons Zero v1.0 Universal
13.98k stars 1.44k forks source link

Backup.py assumes path component of S3 URL exists #2133

Open pckilgore opened 2 years ago

pckilgore commented 2 years ago

This line:

https://github.com/mail-in-a-box/mailinabox/blob/99474b348f0dd2632057c18c6a8c4e6464962878/management/backup.py#L211

Causes an exception when attempting to unpack a two-tuple that's actually a single value where the S3 URL does not contain an object path for the backups (or a trailing "/").

Worked around it by adding the "/" to my config.

Works

target: s3://s3.ca-central-1.amazonaws.com/BUCKET/

Fails

(Crashes admin page)

target: s3://s3.ca-central-1.amazonaws.com/BUCKET
JoshData commented 2 years ago

Yep. This was reported on the forum. I'd appreciate anyone's help making a concise fix to the code.

pckilgore commented 2 years ago

I started down this path and ended up realizing, it's not simple!

Surprised no libraries existed so made one: https://github.com/pckilgore/s3_endpoint_parse

What's your feeling on dependencies? The entire lib is one file, I could also just inline it /shrug.

JoshData commented 2 years ago

Mail-in-a-Box forms the URL from the options the user gives in the control panel (at https://github.com/mail-in-a-box/mailinabox/blob/main/management/templates/system-backup.html#L297), and we no longer pass the URL directly to duplicity, so we're not actually dealing with "S3 URLs" anywhere. We only have to support the URLs that our application has constructed, which happens to be the Path Style for S3.

elsiehupp commented 2 years ago

My non-AWS S3 backups abruptly broke for apparently this reason when I upgraded from Mail-in-a-Box v56 (I think?) to v57a, with repeated error emails reading not enough values to unpack (expected 2, got 1)

First I regenerated my access keys and re-entered all of my S3 bucket's information, and Mail-in-a-Box gave me a popup reading "OK", but then it immediately gave me another popup reading not enough values to unpack (expected 2, got 1) again. Adding a trailing slash to the "S3 Path" field did, in fact, fix the problem.

As an aside, when I was re-entering the S3 bucket's information, and I initially didn't re-enter all of the fields, the error message that popped up was (a) not particularly helpful, and (b) displayed escaped HTML markup, like so:

escaped html

This is only tangentially related, so I should probably open a separate issue, but idk.

rtuin commented 2 years ago

Just dropped in to say I'm having the same issue and @pckilgore's suggestion to add a / to the bucket name (in the web UI) fixes the not enough values to unpack (expected 2, got 1) error for me.

Screenshot 2022-07-28 at 10 14 44