From 36c701b08fa40aa28c87943e7dfb28fbaa1aac81 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 1 Aug 2014 17:29:42 -0500 Subject: [PATCH] do not expand shell on subprocess --- gnupg/_meta.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gnupg/_meta.py b/gnupg/_meta.py index f11310c..00c3a68 100644 --- a/gnupg/_meta.py +++ b/gnupg/_meta.py @@ -31,7 +31,9 @@ import encodings ## See https://code.patternsinthevoid.net/?p=android-locale-hack.git import locale import os +import platform import psutil +import shlex import subprocess import sys import threading @@ -505,9 +507,16 @@ class GPGBase(object): """ ## see http://docs.python.org/2/library/subprocess.html#converting-an\ ## -argument-sequence-to-a-string-on-windows - cmd = ' '.join(self._make_args(args, passphrase)) + cmd = shlex.split(' '.join(self._make_args(args, passphrase))) log.debug("Sending command to GnuPG process:%s%s" % (os.linesep, cmd)) - return subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, + + if platform.system() == "Windows": + # TODO figure out what the hell is going on there. + expand_shell = True + else: + expand_shell = False + + return subprocess.Popen(cmd, shell=expand_shell, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env={'LANGUAGE': 'en'})