Bug 1214812 - [mozdevice] - adb.py - do not prepend LD_LIBRARY_PATH to su commands, r=gbrown.

This commit is contained in:
Bob Clary 2015-12-01 14:25:12 -08:00
parent bf46f3d76a
commit 221de076d9

View File

@ -536,7 +536,6 @@ class ADBDevice(ADBCommand):
self._have_android_su = False
uid = 'uid=0'
cmd_id = 'LD_LIBRARY_PATH=/vendor/lib:/system/lib id'
# Is shell already running as root?
# Catch exceptions due to the potential for segfaults
# calling su when using an improperly rooted device.
@ -548,7 +547,7 @@ class ADBDevice(ADBCommand):
# Do we have a 'Superuser' sh like su?
try:
if self.shell_output("su -c '%s'" % cmd_id).find(uid) != -1:
if self.shell_output("su -c id").find(uid) != -1:
self._have_su = True
except ADBError:
self._logger.debug("Check for su failed")
@ -953,15 +952,15 @@ class ADBDevice(ADBCommand):
It is the caller's responsibilty to clean up by closing
the stdout and stderr temporary files.
"""
if root:
ld_library_path='LD_LIBRARY_PATH=/vendor/lib:/system/lib'
cmd = '%s %s' % (ld_library_path, cmd)
if self._have_root_shell:
pass
if root and not self._have_root_shell:
# If root was requested and we do not already have a root
# shell, then use the appropriate version of su to invoke
# the shell cmd. Prefer Android's su version since it may
# falsely report support for su -c.
if self._have_android_su:
cmd = "su 0 %s" % cmd
elif self._have_su:
cmd = "su -c \"%s\"" % cmd
elif self._have_android_su:
cmd = "su 0 \"%s\"" % cmd
else:
raise ADBRootError('Can not run command %s as root!' % cmd)