Skip to content

Commit

Permalink
Added logging of additional debugging information to nsenter function
Browse files Browse the repository at this point in the history
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 <lveyde@redhat.com>
  • Loading branch information
lveyde committed Jul 7, 2022
1 parent 4b79c67 commit 6595889
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/imgbased/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):
Expand Down

0 comments on commit 6595889

Please # to comment.