mirror of
https://github.com/uselessd/alcove.git
synced 2026-04-15 17:25:33 +00:00
Join Linux namespaces by specifiying the path to the processes'
namespace. Assuming a container is running on PID 13502, the path to the
net namespace will be: /proc/13502/ns/net
1> Port = alcove_drv:start().
#Port<0.1001>
2> alcove:setns(Port, "/proc/13502/ns/net").
true
3> alcove:execvp(Port, "/sbin/ifconfig", ["/sbin/ifconfig", "-a"]).
true
4> alcove:stdout(Port,0).
<<"eth0 Link encap:Ethernet HWaddr ...">>
setns(2) actually provides 2 parameters: an fd and an allowed namespace
(CLONE_NEWUTS, CLONE_NEWIPC, CLONE_NEWNET).
The second parameter is used when an fd with an unknown namespace is
passed to the process and the user wants to connect to a specific
namespace. In the case of alcove, the fd is opened by the port, so
specifying the namespace is not supported.
If alcove supports calling setns(2) by fd instead of by path, the
interface will need to be changed.