From 659588964777c3b49e2e6b1861c6d1b73ef455e7 Mon Sep 17 00:00:00 2001 From: Lev Veyde Date: Thu, 7 Jul 2022 16:21:05 +0300 Subject: [PATCH] Added logging of additional debugging information to nsenter function Previosuly we haven't logged the output of the STDERR, only the STDOUT. Additionally we haven't logged the return code. This patch fixes that. Signed-off-by: Lev Veyde --- src/imgbased/command.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/imgbased/command.py b/src/imgbased/command.py index 99d2c35..31506cf 100644 --- a/src/imgbased/command.py +++ b/src/imgbased/command.py @@ -18,7 +18,6 @@ def call(*args, **kwargs): def nsenter(arg, new_root=None, shell=False, environ=None): - DEVNULL = open(os.devnull, "w") if new_root: if shell: arg = "nsenter --root={0} --wd={0} {1}".format(new_root, arg) @@ -31,10 +30,12 @@ def nsenter(arg, new_root=None, shell=False, environ=None): environ = environ or os.environ log.debug("Executing: %s", arg) proc = subprocess.Popen(arg, stdout=subprocess.PIPE, env=environ, - stderr=DEVNULL, shell=shell).communicate() - ret = proc[0] - log.debug("Result: %s", repr(ret)) - return ret + stderr=subprocess.PIPE, shell=shell) + stdout, stderr = proc.communicate() + log.debug("STDOUT: %s", repr(stdout)) + log.debug("STDERR: %s", repr(stderr)) + log.debug("ReturnCode: %s", repr(proc.returncode)) + return stdout def chroot(args, root):