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