Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving to Keyring in Docker on synology NAS #539

Closed
Jholmgren5 opened this issue Jan 21, 2023 · 12 comments · Fixed by #554
Closed

Saving to Keyring in Docker on synology NAS #539

Jholmgren5 opened this issue Jan 21, 2023 · 12 comments · Fixed by #554
Assignees

Comments

@Jholmgren5
Copy link

Having an issue with Python and saving to system keyring. Using a fully updated synology NAS with Docker. Everything works fine, and I can pull photos down, log in, 2FA, etc, all working. However when I go to save my iCloud password, after i type “y”, this is the error:

ave password in keyring? [y/N]: y
Traceback (most recent call last):
File "/usr/bin/icloud", line 8, in
sys.exit(main())
File "/usr/lib/python3.9/site-packages/pyicloud_ipd/cmdline.py", line 209, in
main
utils.store_password_in_keyring(username, password)
File "/usr/lib/python3.9/site-packages/pyicloud_ipd/utils.py", line 53, in sto
re_password_in_keyring
return keyring.set_password(
File "/usr/lib/python3.9/site-packages/keyring/core.py", line 48, in set_passw
ord
_keyring_backend.set_password(service_name, username, password)
File "/usr/lib/python3.9/site-packages/keyrings/alt/file_base.py", line 90, in
set_password
password_base64 = base64.encodestring(password_encrypted).decode()
AttributeError: module 'base64' has no attribute 'encodestring'

When I type in my password, my iDevice does pop up with a 2FA alert.

@Jholmgren5 Jholmgren5 added the bug label Jan 21, 2023
@Jholmgren5 Jholmgren5 changed the title Saving to Keyring in Docker on symbology NAS Saving to Keyring in Docker on synology NAS Jan 21, 2023
@mpolom
Copy link

mpolom commented Jan 23, 2023

I just wanted to add that I have the same issue too

@AndreyNikiforov
Copy link
Collaborator

I found notes about Docker & Keyring Using Keyring on headless Linux systems in a Docker container. See if that helps

@mpolom
Copy link

mpolom commented Jan 23, 2023

From some reading, it seems base64.encodestring() and base64.decodestring() have been deprecated since Python 3.1 and now removed in 3.9.1.

base64.encodebytes() and base64.decodebytes() should be used instead.

@Jholmgren5
Copy link
Author

Looks like I have more learning to do. I am a complete Docker noob, and know almost nothing about Python, haha. The basement stuff makes sense, based on a quick google search, so thanks for that info, and a point in the right direction. I’ll still keep this open, in case anyone has the same problem, or a fix. Thanks!

@AndreyNikiforov
Copy link
Collaborator

From some reading, it seems base64.encodestring() and base64.decodestring() have been deprecated since Python 3.1 and now removed in 3.9.1.

base64.encodebytes() and base64.decodebytes() should be used instead.

Hmm... We are using 3.9 and possibly introduced regression by not sticking to exact minor versions... Should be reproducible outside of docker too (e.g. in packaged binaries). If reproduced, we can possibly mitigate by pinning python to 3.9.0

@AndreyNikiforov
Copy link
Collaborator

Looks like I have more learning to do. I am a complete Docker noob, and know almost nothing about Python, haha. The basement stuff makes sense, based on a quick google search, so thanks for that info, and a point in the right direction. I’ll still keep this open, in case anyone has the same problem, or a fix. Thanks!

Docker and systems using it (e.g. Kubernetes) have mechanisms to pass secrets to container. That would be canonical solution rather than granting container a privileged access to the host (in order to use keyring from inside the container). Probably need to tweak icloudpd to support that approach though, e.g. accept password from file as secrets appear inside the containers as files.

@AndreyNikiforov
Copy link
Collaborator

From some reading, it seems base64.encodestring() and base64.decodestring() have been deprecated since Python 3.1 and now removed in 3.9.1.
base64.encodebytes() and base64.decodebytes() should be used instead.

Hmm... We are using 3.9 and possibly introduced regression by not sticking to exact minor versions... Should be reproducible outside of docker too (e.g. in packaged binaries). If reproduced, we can possibly mitigate by pinning python to 3.9.0

I just checked that packaged executable for windows saves to and uses from keyring successfully. It is also packaged with 3.9, so it is version/platform combo.

Tried docker with --privileged argument and got the same error with encodestring, so it is most likely unrelated to docker permissions, but linked with function deprecation.

@mpolom
Copy link

mpolom commented Jan 23, 2023

It looks like keyrings.alt made the fix a couple of years ago here: jaraco/keyrings.alt#40

@AndreyNikiforov
Copy link
Collaborator

I cannot repro the issues in 1.8.0. Closing the issue. @Jholmgren5 if you see the issue again in 1.8.0, pls reopen

@Jholmgren5
Copy link
Author

Thanks for the help! It looks like version 1.8.0 is broken in some way, at least for my case. The container is significantly smaller in size too. This is what happens when I try to download the 10 most recent photos. I installed this container separately, alongside 1.7.3, in order to test it.

2023-01-28 14:32:17 DEBUG Authenticating...
Traceback (most recent call last):
File "icloudpd.py", line 5, in
File "click/core.py", line 1130, in call
File "click/core.py", line 1055, in main
File "click/core.py", line 1404, in invoke
File "click/core.py", line 760, in invoke
File "icloudpd/base.py", line 268, in main
File "icloudpd/authentication.py", line 29, in authenticate
File "pyicloud_ipd/base.py", line 141, in init
File "pyicloud_ipd/utils.py", line 35, in get_password_from_keyring
File "keyring/core.py", line 55, in get_password
File "keyring/backends/fail.py", line 25, in get_password
keyring.errors.NoKeyringError: No recommended backend was available. Install a r
ecommended 3rd party backend package; or, install the keyrings.alt package if yo
u want to use the non-recommended backends. See https://pypi.org/project/keyring
for details.
[25] Failed to execute script 'icloudpd' due to unhandled exception!
/app #

@AndreyNikiforov
Copy link
Collaborator

@Jholmgren5 I believe keyring issue is fixed in 1.8.1.

@Jholmgren5
Copy link
Author

@AndreyNikiforov it works great now! Thanks so much for the help! This a game changer for me to backup my photos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants