Say I am in the initial user namespace and there is an empty root-owned file in some directory: Now I am switching to a new user namespace with unshare -Ur. In this namespace, root.txt is reported to be owned by “nobody” because original root uid(0) is not mapped to the new namespace: Then I use vim to edit this file.
Tag: linux-namespaces
How to enter in to network namespace and read the file content using C program
In my Linux machine, i have configured the network namespace. With shell script or command line or system command I was able to fetch the file content present in the network namespace. Output: In a C program, I can use system(“ip netns exec test_namespace cat /var/test_namespace/route.conf”) command to get the output. But I prefer not to use this option. Looking
‘unshare’ does not work as expected in C api
This sequence of commands works: However, the corresponding C program does not work as expected (it seems it does not unmount the previous /proc, and also it provides EBUSY trying to unmount the devpts): I omitted here error checking for readability I think that unshare or unmount does not work as expect: even if it returns zero, it seems that
grantpt report error after unshare
I have a small program, which tries to create a pseudoterminal after unshare. the output is: The Code: If I remove flag |= CLONE_NEWUSER;, there is not error reported. Can you help to explain why this happens? thanks in advance! Answer Since I’ve had the same issue I have also looked into this. Here are my findings: grantpt(3) tries to
How to get the IP address of an LXC container?
I have started the lxc using lxc-start. Now, how I can get the IP address of the container? Answer Source
How to add a name to namespace?
As I know, I can use the “clone” to create a process and a namespace, but the namespace created in this way has no name. For example, I create a network namespace with the parameter: CLONE_NEWNS, but in the command “ip netns list”, there is no namespace list because the namespace created has no name. But I can use the