Michal Toman a4d48d5
From d344a5ade872ba59ab18fdc73bff1de6ddf1fbc9 Mon Sep 17 00:00:00 2001
Michal Toman a4d48d5
From: Michal Toman <michal.toman@gmail.com>
Michal Toman a4d48d5
Date: Wed, 11 Mar 2015 09:23:36 +0000
Michal Toman a4d48d5
Subject: [PATCH] fix the invocation of mock shell
Michal Toman a4d48d5
Michal Toman a4d48d5
Formerly mock shell has taken all the excessive arguments
Michal Toman a4d48d5
from the command line and merged them into the resulting
Michal Toman a4d48d5
command executed in the chrooted shell. This changed
Michal Toman a4d48d5
and mock shell now only accepts a single command line
Michal Toman a4d48d5
argument - the whole command line to be forwarded to
Michal Toman a4d48d5
the chrooted shell.
Michal Toman a4d48d5
Michal Toman a4d48d5
Signed-off-by: Michal Toman <michal.toman@gmail.com>
Michal Toman a4d48d5
---
Michal Toman a4d48d5
 src/lib/retrace.py        | 12 ++++++------
Michal Toman a4d48d5
 src/retrace-server-worker | 24 ++++++++++++------------
Michal Toman a4d48d5
 2 files changed, 18 insertions(+), 18 deletions(-)
Michal Toman a4d48d5
Michal Toman a4d48d5
diff --git a/src/lib/retrace.py b/src/lib/retrace.py
Michal Toman a4d48d5
index 772b638..392d1cd 100644
Michal Toman a4d48d5
--- a/src/lib/retrace.py
Michal Toman a4d48d5
+++ b/src/lib/retrace.py
Michal Toman a4d48d5
@@ -419,21 +419,21 @@ def run_gdb(savedir):
Michal Toman a4d48d5
 
Michal Toman a4d48d5
     with open(os.devnull, "w") as null:
Michal Toman a4d48d5
         child = Popen(["/usr/bin/mock", "shell", "--configdir", savedir,
Michal Toman a4d48d5
-                       "--", "ls", "'%s'" % executable],
Michal Toman a4d48d5
+                       "--", "ls '%s'" % executable],
Michal Toman a4d48d5
                        stdout=PIPE, stderr=null)
Michal Toman a4d48d5
         output = child.communicate()[0]
Michal Toman a4d48d5
         if output.strip() != executable:
Michal Toman a4d48d5
             raise Exception("The appropriate package set could not be installed")
Michal Toman a4d48d5
 
Michal Toman a4d48d5
         chmod = call(["/usr/bin/mock", "shell", "--configdir", savedir,
Michal Toman a4d48d5
-                      "--", "/bin/chmod", "a+r", "'%s'" % executable],
Michal Toman a4d48d5
+                      "--", "/bin/chmod a+r '%s'" % executable],
Michal Toman a4d48d5
                       stdout=null, stderr=null)
Michal Toman a4d48d5
 
Michal Toman a4d48d5
         if chmod != 0:
Michal Toman a4d48d5
             raise Exception, "Unable to chmod the executable"
Michal Toman a4d48d5
 
Michal Toman a4d48d5
         child = Popen(["/usr/bin/mock", "shell", "--configdir", savedir,
Michal Toman a4d48d5
-                       "--", "ls", "'%s'" % EXPLOITABLE_PLUGIN_PATH],
Michal Toman a4d48d5
+                       "--", "ls '%s'" % EXPLOITABLE_PLUGIN_PATH],
Michal Toman a4d48d5
                        stdout=PIPE, stderr=null)
Michal Toman a4d48d5
         add_exploitable = child.communicate()[0].strip() == EXPLOITABLE_PLUGIN_PATH
Michal Toman a4d48d5
 
Michal Toman a4d48d5
@@ -461,13 +461,13 @@ def run_gdb(savedir):
Michal Toman a4d48d5
             raise Exception("Unable to copy GDB launcher into chroot")
Michal Toman a4d48d5
 
Michal Toman a4d48d5
         chmod = call(["/usr/bin/mock", "--configdir", savedir, "shell",
Michal Toman a4d48d5
-                      "--", "/bin/chmod", "a+rx", "/var/spool/abrt/gdb.sh"],
Michal Toman a4d48d5
+                      "--", "/bin/chmod a+rx /var/spool/abrt/gdb.sh"],
Michal Toman a4d48d5
                      stdout=null, stderr=null)
Michal Toman a4d48d5
         if chmod:
Michal Toman a4d48d5
             raise Exception("Unable to chmod GDB launcher")
Michal Toman a4d48d5
 
Michal Toman a4d48d5
         child = Popen(["/usr/bin/mock", "shell", "--configdir", savedir,
Michal Toman a4d48d5
-                       "--", "su", "mockbuild", "-c", "'/bin/sh /var/spool/abrt/gdb.sh'",
Michal Toman a4d48d5
+                       "--", "su mockbuild -c '/bin/sh /var/spool/abrt/gdb.sh'",
Michal Toman a4d48d5
                        # redirect GDB's stderr, ignore mock's stderr
Michal Toman a4d48d5
                        "2>&1"], stdout=PIPE, stderr=null)
Michal Toman a4d48d5
 
Michal Toman a4d48d5
@@ -712,7 +712,7 @@ def prepare_debuginfo(vmcore, chroot=None, kernelver=None):
Michal Toman a4d48d5
     if chroot:
Michal Toman a4d48d5
         with open(os.devnull, "w") as null:
Michal Toman a4d48d5
             child = Popen(["/usr/bin/mock", "--configdir", chroot, "shell",
Michal Toman a4d48d5
-                           "--", "crash", "-s", vmcore, vmlinux],
Michal Toman a4d48d5
+                           "--", "crash -s %s %s" % (vmcore, vmlinux)],
Michal Toman a4d48d5
                            stdin=PIPE, stdout=PIPE, stderr=null)
Michal Toman a4d48d5
     else:
Michal Toman a4d48d5
         child = Popen(["crash", "-s", vmcore, vmlinux], stdin=PIPE, stdout=PIPE, stderr=STDOUT)
Michal Toman a4d48d5
diff --git a/src/retrace-server-worker b/src/retrace-server-worker
Michal Toman a4d48d5
index dd1e10f..931888a 100755
Michal Toman a4d48d5
--- a/src/retrace-server-worker
Michal Toman a4d48d5
+++ b/src/retrace-server-worker
Michal Toman a4d48d5
@@ -335,10 +335,10 @@ def start_retrace():
Michal Toman a4d48d5
     retrace_run(25, ["/usr/bin/mock", "init", "--configdir", task.get_savedir()])
Michal Toman a4d48d5
     if CONFIG["UseFafPackages"]:
Michal Toman a4d48d5
         retrace_run(26, ["/usr/bin/mock", "--configdir", task.get_savedir(), "shell", "--",
Michal Toman a4d48d5
-                         "bash", "-c", "'for PKG in /packages/*; do rpm2cpio \\$PKG | " \
Michal Toman a4d48d5
-                         "cpio -muid --quiet; done'"])
Michal Toman a4d48d5
+                         "bash -c 'for PKG in /packages/*; "
Michal Toman a4d48d5
+                         "do rpm2cpio $PKG | cpio -muid --quiet; done'"])
Michal Toman a4d48d5
     retrace_run(27, ["/usr/bin/mock", "--configdir", task.get_savedir(), "shell",
Michal Toman a4d48d5
-                     "--", "chgrp", "-R", "mockbuild", "/var/spool/abrt/crash"])
Michal Toman a4d48d5
+                     "--", "chgrp -R mockbuild /var/spool/abrt/crash"])
Michal Toman a4d48d5
 
Michal Toman a4d48d5
     # generate backtrace
Michal Toman a4d48d5
     task.set_status(STATUS_BACKTRACE)
Michal Toman a4d48d5
@@ -405,7 +405,7 @@ def mock_find_vmlinux(cfgdir, candidates):
Michal Toman a4d48d5
     with open(os.devnull, "w") as null:
Michal Toman a4d48d5
         for cand in candidates:
Michal Toman a4d48d5
             child = Popen(["/usr/bin/mock", "--configdir", cfgdir, "shell", "--",
Michal Toman a4d48d5
-                           "test", "-f", cand, "&&", "echo", cand], stdout=PIPE, stderr=null)
Michal Toman a4d48d5
+                           "test -f %s && echo %s" % (cand, cand)], stdout=PIPE, stderr=null)
Michal Toman a4d48d5
             output = child.communicate()[0].strip()
Michal Toman a4d48d5
             child.wait()
Michal Toman a4d48d5
             if output == cand:
Michal Toman a4d48d5
@@ -517,14 +517,14 @@ def start_vmcore():
Michal Toman a4d48d5
             # generate the log
Michal Toman a4d48d5
             with open(os.devnull, "w") as null:
Michal Toman a4d48d5
                 child = Popen(["/usr/bin/mock", "--configdir", cfgdir, "shell", "--",
Michal Toman a4d48d5
-                               "crash", "--minimal", "-s", vmcore, vmlinux],
Michal Toman a4d48d5
+                               "crash --minimal -s %s %s" % (vmcore, vmlinux)],
Michal Toman a4d48d5
                               stdin=PIPE, stdout=PIPE, stderr=null)
Michal Toman a4d48d5
                 kernellog = child.communicate("log\nquit\n")[0]
Michal Toman a4d48d5
                 if child.wait():
Michal Toman a4d48d5
                     log_warn("crash 'log' exitted with %d" % child.returncode)
Michal Toman a4d48d5
 
Michal Toman a4d48d5
                 child = Popen(["/usr/bin/mock", "--configdir", cfgdir, "shell", "--",
Michal Toman a4d48d5
-                               "crash", "-s", vmcore, vmlinux], stdin=PIPE, stdout=PIPE, stderr=null)
Michal Toman a4d48d5
+                               "crash -s %s %s" % (vmcore, vmlinux)], stdin=PIPE, stdout=PIPE, stderr=null)
Michal Toman a4d48d5
                 crash_bt_a = child.communicate("bt -a\nquit\n")[0]
Michal Toman a4d48d5
                 if child.wait():
Michal Toman a4d48d5
                     log_warn("crash 'bt -a' exitted with %d" % child.returncode)
Michal Toman a4d48d5
@@ -533,7 +533,7 @@ def start_vmcore():
Michal Toman a4d48d5
                 crash_kmem_f = None
Michal Toman a4d48d5
                 if CONFIG["VmcoreRunKmem"] == 1:
Michal Toman a4d48d5
                     child = Popen(["/usr/bin/mock", "--configdir", cfgdir, "shell", "--",
Michal Toman a4d48d5
-                                   "crash", "-s", vmcore, vmlinux], stdin=PIPE, stdout=PIPE, stderr=null)
Michal Toman a4d48d5
+                                   "crash -s %s %s" % (vmcore, vmlinux)], stdin=PIPE, stdout=PIPE, stderr=null)
Michal Toman a4d48d5
                     crash_kmem_f = child.communicate("kmem -f\nquit\n")[0]
Michal Toman a4d48d5
                     if child.wait():
Michal Toman a4d48d5
                         log_warn("crash 'kmem -f' exitted with %d" % child.returncode)
Michal Toman a4d48d5
@@ -541,7 +541,7 @@ def start_vmcore():
Michal Toman a4d48d5
 
Michal Toman a4d48d5
                 if CONFIG["VmcoreRunKmem"] == 2:
Michal Toman a4d48d5
                     child = Popen(["/usr/bin/mock", "--configdir", cfgdir, "shell", "--",
Michal Toman a4d48d5
-                                   "crash", "-s", vmcore, vmlinux], stdin=PIPE, stdout=PIPE, stderr=null)
Michal Toman a4d48d5
+                                   "crash -s %s %s" % (vmcore, vmlinux)], stdin=PIPE, stdout=PIPE, stderr=null)
Michal Toman a4d48d5
                     crash_kmem_f = child.communicate("set hash off\nkmem -f\nset hash on\nquit\n")[0]
Michal Toman a4d48d5
                     if child.wait():
Michal Toman a4d48d5
                         log_warn("crash 'kmem -f' exitted with %d" % child.returncode)
Michal Toman a4d48d5
@@ -550,28 +550,28 @@ def start_vmcore():
Michal Toman a4d48d5
                 crash_kmem_z = None
Michal Toman a4d48d5
                 if CONFIG["VmcoreRunKmem"] == 3:
Michal Toman a4d48d5
                     child = Popen(["/usr/bin/mock", "--configdir", cfgdir, "shell", "--",
Michal Toman a4d48d5
-                                   "crash", "-s", vmcore, vmlinux], stdin=PIPE, stdout=PIPE, stderr=null)
Michal Toman a4d48d5
+                                   "crash -s %s %s" % (vmcore, vmlinux)], stdin=PIPE, stdout=PIPE, stderr=null)
Michal Toman a4d48d5
                     crash_kmem_z = child.communicate("kmem -z\nquit\n")[0]
Michal Toman a4d48d5
                     if child.wait():
Michal Toman a4d48d5
                         log_warn("crash 'kmem -z' exitted with %d" % child.returncode)
Michal Toman a4d48d5
                         crash_kmem_z = None
Michal Toman a4d48d5
 
Michal Toman a4d48d5
                 child = Popen(["/usr/bin/mock", "--configdir", cfgdir, "shell", "--",
Michal Toman a4d48d5
-                               "crash", "-s", vmcore, vmlinux], stdin=PIPE, stdout=PIPE, stderr=null)
Michal Toman a4d48d5
+                               "crash -s %s %s" % (vmcore, vmlinux)], stdin=PIPE, stdout=PIPE, stderr=null)
Michal Toman a4d48d5
                 crash_sys = child.communicate("sys\nquit\n")[0]
Michal Toman a4d48d5
                 if child.wait():
Michal Toman a4d48d5
                     log_warn("crash 'sys' exitted with %d" % child.returncode)
Michal Toman a4d48d5
                     crash_sys = None
Michal Toman a4d48d5
 
Michal Toman a4d48d5
                 child = Popen(["/usr/bin/mock", "--configdir", cfgdir, "shell", "--",
Michal Toman a4d48d5
-                               "crash", "-s", vmcore, vmlinux], stdin=PIPE, stdout=PIPE, stderr=null)
Michal Toman a4d48d5
+                               "crash -s %s %s" % (vmcore, vmlinux)], stdin=PIPE, stdout=PIPE, stderr=null)
Michal Toman a4d48d5
                 crash_sys_c = child.communicate("sys -c\nquit\n")[0]
Michal Toman a4d48d5
                 if child.wait():
Michal Toman a4d48d5
                     log_warn("crash 'sys -c' exitted with %d" % child.returncode)
Michal Toman a4d48d5
                     crash_sys_c = None
Michal Toman a4d48d5
 
Michal Toman a4d48d5
                 child = Popen(["/usr/bin/mock", "--configdir", cfgdir, "shell", "--",
Michal Toman a4d48d5
-                               "crash", "-s", vmcore, vmlinux], stdin=PIPE, stdout=PIPE, stderr=null)
Michal Toman a4d48d5
+                               "crash -s %s %s" % (vmcore, vmlinux)], stdin=PIPE, stdout=PIPE, stderr=null)
Michal Toman a4d48d5
                 crash_foreach_bt = child.communicate("foreach bt\nquit\n")[0]
Michal Toman a4d48d5
                 if child.wait():
Michal Toman a4d48d5
                     log_warn("crash 'foreach bt' exitted with %d" % child.returncode)
Michal Toman a4d48d5
-- 
Michal Toman a4d48d5
2.1.0
Michal Toman a4d48d5