venerdì 10 febbraio 2017

[bash] WD MyCloud blank dashboard

I have 2 identical Western Digital MyCloud NAS 4TB.

On one I got a white page on the web GUI. What happened is that login form appeared for just a while and then disappeared. I could see the HTML properly loaded, but I couldn't submit the form. The weird thing is that the other one, identical even for firmware version, was perfectly working.

After struggling for almost 1 year, nor Google helped, neither several forums. So I decided to drill down myself and discovered that it's a nasty bug in the license authorization. Console showed:

404 (Not Found) GET /api/2.1/rest/eula_acceptance?_=1445555308745

In some cases the initial setup with authorization doesn't work or communicate and, in addition, there's a really poor messaging (blank page is not an alert!), lack of any failover / failback mechanism in case of license drop e.g. for a wrong click or temporary network down. Nice job on that FK php guys!

Once I found the cause, it was a matter of bash grep and vi work :-)
Access via ssh, default password is "welc0me".
Backup a file, modify, accept eula, recover backup, tha's it!

ssh root@192.168.1.xxx/
welc0me
cd /var/www/htdocs/UI/js/lib
cp authentication.js authentication_backup.js
vi authentication.js

On line 37 replace this

"error": function (request, status, error) {
if (request.status == 404) { // EULA not found
if (settings.hideLoading != null){
settings.hideLoading();
}
if (settings.showEula != null){
settings.showEula();
}
}
else {
if (settings.processEulaError != null){
settings.processEulaError(request.responseText, 'get_eula_acceptance', request.status);
}
}
}

with this

"error": function (request, status, error) {
handler.checkUsers();
}

Reload the page and accept EULA.

rm authentication.js
mv authentication_backup.js authentication.js

VOILA', offer me a beer plz!