Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
fix the invocation of mock shell
Browse files Browse the repository at this point in the history
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.

Closes #74

Signed-off-by: Michal Toman <[email protected]>
  • Loading branch information
mtoman committed Mar 11, 2015
1 parent d796769 commit 52be632
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions src/lib/retrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
24 changes: 12 additions & 12 deletions src/retrace-server-worker
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -533,15 +533,15 @@ 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)
crash_kmem_f = None

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)
Expand All @@ -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)
Expand Down

0 comments on commit 52be632

Please sign in to comment.