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

Error after password change #127

Closed
speedyconzales opened this issue Aug 25, 2023 · 6 comments
Closed

Error after password change #127

speedyconzales opened this issue Aug 25, 2023 · 6 comments
Assignees
Labels
Milestone

Comments

@speedyconzales
Copy link

Not really an issue for me but after trying out the docker secrets I would like to point you to the fact that User and Password are stored in the org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json file in the config volume
Therefore the values are persistent. Using env variables for these values seems unnecessary.

So once set you don't need the env variables for user and password anymore.

On a fresh docker container installation without any config files -> just configure user and password one time. That's it.

That said if you ever change your password you have to change It in the json file cause the docker container always crashes with this error then (although I added the correct user and password as env variables in the docker-compose file. but it seems that the wrong password in org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json won't be altered anymore after first set):

30|Log.L.log 8/25/23, 9:14:59 PM - SEVERE [ Log.L.log ] -> Exception thrown at jd.SecondLevelLaunch$9$1.run(SecondLevelLaunch.java:919):
java.lang.ExceptionInInitializerError
	at jd.SecondLevelLaunch$9$1.run(SecondLevelLaunch.java:747)
Caused by: java.lang.RuntimeException: No Console Available!
	at org.appwork.console.ConsoleDialog.<init>(ConsoleDialog.java:54)
	at org.appwork.console.ConsoleDialog.<init>(ConsoleDialog.java:60)
	at org.jdownloader.api.myjdownloader.MyJDownloaderController.askLoginsOnConsole(MyJDownloaderController.java:273)
	at org.jdownloader.api.myjdownloader.MyJDownloaderController.start(MyJDownloaderController.java:125)
	at org.jdownloader.api.myjdownloader.MyJDownloaderController.<init>(MyJDownloaderController.java:112)
	at org.jdownloader.api.myjdownloader.MyJDownloaderController.<clinit>(MyJDownloaderController.java:37)
	... 1 more

TL;DR:

if you ever change your user or password. make sure to alter the org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json file accordingly. That seems the easiest way at the moment.

@jaymoulin jaymoulin self-assigned this Aug 25, 2023
@jaymoulin
Copy link
Owner

You're supposed to recreate a container when you change environment variable, this is a normal docker behaviour. Restarting it would have "fixed your issue" as your expected behaviour is handled at init (Both by Docker and JDownloader).

You also could have used the configure command as described in the documentation

@speedyconzales
Copy link
Author

speedyconzales commented Aug 25, 2023

docker-compose automatically recreates the container when the .yml file changed. was using command docker-compose up -d.
go ahead, try it yourself. after first creation of the config files no recreation with different env variables will alter the corresponding user and password values in the config file. instead you will get this error.

so as of now env variables are just useless after first creation

maybe this helps for further understanding:
using configure gives those two errors:
/usr/bin/configure: 16: /usr/bin/configure: pkill: not found
/usr/bin/configure: 16: /usr/bin/configure: reboot: not found

on a fresh created docker container.
image: jaymoulin/jdownloader:latest
version: 2.1.0-arm64

@jaymoulin
Copy link
Owner

docker-compose automatically recreates the container when the .yml file changed. was using command docker-compose up -d. go ahead, try it yourself. after first creation of the config files no recreation with different env variables will alter the corresponding user and password values in the config file. instead you will get this error.

As stated previously, you should use the configure command to change your password as you would normally do with any other program. You can check for yourself that this is already handled with the current version of the program

if [ -n "$FILE_MYJD_USER" ] && [ -n "$FILE_MYJD_PASSWORD" ]; then
(BTW, I don't know what version you're using as you deliberatly decided to remove the bug report template)

so as of now env variables are just useless after first creation

maybe this helps for further understanding: using configure gives those two errors: /usr/bin/configure: 16:
/usr/bin/configure: pkill: not found /usr/bin/configure:
16: /usr/bin/configure: reboot: not found

This, nonetheless, could be considered as a bug as the configure command is intended to restart the JDownloader instance for you. If you could give more information on the context and version you use, this would have been a great addition to help fix any issue.

jaymoulin added a commit that referenced this issue Aug 30, 2023
@jaymoulin jaymoulin added this to the 2.1.1 milestone Aug 30, 2023
jaymoulin added a commit that referenced this issue Aug 30, 2023
@speedyconzales
Copy link
Author

speedyconzales commented Sep 1, 2023

after updating the docker image to the latest version I tried configure once more.
nothing changed....

after debugging that behaviour this is my conclusion:
current: sed -Ei "s/\"password\" : .+\"(,?)/\"password\" : \"$2\"\1/" is very error prone cause it expects to be /opt/JDownloader/app/cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json in a specific format.
That said only the .dist version of the json file is formatted in a way for the current sed command to work properly.
after some testing I figured out that every time you change e.g. the device name in myjdownloader settings web UI and restart jdownloader. then the corresponding .json file gets overwritten with the new values and the format will be a flat one liner without spaces.

my suggestion. use something superior in order to alter .json files other than sed (e.g. jq) or change the .dist file to the one line format without spaces as well and use the following sed command version that I tested is working as expected then.
improved: sed -Ei 's/\"password\":\"[^"]+\"(,?)/\"password\":\"$2\"\1/'

@jaymoulin
Copy link
Owner

Thank you for reporting and for your support. The fix I deployed wasn't supposed to change the configure tool but added missing dependencies.

I will not install jq for the configure tool as sed is native to the system. jq is not and require many other dependencies and is not initially build for multi-platform, requiring more complexity for a minimum to no value.

Your RegExp is better for handling the change. This will reintroduce the initial password configuration bug but I'll handle it

jaymoulin added a commit that referenced this issue Sep 2, 2023
Configure tool will now surround parameters by double quotes to avoid
commas in password or email or devicename to break JSON format. With
this change, spaces before and after the semicolumn separator in
MyJDownloader configuration JSON file are forbidden (therefore, changed
in the dist default file).

This new behaviour, however, is buggy with double quotes in password.
This is a limitation of sed that does not allow non greedy regexp. This
means if a password contains a double quote, it will be correctly handle
the first time only and will break everything on password change. Same
for devicename or email.

Let's pray for JDownloader to NOT change back with the space on the
semicolumn separator or everything will be broken again.

I know this is not perfect but fixes 99% of issues to avoid
recompiling the universe or adding a thousand dependencies.
@advapiIT
Copy link

advapiIT commented Sep 5, 2023

In my case the org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json has repeated password entries and a lot full of \n\n\n\n\n\n\n\n\n I edited it, rebooted the container and it worked. Thanks

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

No branches or pull requests

3 participants