From e25bd14690a2d242dcfda09c925263eeb40a20e4 Mon Sep 17 00:00:00 2001 From: Jan Vcelak Date: Fri, 30 Nov 2012 17:11:08 +0100 Subject: [PATCH] utils: don't run execute() through shell --- tuned/utils/commands.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tuned/utils/commands.py b/tuned/utils/commands.py index 436680e..d7eef69 100644 --- a/tuned/utils/commands.py +++ b/tuned/utils/commands.py @@ -31,13 +31,16 @@ def read_file(f): except (OSError,IOError) as e: log.error("Reading %s error: %s" % (f, e)) return old_value - def execute(args): + if not hasattr(execute, "_environment"): + execute._environment = os.environ.copy() + execute._environment["LC_ALL"] = "C" + log.debug("Executing %s." % str(args)) out = "" try: - proc = Popen("LANG= " + " ".join(args), stdout = PIPE, stderr = PIPE, shell = True) + proc = Popen(args, stdout=PIPE, stderr=PIPE, env=execute._environment) out, err = proc.communicate() if proc.returncode: