Skip to content

Commit 8e060af

Browse files
committed
invoker: better detection why userns does not work
Add the Ubuntu procfs knob and actually test for the current value to give a more precise hint of what is going on.
1 parent 434c5d0 commit 8e060af

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

pym/bob/invoker.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,23 @@ def ensureSandboxUsable():
450450
ret = subprocess.run([getSandboxHelperPath(), "-C"], stdout=subprocess.DEVNULL,
451451
stderr=subprocess.DEVNULL).returncode
452452
if ret != 0:
453+
knobs = [("/proc/sys/kernel/unprivileged_userns_clone", "1"),
454+
("/proc/sys/kernel/apparmor_restrict_unprivileged_userns", "0")]
455+
for knob, expected_val in knobs:
456+
try:
457+
with open(knob) as f:
458+
if f.read().strip() != expected_val:
459+
msg = f"Make sure {knob} is {expected_val}."
460+
break
461+
except FileNotFoundError:
462+
pass
463+
except OSError:
464+
msg = f"Make sure {knob} is {expected_val}."
465+
break
466+
else:
467+
msg = f"Not sure why that is exactly. Please consider opening a bug report at https://github.com/BobBuildTool/bob."
453468
raise BuildError("Your system does not support unprivileged containers! You need to build without sandbox (--no-sandbox).",
454-
help="Make sure /proc/sys/kernel/unprivileged_userns_clone is 1."
455-
" In case you use Docker, consider using the 'unconfined' seccomp profile."
469+
help=f"{msg} In case you use Docker, consider using the 'unconfined' seccomp profile."
456470
" See https://bob-build-tool.readthedocs.io/en/latest/installation.html#sandbox-capabilities for more details.",
457471
returncode=3)
458472
except OSError as e:

0 commit comments

Comments
 (0)