attach: correctly handle namespace inheritance
attach: correctly handle namespace inheritance

When attaching to a container's namespaces we did not handle the case where we
inherited namespaces correctly. In essence, liblxc on start records the
namespaces the container was created with in the handler. But it only records
the clone flags that were passed to clone() and doesn't record the namespaces
we e.g. inherited from other containers. This means that attach only ever
attached to the clone flags. But this is only correct if all other namespaces
not recorded in the handler refer to the namespaces of the caller. However,
this need not be the case if the container has inherited namespaces from
another container. To handle this case we need to check whether caller and
container are in the same namespace. If they are, we know that things are all
good. If they aren't then we need to attach to these namespaces as well.

Signed-off-by: Christian Brauner <48455ab3070520a2d174545c7239d6d0fabd9a83@ubuntu.com>

caglar10ur/lxc,hallyn/lxc,hallyn/lxc,caglar10ur/lxc,thmo/lxc,thmo/lxc,ss1h2a3tw/lxc,ss1h2a3tw/lxc,ss1h2a3tw/lxc,caglar10ur/lxc,hallyn/lxc,thmo/lxc