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

Commit

Permalink
Remove rpm2cpio part from podman retrace
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Fabik <[email protected]>
  • Loading branch information
michalfabik committed Jan 29, 2020
1 parent a4876a1 commit 2a00fdd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 65 deletions.
4 changes: 2 additions & 2 deletions src/config/retrace-server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ VmcoreDumpLevel = 0
# Requires support from ABRT Server
UseFafPackages = 0

# Where to hardlink faf packages
FafLinkDir = /var/spool/faf/retrace-tmp
# Spool directory for FAF packages
FafLinkDir = /var/spool/faf

# Run the retrace in a Mock chroot (default), or a Podman container
# (mock|podman)
Expand Down
2 changes: 1 addition & 1 deletion src/retrace/config.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Config(object):
"KernelChrootRepo": "http://dl.fedoraproject.org/pub/fedora/linux/releases/16/Everything/$ARCH/os/",
"UseFafPackages": False,
"RetraceEnvironment": "mock",
"FafLinkDir": "/var/spool/faf/retrace-tmp",
"FafLinkDir": "/var/spool/faf",
"AuthGroup": "retrace",
"EmailNotify": False,
"EmailNotifyFrom": "retrace@localhost",
Expand Down
32 changes: 6 additions & 26 deletions src/retrace/retrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def parse_http_gettext(lang, charset):
return result


def run_gdb(savedir, plugin, repopath, fafrepo=None, taskid=None):
def run_gdb(savedir, plugin, repopath, taskid=None):
# exception is caught on the higher level
exec_file = open(os.path.join(savedir, "crash", "executable"), "r")
executable = exec_file.read(ALLOWED_FILES["executable"])
Expand Down Expand Up @@ -398,8 +398,9 @@ def run_gdb(savedir, plugin, repopath, fafrepo=None, taskid=None):
os.path.join(savedir, RetraceTask.DOCKERFILE),
"--volume=%s:%s:ro" % (repopath, repopath)]
if CONFIG["UseFafPackages"]:
log_debug("Using FAF repository '%s'" % fafrepo)
podman_build_call.append("--volume=%s:/var/spool/abrt/faf-packages" % fafrepo)
faf_link_dir = CONFIG["FafLinkDir"]
log_debug("Using FAF repository")
podman_build_call.append("--volume=%s:%s" % (faf_link_dir, faf_link_dir))

img_cont_id = str(taskid)

Expand All @@ -409,27 +410,8 @@ def run_gdb(savedir, plugin, repopath, fafrepo=None, taskid=None):
if child.returncode:
raise Exception("Unable to build podman container")


if CONFIG["UseFafPackages"]:
run(["/usr/bin/podman", "run", "-it", "--detach",
"--volume=%s:%s:ro" % (repopath, repopath),
"--volume=%s:/var/spool/abrt/faf-packages" % fafrepo,
"--rm",
"--name=%s" % img_cont_id,
"retrace-image:%s" % img_cont_id],
stdout=DEVNULL, stderr=DEVNULL, encoding='utf-8')

child = run(["/usr/bin/podman", "exec", "-it", "%s" % img_cont_id, "bash", "-c",
"for PKG in /var/spool/abrt/faf-packages/*; "
"do rpm2cpio $PKG | cpio -muid --quiet; done"],
stdout=DEVNULL, stderr=DEVNULL, encoding='utf-8')
if child.returncode:
raise Exception("Unpacking of packages failed")
child = run(["/usr/bin/podman", "exec", img_cont_id,
"/var/spool/abrt/gdb.sh"], stdout=PIPE, encoding='utf-8')
else:
child = run(["/usr/bin/podman", "run", "-it", "--name=%s" % img_cont_id,
"--rm", "retrace-image:%s" % img_cont_id], stdout=PIPE, encoding='utf-8')
child = run(["/usr/bin/podman", "run", "-it", "--name=%s" % img_cont_id,
"--rm", "retrace-image:%s" % img_cont_id], stdout=PIPE, encoding='utf-8')
else:
raise Exception("RetraceEnvironment set to invalid value")

Expand Down Expand Up @@ -2548,8 +2530,6 @@ def clean(self):

if CONFIG["RetraceEnvironment"] == "podman":
img_cont_id = str(self._taskid)
if CONFIG["UseFafPackages"]:
run(["/usr/bin/podman", "stop", img_cont_id])
run(["/usr/bin/podman", "rmi", "retrace-image:%s" % img_cont_id])

for f in os.listdir(self._savedir):
Expand Down
45 changes: 9 additions & 36 deletions src/retrace/retrace_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def __init__(self, task):
self.plugins = Plugins()
self.task = task
self.logging_handler = None
self.fafrepo = None
self.hook = RetraceHook(task)

def begin_logging(self):
Expand Down Expand Up @@ -287,24 +286,11 @@ def read_release_file(self, crashdir, crash_package):
def read_packages(self, crashdir, releaseid, crash_package, distribution):
packages = [crash_package]
missing = []
fafrepo = ""

packagesfile = os.path.join(crashdir, "packages")
if os.path.isfile(packagesfile):
with open(packagesfile, "r") as f:
packages = f.read.split()
elif CONFIG["UseFafPackages"]:
packages = ["bash", "cpio", "glibc-debuginfo"]
child = run(["/usr/bin/faf-c2p", "--hardlink-dir", CONFIG["FafLinkDir"],
os.path.join(crashdir, "coredump")], stdout=PIPE, stderr=PIPE, encoding='utf-8')
fafrepo = child.stdout.strip()
if child.stderr:
log_warn(child.stderr)

# hack - use latest glibc - for some reason gives better results
for filename in os.listdir(fafrepo):
if filename.startswith("glibc"):
os.unlink(os.path.join(fafrepo, filename))
else:
# read required packages from coredump
try:
Expand Down Expand Up @@ -359,7 +345,7 @@ def read_packages(self, crashdir, releaseid, crash_package, distribution):
except Exception as ex:
log_error("Unable to obtain packages from 'coredump' file: %s" % ex)
self._fail()
return (packages, missing, fafrepo)
return (packages, missing)

def start_retrace(self, custom_arch=None):
self.hook.run("start")
Expand Down Expand Up @@ -396,7 +382,7 @@ def start_retrace(self, custom_arch=None):
self._fail()
self.hook.run("pre_prepare_debuginfo")

packages, missing, self.fafrepo = self.read_packages(crashdir, releaseid, crash_package, distribution)
packages, missing = self.read_packages(crashdir, releaseid, crash_package, distribution)

self.hook.run("post_prepare_debuginfo")
self.hook.run("pre_prepare_environment")
Expand All @@ -422,8 +408,6 @@ def start_retrace(self, custom_arch=None):
mockcfg.write(" 'dirs': [\n")
mockcfg.write(" ('%s', '%s'),\n" % (repopath, repopath))
mockcfg.write(" ('%s', '/var/spool/abrt/crash'),\n" % crashdir)
if CONFIG["UseFafPackages"]:
mockcfg.write(" ('%s', '/packages'),\n" % self.fafrepo)
mockcfg.write(" ] }\n")
mockcfg.write("\n")
mockcfg.write("config_opts['yum.conf'] = \"\"\"\n")
Expand Down Expand Up @@ -473,10 +457,6 @@ def start_retrace(self, custom_arch=None):
self.hook.run("post_prepare_environment")
self.hook.run("pre_retrace")

if CONFIG["UseFafPackages"]:
self._retrace_run(26, ["/usr/bin/mock", "--configdir", task.get_savedir(), "shell", "--",
"bash -c 'for PKG in /packages/*; "
"do rpm2cpio $PKG | cpio -muid --quiet; done'"])
self._retrace_run(27, ["/usr/bin/mock", "--configdir", task.get_savedir(), "shell",
"--", "chgrp -R mock /var/spool/abrt/crash"])

Expand All @@ -492,8 +472,6 @@ def start_retrace(self, custom_arch=None):
RetraceTask.DOCKERFILE), "w") as dockerfile:
dockerfile.write('FROM %s:%s\n\n' % (distribution, version))
dockerfile.write('RUN mkdir -p /var/spool/abrt/crash\n')
if CONFIG["UseFafPackages"]:
dockerfile.write('RUN mkdir -p /var/spool/abrt/faf-packages')
dockerfile.write('\n')
dockerfile.write('RUN dnf install --assumeyes dnf-plugins-core\n')
dockerfile.write('RUN dnf config-manager --add-repo=file://%s\n' % repopath)
Expand All @@ -512,15 +490,12 @@ def start_retrace(self, custom_arch=None):
dockerfile.write('RUN chmod +x /var/spool/abrt/gdb.sh\n')
dockerfile.write('COPY %s /var/spool/abrt/crash/\n\n'
% RetraceTask.COREDUMP_FILE)
if CONFIG["UseFafPackages"]:
dockerfile.write('CMD ["/usr/bin/bash"]')
else:
dockerfile.write('RUN useradd -m retrace\n')
dockerfile.write('RUN chown retrace /var/spool/abrt/gdb.sh\n')
dockerfile.write('RUN chown retrace /var/spool/abrt/%s\n'
% RetraceTask.COREDUMP_FILE)
dockerfile.write('USER retrace\n\n')
dockerfile.write('ENTRYPOINT ["/var/spool/abrt/gdb.sh"]')
dockerfile.write('RUN useradd -m retrace\n')
dockerfile.write('RUN chown retrace /var/spool/abrt/gdb.sh\n')
dockerfile.write('RUN chown retrace /var/spool/abrt/%s\n'
% RetraceTask.COREDUMP_FILE)
dockerfile.write('USER retrace\n\n')
dockerfile.write('ENTRYPOINT ["/var/spool/abrt/gdb.sh"]')
except Exception as ex:
log_error("Unable to create Dockerfile: %s" % ex)
self._fail()
Expand All @@ -529,7 +504,7 @@ def start_retrace(self, custom_arch=None):
self.hook.run("pre_retrace")

try:
backtrace, exploitable = run_gdb(task.get_savedir(), self.plugin, repopath, self.fafrepo, task.get_taskid())
backtrace, exploitable = run_gdb(task.get_savedir(), self.plugin, repopath, task.get_taskid())
except Exception as ex:
log_error(str(ex))
self._fail()
Expand Down Expand Up @@ -983,8 +958,6 @@ def start(self, kernelver=None, arch=None):

def clean_task(self):
self.hook.run("pre_clean_task")
if CONFIG["UseFafPackages"] and self.fafrepo:
shutil.rmtree(self.fafrepo)
ret = self.task.clean()
self.hook.run("post_clean_task")
return ret
Expand Down

0 comments on commit 2a00fdd

Please sign in to comment.