From 8406399f47518e6c6c8cd4f9eab486d8df9bc837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Wed, 21 Apr 2021 23:54:14 +0100 Subject: [PATCH] Do not require chroot to be in PATH of non-root user. --- lib/utils.py | 2 +- rootfs.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/utils.py b/lib/utils.py index ca256dc..4a7e1a2 100755 --- a/lib/utils.py +++ b/lib/utils.py @@ -20,7 +20,7 @@ def run(*args, **kwargs): print(arguments) try: - subprocess.run(arguments, check=True, **kwargs) + return subprocess.run(arguments, check=True, **kwargs) except subprocess.CalledProcessError: print("Bootstrapping failed") sys.exit(1) diff --git a/rootfs.py b/rootfs.py index cb7fc04..4ddc6f2 100755 --- a/rootfs.py +++ b/rootfs.py @@ -81,8 +81,14 @@ def bootstrap(args, tmp_dir, initramfs_path): """Kick off bootstrap process.""" print("Bootstrapping %s" % (args.arch)) if args.chroot: + find_chroot = """ +import shutil +print(shutil.which('chroot')) +""" + chroot_binary = run('sudo', 'python3', '-c', find_chroot, + capture_output=True).stdout.decode().strip() init = os.path.join(os.sep, 'bootstrap-seeds', 'POSIX', args.arch, 'kaem-optional-seed') - run('sudo', 'env', '-i', 'PATH=/bin', 'chroot', tmp_dir, init) + run('sudo', 'env', '-i', 'PATH=/bin', chroot_binary, tmp_dir, init) return if args.minikernel: