forkfile: use pidfds to attach to namespaces
forkfile: use pidfds to attach to namespaces

This is currently somewhat penalizing kernels that don't have pidfd setns
support because we're trying to setns() via the pidfd first and then fallback
to regular setns(). It's also penalizing error paths even non newer kernels
because in that case we always try both because we can't discern based on
return value from setns() when passing a pidfd if it failed because it doesn't
supports pidfd or because an actual error happened.

So in the long-term we'll want a way for the LXD daemon to communicate the
feature mask it detected at startup time to its helpers. This could probably be
a 32 bitmask that records all the kernel features via flags and that is passed
as an argument to the subprocess which can check for features it needs to know
about. Or maybe something more clever.

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

stgraber/lxd,stgraber/lxd,hallyn/lxd,lxc/lxd,lxc/lxd,stgraber/lxd,stgraber/lxd,atxwebs/lxd,hallyn/lxd,Skarlso/lxd,stgraber/lxd,Skarlso/lxd,lxc/lxd,atxwebs/lxd,lxc/lxd,atxwebs/lxd,Skarlso/lxd,hallyn/lxd,hallyn/lxd,Skarlso/lxd,lxc/lxd,stgraber/lxd,stgraber/lxd,lxc/lxd,hallyn/lxd,lxc/lxd,atxwebs/lxd,hallyn/lxd