From 73628a6e07e7c0a3f42fe1c1bbd710f5b3489c75 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Fri, 10 Nov 2017 08:38:08 -0800 Subject: [PATCH] Log a more descriptive error when setfiles fails (#1499771) Some lorax users run it from inside mock, which isn't able to detect whether the host is in Permissive mode. This can lead to confusing error messages, so this points them in the right direction. --- src/pylorax/imgutils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pylorax/imgutils.py b/src/pylorax/imgutils.py index 85345bc6..af534906 100644 --- a/src/pylorax/imgutils.py +++ b/src/pylorax/imgutils.py @@ -119,7 +119,13 @@ def mkrootfsimg(rootdir, outfile, label, size=2, sysroot=""): "-e", "/install", "-e", "/ostree", "/etc/selinux/targeted/contexts/files/file_contexts", "/"] root = join(mnt, sysroot.lstrip("/")) - runcmd(cmd, root=root) + try: + runcmd(cmd, root=root) + except CalledProcessError as e: + logger.error("setfiles exited with a non-zero return code (%d) which may " + "be caused by running without SELinux in Permissive mode.", e.returncode) + raise + ######## Utility functions ###############################################