View Single Post
Posts: 2,225 | Thanked: 3,822 times | Joined on Jun 2010 @ Florida
#1
This has always been doable on the N900, but as far as I know no one's ever really bothered doing it. I knew for years it was possible in principle, knew for about a year how to do it, but didn't have the occasion to.

Well, I just "upgraded" back to the N900 from the N9 (you served me well N9, I still love you, but you're no N900), and this time around I decided "what the heck, I could use these 9+ free hours to be productive, OR I could script up this thing that no one really needs but is sorta fun and allows me to 'bootstrap' up to root access on a stock N900 without any external help or tools. Oooo and even better, then I could spend another 12+ hours writing up a thorough tutorial about how I did it, because people might enjoy reading it and/or learn something from it." (Of course taking this much time to write something was also helpful to me already, it caused me to spend a lot more time contemplating/reconsidering/reviewing/rechecking what I did/decided.)

Normally, when we want to get root access on our N900s right after a fresh flash, we have a couple of options: install rootsh/sudser/sshd etc, any package that directly or indirectly opens a way for us to get a root shell on our N900s, or go the 'official' way and turn on R&D mode, which lets us through the Nokia-included /usr/sbin/gainroot command. But sometimes you might not have access to either for whatever reason, and maybe, just maybe, if/when that time comes you'll remember enough details from this post that you'll be able to redo it from memory. Or more likely, you'll just find this post informative/interesting for other reasons.

For starters, let's explain the broad-strokes reasoning:

We know that the stock N900 will have the following things:
1. busybox (has a decent, if smallish, set of standard UNIX-y tools built in)
2. XTerm (allows you access to #1)
3. hildon-application-manager (The "App Manager" app, hereby referred to as "HAM". HAM will install any valid .deb file we give it that also matches HAM's own special criteria. When it does so, it will do the install process with root privileges, including any of the .deb's {pre/post}{rm/inst} scripts - this is why all those aforementioned packages in the repos are able do set us up with root access one way or another.)

So, in principle, all we need is:
1. To write a script which, when run as root, will change the system in a way that enables us to become root. (There are many different ways to do this, but once we know how we can trivially do this with a plain-text editor)
2. To wrap that script up in .deb file which will contain the script as its 'preinst' or 'postinst' script. (This is the hard part, because we have to know the layout of a .deb package - we can't rely on automated tools.)

Then we just tell HAM to install that .deb file, either by navigating to it using built in File Manager, or by running the dbus command to invoke HAM's install-this-deb-file behavior through that.

For those who are interested: See next posts for much more detail:
My preferred 'get access to root' configuration, and reasoning
.deb format basics and how I did all the deb metadata files
.ar format basics and how to assemble+install the .deb
Example implementation

P.S. I hope it's obvious, but if you feel this is over your head, by all means, feel free to ask questions, but please don't go trying this on your devices if you don't already feel comfortable using the shell/xterm on your N900(s). For example, if look at the command at the end of the assemble+install section, and don't realize that "$DEB" is a variable for the .deb file (which you must either define in the shell with a previous command, or replace with the actual filepath in the command itself), then you probably want to take some more time to understand what the shell commands mean before proceeding. Similarly, if you screw up editing the /etc/sudoers file, (or any files in /etc/sudoers.d/), then you can lock yourself out of root access.
__________________
If you want to donate in support of anything that I do, you can do so with either of these options:
PayPal | Bitcoin: 1J4XG2z97iFEKNZXThHdFHq6AeyWEHs8BJ | [Will add other donation options eventually]

Last edited by Mentalist Traceur; 2015-01-19 at 11:50. Reason: Edit1: Adding links to later posts | Edit2: Fixing links to later posts
 

The Following 20 Users Say Thank You to Mentalist Traceur For This Useful Post: