Jakob Østergaard Hegelund

Tech stuff of all kinds

Autologin on (Oracle) Sun Unified 7000 systems

2012-02-10

Having just received a Sun Unified storage system at work (basically two amd64 based servers and two disk shelves full of high capacity disks coupled with some read flash and fancy write optimized flash), I wanted to put the "dashboard" page from the web UI on a big screen on the wall so that everyone that walks by can see the current status of the system.

The system has an absolutely fantastic web based user interface. It even supports the creation of "kiosk" users - accounts that are limited to viewing only the dashboard. Just what I needed... However, there is no (documented) way of actually having a kiosk session automatically log on to the system, so that it could function like, well, a kiosk session.

The usual way of accomplishing this in a web interface, would be to allow the user to supply a &username= and &password= argument on the URL. It is simple and it works, and for a kiosk session that is locked down anyway, it is perfectly safe. This, however, is not possible on the 7000 series as the entire login page is not a form - it is a fairly empty piece of HTML that is then populated with DIVs by a lot of JavaScript.

Firefox, firebug and greasemonkey to the rescue! Using firebug I managed to figure out how to fill in the username and password values in the input fields and call the .click() method on the "login" button. To my surprise, even though the username and password fields were visibly filled in correctly, the click on the button prompted an error messaage saying I should "Enter a username". It seems someone really went out of their way to make sure that I would not get any real work done today...

After reading a lot of the JavaScript that was used to build up the login page, I could see that the "keyup" event was significant. It caused the input elemen .value to be assigned to some other variable which was then later used in other methods for the actual user authentication. Calling all those methods in the right order and even accessing them turned out to be a bit out of my JavaScript abilities.

In order to get the login code to run, I simply assigned the username of the kiosk user to the username input element .value, then create a UIEvent of type keyup and dispatch it to that element. Then the same is done for the password input, and finally the .click() method is called on the login button. This solved the problem in my test setup.

Then, a greasemonkey .user.js was created to automate this whenever the logon page would be shown. This, however, did not work. Of course, since the page is almost blank once it finishes loading and greasemonkey runs the JavaScritp that I supplied, there is no way my code can find the username and password entries - they simply do not exist yet. The JavaScript referenced from the nearly empty page must finish executing first. The solution - ugly but functional - is to delay the execution of my code by five seconds. This gives plenty of time for the page to materialize.

So, if you decide to purchase a Sun Unified 7000 series storage system and you want a kiosk user to access the dashboard, you can download the greasemonkey user script here.