test-container: return UNSUPPORTED for ENOSPC on clone()
commitbd0b58837c7df091046e7531642f379a52e1e157
authorXi Ruoyao <xry111@xry111.site>
Tue, 28 Jun 2022 10:44:03 +0000 (28 18:44 +0800)
committerDJ Delorie <dj@redhat.com>
Wed, 6 Jul 2022 02:34:51 +0000 (5 22:34 -0400)
tree44ddeab7eddc6c7ee2e44de31522dda1b3a658ae
parentae308947ff0fa950431d53bcc90c875295d57715
test-container: return UNSUPPORTED for ENOSPC on clone()

Since Linux 4.9, the kernel provides
/proc/sys/user/max_{mnt,pid,user}_namespace as a limitation of number of
namespaces.  Some distros (for example, Slint Linux 14.2.1) set them (or
only max_user_namespace) to zero as a "security policy" for disabling
namespaces.

The clone() call will set errno to ENOSPC under such a limitation.  We
didn't check ENOSPC in the code so the test will FAIL, and report:

    unable to unshare user/fs: No space left on device

This message is, unfortunately, very unhelpful.  It leads people to
check the memory or disk space, instead of finding the real issue.

To improve the situation, we should check for ENOSPC and return
UNSUPPORTED as the test result.  Also refactor check_for_unshare_hints()
to emit a proper message telling people how to make the test work, if
they really need to run the namespaced tests.

Reported-by: Philippe Delavalade <philippe.delavalade@orange.fr>
URL: https://lists.linuxfromscratch.org/sympa/arc/lfs-support/2022-06/msg00022.html
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: DJ Delorie <dj@redhat.com>
support/test-container.c