meganz / MEGAcmd

Command Line Interactive and Scriptable Application to access MEGA
Other
1.94k stars 407 forks source link

Possible Bug in the Login process #490

Open ollie10 opened 3 years ago

ollie10 commented 3 years ago

Good Morning,

I found a (possible)bug in the login method in the scriptable version: basically, it tells you that you have entered the wrong email and password if your password contains one or more special (non-alphanumeric) characters, at least I detected that it surely happens with one of them. Changing the password (removing special characters) works, using the interactive mode works too (with the original password).

This calls me to another question: how to restart the MegaServer if the machine has been restarted? I'm on an Ubuntu server and I have some backup process scheduled, I thought that logging in with the scriptable version was the most appropriate vai to run the MegaServer after the machine turns on but I can't due to the bug I just mentioned. Is this the proper way?

Many thanks

Dabombber commented 3 years ago

Examples might help with seeing what the problem is. On linux, the shell files pass arguments to mega-exec using "$@" so there shouldn't be any escaping issues. It's most likely a problem with your command.

Windows on the other hand, is... problematic. The batch files pass arguments using %* which is all kinds of broken, it'd be better to avoid using the batch files and call MegaClient.exe directly.

ollie10 commented 3 years ago

Hello @Dabombber I tried with same command, it should not be science fiction, it' a command with two parameters... It breaks with the dollar sign perhaps

Dabombber commented 3 years ago

So a variable then? Have a look at the documentation on Quoting in Bash. An easy fix might be to use single quotes ' instead of double quotes ", but even that needs special handling if your password contains a '.

ollie10 commented 3 years ago

Hello @Dabombber tried in any way, I still think it's a bug but it's fine maybe we should just use 5 chars password only with numbers that's probably the solution...

Tried:

None of those works, surely if I do an echo $mega_pwd I have my password correctly stored shown crystal clear...

mattw-mega commented 3 years ago

Figuring out the right escapes is quite tricky, if you want to use your password with command line tools then changing it to not include characters that the shell thinks are special will make things a lot easier (but I would recommend a lot more than 5 characters!). Or, you could log in once manually (eg in the megacmd shell, and then exit without logging off), and let the tools resume that session so they don't need to log in again every time, you can arrange things that way so that your scripts don't need to store your password.