Skip to content

Commit 1e59bbd

Browse files
committed
Fix subprocess.Popen(..., shell=True) using the wrong shell.
1 parent 2c28aa3 commit 1e59bbd

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/Python-3.3.3-android-misc.patch

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,28 @@ diff -ru Python-3.3.3/Lib/platform.py Python-3.3.3-android/Lib/platform.py
151151
return distname,version,id
152152

153153
_release_filename = re.compile(r'(\w+)[-_](release|version)', re.ASCII)
154+
diff -ru Python-3.3.3/Lib/subprocess.py Python-3.3.3-android/Lib/subprocess.py
155+
--- Python-3.3.3/Lib/subprocess.py 2013-11-17 07:22:39.000000000 +0000
156+
+++ Python-3.3.3-android/Lib/subprocess.py 2014-08-01 23:31:05.711735647 +0000
157+
@@ -1343,9 +1343,18 @@
158+
args = list(args)
159+
160+
if shell:
161+
- args = ["/bin/sh", "-c"] + args
162+
if executable:
163+
- args[0] = executable
164+
+ main = executable
165+
+ elif os.path.isfile('/bin/sh'):
166+
+ main = '/bin/sh'
167+
+ else:
168+
+ import platform
169+
+ if platform.linux_distribution()[0] == 'Android':
170+
+ main = '/system/bin/sh'
171+
+ else:
172+
+ raise RuntimeError('Could not find shell binary to execute command with.')
173+
+
174+
+ args = [main, "-c"] + args
175+
176+
if executable is None:
177+
executable = args[0]
154178

0 commit comments

Comments
 (0)