Closed Bug 895153 Opened 11 years ago Closed 11 years ago

[mozdevice] shell command with root=True does not work on B2G

Categories

(Testing :: Mozbase, defect)

25 Branch
Other
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: zcampbell, Unassigned)

References

Details

Performing this command on B2G does not work:

File "/home/zacdev/Mozilla/gaia-ui-tests/gaiatest/gaia_test.py", line 406, in stop_b2g
    self.manager.shellCheckOutput(['stop', 'b2g'], root=True)
  File "/home/zacdev/.virtualenvs/gaia-ui-35/local/lib/python2.7/site-packages/mozdevice-0.27-py2.7.egg/mozdevice/devicemanager.py", line 374, in shellCheckOutput
    raise DMError("Non-zero return code for command: %s (output: '%s', retval: '%s')" % (cmd, output, retval))
TEST-UNEXPECTED-FAIL | test_fmradio_turn_on_off.py TestFMRadioTurnOnOff.test_turn_radio_on_off | DMError: Non-zero return code for command: ['stop', 'b2g'] (output: 'su: exec failed for stop b2g Error:No such file or directory', retval: '254')


I tried directly from the command line:
$ adb shell su -c "stop b2g"
su: exec failed for stop b2g Error:No such file or directory

OTOH these do work:
$ adb shell su -c stop b2g
$ adb shell "su -c stop b2g"
I believe 'su' isn't needed with B2G; at least for engineering builds, I thought adb always has root access.  Or have you found a case where that isn't true?
Yes I have found a case.

We are using a different flash script this time which is perhaps not setting the correct permissions to the b2g process.
It appears that we surround the command in quotes when running as root, but not otherwise. Running as root was introduced in bug 763497, do we recall why the quotes were necessary? The bug is primarily regarding the SUT implementation, so perhaps the ADB implementation has not been used much?

https://github.com/mozilla/mozbase/blob/master/mozdevice/mozdevice/devicemanagerADB.py#L107
Apparently this is causing issues with the hamachi builds too. Will, are you able to answer the question in comment 3?
Flags: needinfo?(wlachance)
I've noticed this too. It looks like on b2g, "su" doesn't actually do the normal shell quoting/escaping.

In this particular case, a simple solution may be not to pass root=True to the command. We really should figure out what's going on here though. Filed bug 916809 to look into that.
Flags: needinfo?(wlachance)
So I filed bug 916809 to see what's going on, and it does seem like the "su -c 'xxxx'" trick doesn't work on b2g (see the bug for details). However, mozdevice shouldn't use "su" if it can find a root shell (i.e. adb is running as root), which should always be the case with eng builds. So I'm not sure what's going on in this bug -- are you trying to run automation on a production phone? I'm not sure if that's ever going to work. If you really want/need to do that, I would recommend replacing su with sh and setuiding it to root.
See Also: → 916809
As I understand it, the Hamachi and Leo eng builds do not have sufficient access. Is this the case Zac? If so, perhaps we need a different bug to fix those builds.
Flags: needinfo?(zcampbell)
I'm not sure if this bug is valid anymore. Let me try the original test case again.
The original test case isn't valid anymore but at the time I worked around it by setting adb root before using mozdevice.

I guess I just presumed that using root=True means that you get root regardless. but it seems you need a root enabled build beforehand. so what is the point of root=True!?
Status: NEW → RESOLVED
Closed: 11 years ago
Flags: needinfo?(zcampbell)
Resolution: --- → INVALID
(In reply to Zac C (:zac) from comment #9)
> The original test case isn't valid anymore but at the time I worked around
> it by setting adb root before using mozdevice.
> 
> I guess I just presumed that using root=True means that you get root
> regardless. but it seems you need a root enabled build beforehand. so what
> is the point of root=True!?

It is possible for some commands to run without unprivileged on Android, which is handy for running things like mochitest on unrooted devices. Setting "root=True" is an indication that the command *requires* root.
You need to log in before you can comment on or make changes to this bug.