The subprocess.run command avoids using the shell and so is robust
should sys.argv contain any whitespace or unexpected shell meta
characters.
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
import os
import re
+import subprocess
import sys
import tempfile
os.environ['VIR_TEST_FILE_ACCESS_OUTPUT'] = access_file
-test = ' '.join(sys.argv[1:])
+proc = subprocess.run(sys.argv[1:])
-ret = os.system(test)
-
-if ret != 0 or os.read(access_fd, 10) == b'':
+if proc.returncode != 0 or os.read(access_fd, 10) == b'':
os.close(access_fd)
os.remove(access_file)
sys.exit(ret)