From 89e4dd6420d156a23e2cab3dacf9e3d157073d15 Mon Sep 17 00:00:00 2001 From: Lars Kruse Date: Sun, 10 Jun 2018 21:40:04 +0200 Subject: [PATCH] kvm_net: avoid shell when using Popen --- plugins/libvirt/kvm_net | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/libvirt/kvm_net b/plugins/libvirt/kvm_net index e03794ba..1399fdb5 100755 --- a/plugins/libvirt/kvm_net +++ b/plugins/libvirt/kvm_net @@ -96,9 +96,9 @@ def fetch(vms): def detect_kvm(): """ Check if kvm is installed """ - kvm = Popen("which kvm", shell=True, stdout=PIPE) + kvm = Popen(["which", "kvm"], stdout=PIPE) kvm.communicate() - return not bool(kvm.returncode) + return kvm.returncode == 0 def find_vm_names(pids): @@ -130,7 +130,7 @@ def list_pids(): @return a list of pids from running kvm """ - pid = Popen("pidof qemu-kvm qemu-system-x86_64 kvm", shell=True, stdout=PIPE) + pid = Popen(["pidof", "qemu-kvm", "qemu-system-x86_64", "kvm"], stdout=PIPE) return pid.communicate()[0].decode().split()