[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#21410: [TEST-FAIL] 2 tests failed when running `make check' on Debia
From: |
Alex Vong |
Subject: |
bug#21410: [TEST-FAIL] 2 tests failed when running `make check' on Debian |
Date: |
Mon, 7 Sep 2015 09:47:41 +0800 |
Hi Dave,
I have searched the internet according to the information you provided,
I find this bug report <https://github.com/lxc/lxc/issues/250> provides useful
information.
I have written an example program after going through the clone(2) man page.
It demonstrates the problem and is inlined below.
First, compile the program as `a.out'.
Consider shell session 1:
root# echo 0 > /proc/sys/kernel/unprivileged_userns_clone
user$ ./a.out
I am your parent
Start cloning...
Cannot clone!
Consider shell session 2:
root# echo 1 > /proc/sys/kernel/unprivileged_userns_clone
user$ ./a.out
I am your parent
Start cloning...
Cloned!
I am your child
Any idea what's happenning?
I don't know Linux much, for instance I don't know what is container and
namespace in Linux.
Thanks!
Cheers,
Alex
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sched.h>
#include <sys/wait.h>
#include <unistd.h>
#define STACK_SIZE (1024 * 1024)
int
child(void *str)
{
if (puts(str) < 0)
return EXIT_FAILURE;
else
return EXIT_SUCCESS;
}
int
main(void)
{ void *func_ptr = &child;
void *stack_base = malloc(STACK_SIZE);
void *stack_top;
int flag = CLONE_NEWUSER | SIGCHLD;
char *msg = "I am your child";
int errsv = 0;
puts("I am your parent");
puts("Start cloning...");
stack_top = stack_base + STACK_SIZE;
clone(func_ptr, stack_top, flag, msg);
errsv = errno;
if (!errsv)
puts("Cloned!");
else
puts("Cannot clone!");
return errsv;
}