Closed
Bug 1021756
Opened 11 years ago
Closed 11 years ago
Allow to keep running adbd as root for ro.secure=1 & ro.debuggable=1 devices
Categories
(Firefox OS Graveyard :: Certification Suite, defect)
Firefox OS Graveyard
Certification Suite
Tracking
(Not tracked)
RESOLVED
FIXED
2.1 S2 (15aug)
People
(Reporter: jgriffin, Assigned: armenzg)
References
Details
Attachments
(2 files, 4 obsolete files)
2.36 KB,
patch
|
wlach
:
review+
|
Details | Diff | Splinter Review |
5.88 KB,
patch
|
wlach
:
review+
|
Details | Diff | Splinter Review |
According to the Taipei engineers, in some environments we should be running 'adb root' before attempting any operation that requires root access, to force adb on the phone into root mode.
We should probably be doing this every time we reboot the phone.
Assignee | ||
Updated•11 years ago
|
Assignee: nobody → armenzg
Comment 1•11 years ago
|
||
So adb root is a command run on the host.
Phones come up in user mode and allow the adb root command from the host to work have:
ro.secure=1
ro.debuggable=1
in their /default.prop file.
If you want adb to come up in root mode, then you can change ro.secure=1 to be ro.secure=0
This is typically part of the kernel's initrd image.
Note that production phones are normally released with ro.secure=1 and ro.debuggable=0
Reporter | ||
Comment 2•11 years ago
|
||
We have no ability to affect the builds in this context. We're trying to make the certification suite operate under the widest possible conditions, and the TAMs requested that we add this step. I know it may not always have the desired effect.
Comment 3•11 years ago
|
||
It seems that user builds (at least on the flame) are totally locked down, so there is no way to get a root shell.
I've been told that this is intentional.
Assignee | ||
Comment 4•11 years ago
|
||
jgriffin, do you have more info as to which engineers? or which environments?
I assume that we can change the devicemanagerADB to call "adb root" on the host before rebooting.
Reporter | ||
Comment 5•11 years ago
|
||
This was specifically noted as being needed for the non-phone device, however, Dan has been working on that and I'm not sure he needed to do it. Dan, did you need to run 'adb root' before running the cert suite on the non-phone device?
Flags: needinfo?(dminor)
Comment 6•11 years ago
|
||
(In reply to Jonathan Griffin (:jgriffin) from comment #5)
> This was specifically noted as being needed for the non-phone device,
> however, Dan has been working on that and I'm not sure he needed to do it.
> Dan, did you need to run 'adb root' before running the cert suite on the
> non-phone device?
We need to call 'adb root' to be able to uninstall apps through marionette on the non-phone device.
Flags: needinfo?(dminor)
Assignee | ||
Comment 7•11 years ago
|
||
(In reply to Dan Minor [:dminor] from comment #6)
> (In reply to Jonathan Griffin (:jgriffin) from comment #5)
> > This was specifically noted as being needed for the non-phone device,
> > however, Dan has been working on that and I'm not sure he needed to do it.
> > Dan, did you need to run 'adb root' before running the cert suite on the
> > non-phone device?
>
> We need to call 'adb root' to be able to uninstall apps through marionette
> on the non-phone device.
It seems like the config for the non-phone device is (rwood sent it to me):
ro.secure=1
ro.debuggable=1
Would running "adb root" change the value from ro.secure=1 to ro.secure=0?
I have failed miserably at finding somewhere where it explains what adb root actually does.
dminor, has running "adb root" before starting the cert suite worked for you?
I've tried using the device this morning but rwood and I could not figure out how to make it list under adb devices. What do you have for your udev rules? This is what I have:
SUBSYSTEM=="usb", ATTR{idVendor}=="2207", ATTR{idProduct}=="0006", MODE="0666", OWNER="armenzg"
On another note, the uninstall code seems to be the one of fxos_appgen [1]
It runs some javacript through marionette IIUC.
[1] https://github.com/mozilla-b2g/fxos-appgen/blob/master/fxos_appgen/generator.py#L249
Comment 8•11 years ago
|
||
Armen, I spent some time looking at this this afternoon, and I'm not getting consistent results, so I'm no longer sure if it is dependent upon 'adb root'. The first time I had problems, restarting as 'adb root' allowed the uninstall to work, but that doesn't seem to be the case now.
Did you add 0x2207 to your .android/adb_usb.ini file? I had to do that in order to get the device to work.
Assignee | ||
Comment 9•11 years ago
|
||
(In reply to Dan Minor [:dminor] from comment #8)
> Did you add 0x2207 to your .android/adb_usb.ini file? I had to do that in
> order to get the device to work.
Yes, I did as well.
Comment 10•11 years ago
|
||
ro.secure and ro.debuggable are read-only - so they never change.
When the system starts up with ro.secure=1 and ro.debuggable=1, then adb will be launched as the "shell" user. You can see this if you do:
> adb shell ps | grep adbd
> shell 392 1 4508 212 ffffffff 00000000 S /sbin/adbd
> adb shell
> shell@flame:/ $
The first column tells you the user that adbd is running as.
You'll also notice that your shell prompt ends with $. This is your indication that you have a "shell" user shell.
Now, if ro.debuggable is set to 1, then you're allowed to do 'adb root' and this will relaunch adbd under the root user:
> adb root
> restarting adbd as root
> adb shell ps | grep adbd
> root 844 1 4512 216 ffffffff 00016ce4 S /sbin/adbd
> adb shell
> root@flame:/ #
You'll also notice that your shell prompt ends in #. This is your indication that you have a "root" user shell.
Note that when you run from a script, you should always put adb wait-for-device after doing adb root.
If you have ro.secure=1 and ro.debuggable=0 then adb root won't work.
If you have ro.secure=0 then adb is launched under the root user to start with.
Comment 11•11 years ago
|
||
The results of adb root are lost each time the phone reboots (or whenever the adbd daemon is killed).
Comment 12•11 years ago
|
||
It no longer appears that my uninstall problems were caused by not running 'adb root'. I have some that consistently work and some that consistently fail, regardless of whether 'adb root' was used.
Comment 13•11 years ago
|
||
It looks like I might need 'adb root' for the first run on a newly flashed device. I'll try a few times to see if this is the case, or if I hit an intermittent success :)
Assignee | ||
Comment 14•11 years ago
|
||
This is the code I used to test it [1] and here's the output:
> adbd user shell
> adbd user root
[1]
from mozdevice import DeviceManagerADB
if __name__ == "__main__":
dm = DeviceManagerADB()
print "adbd user %s" % dm.processOwner("adbd")
dm = DeviceManagerADB(runAdbAsRoot=True)
print "adbd user %s" % dm.processOwner("adbd")
Attachment #8464219 -
Flags: review?(wlachance)
Assignee | ||
Comment 15•11 years ago
|
||
wlach, how do you feel about making this the default behaviour and escape it if a variable is set to not run as root?
+ logLevel=mozlog.ERROR, autoconnect=True, doNotRunAdbAsRoot=False, **kwargs):
...
+ if not doNotRunAdbAsRoot and self.processOwner("adbd") != "root":
Assignee | ||
Comment 16•11 years ago
|
||
Depending on the review, this patch might not be needed.
I would prefer adb to be always run as root. I think it will help people more in the long term rather than having them to realize that they should pass the extra parameter.
Comment 17•11 years ago
|
||
Comment on attachment 8464219 [details] [diff] [review]
If requested, run adbd as root
Review of attachment 8464219 [details] [diff] [review]:
-----------------------------------------------------------------
As discussed, let's put this code inside the certsuite, since it seems unlikely that we'll be using this functionality anywhere but there.
::: testing/mozbase/mozdevice/mozdevice/devicemanager.py
@@ +412,5 @@
> """
> if not isinstance(processName, basestring):
> raise TypeError("Process name %s is not a string" % processName)
>
> + process_info = None
Use camel case for variables inside mozdevice.
Attachment #8464219 -
Flags: review?(wlachance) → review-
Assignee | ||
Comment 18•11 years ago
|
||
After a second thought, the processInfo function is useful to me.
Otherwise I would have to duplicate the code in the cert suite.
Attachment #8464219 -
Attachment is obsolete: true
Attachment #8464222 -
Attachment is obsolete: true
Attachment #8464757 -
Flags: review?(wlachance)
Comment 19•11 years ago
|
||
Comment on attachment 8464757 [details] [diff] [review]
allow to request processInfo
Review of attachment 8464757 [details] [diff] [review]:
-----------------------------------------------------------------
Makes sense. r+ with nits addressed.
::: testing/mozbase/mozdevice/mozdevice/devicemanager.py
@@ +408,2 @@
> """
> + Returns None if the process does not exist on the device, otherwise.
This comment's a bit hard to parse. I'd suggest something more like:
Returns information on the process with processName.
Information on process is in tuple format: (pid, process path, user)
If a process with the specified name does not exist this function will return None.
@@ +442,4 @@
>
> + def processExist(self, processName):
> + """
> + Returns None if process does not exist, otherwise, it will
Please reset this to the previous comment: Returns True if process with name processName is running on device.
@@ +447,5 @@
> + """
> + processInfo = self.processInfo(processName)
> + if processInfo:
> + return processInfo[0]
> + else:
This 'else' clause is unnecessary and can safely be taken out, all python functions will return None if no value is given
Attachment #8464757 -
Flags: review?(wlachance) → review+
Assignee | ||
Comment 20•11 years ago
|
||
Assignee | ||
Comment 21•11 years ago
|
||
Would this approach work for you?
I have noticed that _haveSu is exactly the case scenario that we are trying to fix.
Attachment #8464949 -
Flags: feedback?(wlachance)
Comment 22•11 years ago
|
||
Comment on attachment 8464949 [details] [diff] [review]
adb_root_mc.diff
Review of attachment 8464949 [details] [diff] [review]:
-----------------------------------------------------------------
As discussed, I don't think this is going to work. _haveSu refers to whether the device has a su binary that is setuid root.
Attachment #8464949 -
Flags: feedback?(wlachance) → feedback-
Assignee | ||
Comment 23•11 years ago
|
||
Attachment #8464902 -
Attachment is obsolete: true
Attachment #8464949 -
Attachment is obsolete: true
Attachment #8465542 -
Flags: review?(wlachance)
Comment 24•11 years ago
|
||
Comment on attachment 8465542 [details] [diff] [review]
adb_as_root_mc.diff
Review of attachment 8465542 [details] [diff] [review]:
-----------------------------------------------------------------
Ok, I guess we needed this after all.
Attachment #8465542 -
Flags: review?(wlachance) → review+
Assignee | ||
Comment 25•11 years ago
|
||
Thanks wlach!
Devices that start with adb as shell rather than root (ro.secure=1 & ro.debuggable=1) fail to pass the cert:permissions test.
Should we check for such type of devices and fail if the user does not use a flag? (e.g. run.sh --run-adb-as-root) Or should we make cert.py to always run adb as root?
You can see current patch in https://github.com/mozilla-b2g/fxos-certsuite/pull/183
Reporter | ||
Comment 26•11 years ago
|
||
If there aren't any side effects of this (and I don't think there are), I think we should just always do this.
Assignee | ||
Comment 27•11 years ago
|
||
The adb tests have passed, however, I want to see it pass on try before landing tomorrow morning (I will be online a bit).
https://tbpl.mozilla.org/?tree=Try&rev=867dfc0e6700
After landing I will look into uploading it to pypi (perhaps a version bump is required or we can simply overwrite).
Assignee | ||
Comment 28•11 years ago
|
||
(In reply to Jonathan Griffin (:jgriffin) from comment #26)
> If there aren't any side effects of this (and I don't think there are), I
> think we should just always do this.
I have not been able to think of one.
Reporter | ||
Comment 29•11 years ago
|
||
(In reply to Armen Zambrano [:armenzg] (EDT/UTC-4) from comment #27)
> The adb tests have passed, however, I want to see it pass on try before
> landing tomorrow morning (I will be online a bit).
> https://tbpl.mozilla.org/?tree=Try&rev=867dfc0e6700
>
> After landing I will look into uploading it to pypi (perhaps a version bump
> is required or we can simply overwrite).
We should version bump; we never overwrite released versions.
Comment 30•11 years ago
|
||
(In reply to Jonathan Griffin (:jgriffin) from comment #26)
> If there aren't any side effects of this (and I don't think there are), I
> think we should just always do this.
As discussed I don't think we can do this as it will break using devicemanagerADB with unrooted Android devices. It should be kept optional.
Assignee | ||
Comment 31•11 years ago
|
||
(In reply to William Lachance (:wlach) from comment #30)
> (In reply to Jonathan Griffin (:jgriffin) from comment #26)
> > If there aren't any side effects of this (and I don't think there are), I
> > think we should just always do this.
>
> As discussed I don't think we can do this as it will break using
> devicemanagerADB with unrooted Android devices. It should be kept optional.
I don't recall that we agreed on that. As far as I know even if it was mandatory on mozdevice it should not break anything. We never figured out a breakage that I recall of.
Nevertheless, we're referring in this comment to the cert suite, not mozdevice. We will leave it as optional for mozdevice.
Comment 32•11 years ago
|
||
(In reply to Armen Zambrano [:armenzg] (EDT/UTC-4) from comment #31)
> (In reply to William Lachance (:wlach) from comment #30)
> > (In reply to Jonathan Griffin (:jgriffin) from comment #26)
> > > If there aren't any side effects of this (and I don't think there are), I
> > > think we should just always do this.
> >
> > As discussed I don't think we can do this as it will break using
> > devicemanagerADB with unrooted Android devices. It should be kept optional.
>
> I don't recall that we agreed on that. As far as I know even if it was
> mandatory on mozdevice it should not break anything. We never figured out a
> breakage that I recall of.
Running "adb root" on my Galaxy Nexus produces this error message and does not change state:
adbd cannot run as root in production builds
If we applied this logic unconditionally devicemanagerADB would always throw an error on these types of devices.
Comment 33•11 years ago
|
||
(In reply to William Lachance (:wlach) from comment #32)
> Running "adb root" on my Galaxy Nexus produces this error message and does
> not change state:
>
> adbd cannot run as root in production builds
>
> If we applied this logic unconditionally devicemanagerADB would always throw
> an error on these types of devices.
Right - that means rc.secure=1 and ro.debuggable=0 which is how production devices are normally.
They need to be "rooted" and/or unlocked first.
Some definitions of rooting only involve installing su which allows you to get root access. However, to get adb to relaunched as the root user requires modifying those ro. properties which are on the initial ram disk that's bundled with the kernel.
Assignee | ||
Comment 34•11 years ago
|
||
(In reply to William Lachance (:wlach) from comment #32)
> (In reply to Armen Zambrano [:armenzg] (EDT/UTC-4) from comment #31)
> > (In reply to William Lachance (:wlach) from comment #30)
> > > (In reply to Jonathan Griffin (:jgriffin) from comment #26)
> > > > If there aren't any side effects of this (and I don't think there are), I
> > > > think we should just always do this.
> > >
> > > As discussed I don't think we can do this as it will break using
> > > devicemanagerADB with unrooted Android devices. It should be kept optional.
> >
> > I don't recall that we agreed on that. As far as I know even if it was
> > mandatory on mozdevice it should not break anything. We never figured out a
> > breakage that I recall of.
>
> Running "adb root" on my Galaxy Nexus produces this error message and does
> not change state:
>
> adbd cannot run as root in production builds
>
> If we applied this logic unconditionally devicemanagerADB would always throw
> an error on these types of devices.
I see what you mean now.
Anyone know if we're going to run the cert suite on non-rooted devices? (Android production phones mainly).
As far as I know all devices run through the cert suite are supposed to be Firefox OS phones which either start adb as root or they are allowed to run "adb root" to restart it.
If this is not the case, please let me know what we should do in such cases.
Reporter | ||
Comment 35•11 years ago
|
||
We will never run the cert suite on Android, and if it isn't rooted and 'adb root' isn't sufficient to root it, the tests will fail, so it should be ok to run this command always in the context of the cert suite.
Assignee | ||
Comment 36•11 years ago
|
||
http://hg.mozilla.org/integration/mozilla-inbound/rev/0dff8ac3f629
http://hg.mozilla.org/integration/mozilla-inbound/rev/1cb5bd26726e
Whiteboard: [leave open]
Assignee | ||
Comment 37•11 years ago
|
||
For some reason critic did not pick up my pull request:
https://github.com/mozilla-b2g/fxos-certsuite/pull/183
dminor, does this look good to you?
Flags: needinfo?(dminor)
Assignee | ||
Comment 39•11 years ago
|
||
Great!
After it merges to m-c, this will be done.
Whiteboard: [leave open]
Assignee | ||
Updated•11 years ago
|
Summary: Call 'adb root' each time we reboot the device → Allow to keep running adbd as root for ro.secure=1 & ro.debuggable=1 devices
Reporter | ||
Comment 40•11 years ago
|
||
Merged to v1.3.
https://hg.mozilla.org/mozilla-central/rev/1cb5bd26726e
https://hg.mozilla.org/mozilla-central/rev/0dff8ac3f629
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → 2.1 S2 (15aug)
You need to log in
before you can comment on or make changes to this bug.
Description
•