chroot-user: better error message, if unshare is not allowed

This commit is contained in:
Jörg Thalheim 2017-12-09 09:14:56 +00:00
parent edb59ee7bd
commit 438fb59e6f

View File

@ -128,7 +128,7 @@ int main(int argc, char *argv[]) {
// If we are root, no need to create new user namespace. // If we are root, no need to create new user namespace.
if (uid == 0) { if (uid == 0) {
if (unshare(CLONE_NEWNS) < 0) if (unshare(CLONE_NEWNS) < 0)
errorf(EX_OSERR, "unshare"); errorf(EX_OSERR, "unshare() failed: You may have an old kernel or have CLONE_NEWUSER disabled by your distribution security settings.");
// Mark all mounted filesystems as slave so changes // Mark all mounted filesystems as slave so changes
// don't propagate to the parent mount namespace. // don't propagate to the parent mount namespace.
if (mount(NULL, "/", NULL, MS_REC | MS_SLAVE, NULL) < 0) if (mount(NULL, "/", NULL, MS_REC | MS_SLAVE, NULL) < 0)