mirror of
https://github.com/gryf/mc_adbfs.git
synced 2025-12-18 20:10:21 +01:00
Fix for new version of adb command
Previously it was possible (most probably unintentionally) to perform command which gives listing of directory contents on the output: $ adb shell su -c toolbox ls / acct cache charger config ... Using such syntax in newer versions of adb, return an error: $ adb shell su -c toolbox ls / Unknown id: ls It is needed to quote argument passed to the 'shell' parameter on adb, like: $ adb shell 'su -c "toolbox ls /"' acct cache charger config ... This patch fixes this issue for both adb versions.
This commit is contained in:
26
adbfs
26
adbfs
@@ -63,10 +63,10 @@ class Conf(object):
|
|||||||
|
|
||||||
def get_the_box(self):
|
def get_the_box(self):
|
||||||
"""Detect if we dealing with busybox or toolbox"""
|
"""Detect if we dealing with busybox or toolbox"""
|
||||||
|
cmd = 'adb shell which'.split()
|
||||||
try:
|
try:
|
||||||
with open(os.devnull, 'w') as fnull:
|
with open(os.devnull, 'w') as fnull:
|
||||||
result = subprocess.check_output('adb shell which '
|
result = subprocess.check_output(cmd + ['busybox'],
|
||||||
'busybox'.split(),
|
|
||||||
stderr=fnull)
|
stderr=fnull)
|
||||||
if 'busybox' in result:
|
if 'busybox' in result:
|
||||||
self.box = Conf.boxes['busybox']
|
self.box = Conf.boxes['busybox']
|
||||||
@@ -81,8 +81,7 @@ class Conf(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
with open(os.devnull, 'w') as fnull:
|
with open(os.devnull, 'w') as fnull:
|
||||||
result = subprocess.check_output('adb shell which '
|
result = subprocess.check_output(cmd + ['toolbox'],
|
||||||
'toolbox'.split(),
|
|
||||||
stderr=fnull)
|
stderr=fnull)
|
||||||
|
|
||||||
if 'toolbox' in result:
|
if 'toolbox' in result:
|
||||||
@@ -251,11 +250,10 @@ class Adb(object):
|
|||||||
|
|
||||||
def __su_check(self):
|
def __su_check(self):
|
||||||
"""Check if we are able to get elevated privileges"""
|
"""Check if we are able to get elevated privileges"""
|
||||||
|
cmd = 'adb shell su -c whoami'.split()
|
||||||
try:
|
try:
|
||||||
with open(os.devnull, 'w') as fnull:
|
with open(os.devnull, 'w') as fnull:
|
||||||
result = subprocess.check_output('adb shell su -c '
|
result = subprocess.check_output(cmd, stderr=fnull)
|
||||||
'whoami'.split(),
|
|
||||||
stderr=fnull)
|
|
||||||
|
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
return
|
return
|
||||||
@@ -302,12 +300,10 @@ class Adb(object):
|
|||||||
|
|
||||||
def _retrieve_single_dir_list(self, dir_):
|
def _retrieve_single_dir_list(self, dir_):
|
||||||
"""Retrieve file list using adb"""
|
"""Retrieve file list using adb"""
|
||||||
|
lscmd = self.conf.box['rls'].format(dir_)
|
||||||
if self._got_root:
|
if self._got_root:
|
||||||
command = ['adb', 'shell', 'su', '-c',
|
lscmd = 'su -c "{}"'.format(lscmd)
|
||||||
self.conf.box['rls'].format(dir_)]
|
command = ['adb', 'shell', lscmd]
|
||||||
else:
|
|
||||||
command = ['adb', 'shell']
|
|
||||||
command += self.conf.box['rls'].format(dir_).split(' ')
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if self.conf.debug:
|
if self.conf.debug:
|
||||||
@@ -367,9 +363,9 @@ class Adb(object):
|
|||||||
lscmd = self.conf.box['rls'].format(root.filepath)
|
lscmd = self.conf.box['rls'].format(root.filepath)
|
||||||
|
|
||||||
if self._got_root:
|
if self._got_root:
|
||||||
command = ['adb', 'shell', 'su', '-c', lscmd]
|
lscmd = 'su -c "{}"'.format(lscmd)
|
||||||
else:
|
|
||||||
command = ['adb', 'shell'] + lscmd.split()
|
command = ['adb', 'shell', lscmd]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if self.conf.debug:
|
if self.conf.debug:
|
||||||
|
|||||||
Reference in New Issue
Block a user