lxc_attach: fix break with user namespaces (v3)
lxc_attach: fix break with user namespaces (v3)

When you clone a new user_ns, the child cannot write to the fds
opened by the parent.  Hnadle this by doing an extra fork.  The
grandparent hangs around and waits for its child to tell it the
pid of of the grandchild, which will be the one attached to the
container.  The grandparent then moves the grandchild into the
right cgroup, then waits for the child who in turn is waiting on
the grandchild to complete.

Secondly, when attaching to a new user namespace, your old uid is
not valid, so you are uid -1.  This patch simply does setid+setuid
to 0 if that is the case.  We probably want to be smarter, but
for now this allows lxc-attach to work.

Signed-off-by: Christian Seiler <2314b2e3a4a1f7db165be2aafbf1efd78f28cc97@iwakd.de>

armcc/lxc,codebauss/lxc,rldleblanc/lxc,lazy404/lxc,akshaykarle/lxc,hallyn/lxc,federicobriata/lxc,rowhit/lxc,Distrotech/lxc,ecarrara/lxc,hkjolhede/lxc,major/lxc,rldleblanc/lxc,szaszg/lxc,raspberrypython/lxc,cjwatson/lxc,jirislaby/lxc,bmoar/lxc,fwilson42/lxc,bostjan/lxc,weizhenwei/lxc,GreatFruitOmsk/lxc,JohnPeacockMessageSystems/lxc,Distrotech/lxc,aeris/lxc,major/lxc,virajs/lxc,major/lxc,LynxChaus/lxc,regit/lxc,ysbnim/lxc,hkjolhede/lxc,smoser/lxc,christiaan/lxc,QingweiPeterLan/cs188-lxc,ysbnim/lxc,ojkastl/lxc_Patches,yubo/lxc,Pelagicore/lxc,ksperis/lxc,hallyn/lxc,Ponce/lxc,rldleblanc/lxc,smoser/lxc,Pelagicore/lxc,LynxChaus/lxc,cjwatson/lxc,yubo/lxc,thmo/lxc,bostjan/lxc,ojkastl/lxc_Patches,armcc/lxc,codebauss/lxc,tych0/lxc,ss1h2a3tw/lxc,sapun/lxc,caglar10ur/lxc,JohnPeacockMessageSystems/lxc,terceiro/lxc,weizhenwei/lxc,caglar10ur/lxc,ecarrara/lxc,hfuCN/lxc,ss1h2a3tw/lxc,Ponce/lxc,terceiro/lxc,aeris/lxc,cjwatson/lxc,ioops/lxc,abstrakraft/lxc-android-lxc,efiop/lxc,sapun/lxc,ojkastl/lxc_Patches,christiaan/lxc,raspberrypython/lxc,regit/lxc,hallyn/lxc,sapun/lxc,thmo/lxc,ss1h2a3tw/lxc,tych0/lxc,codebauss/lxc,weizhenwei/lxc,QingweiPeterLan/cs188-lxc,JohnPeacockMessageSystems/lxc,bmoar/lxc,Distrotech/lxc,ksperis/lxc,efiop/lxc,GreatFruitOmsk/lxc,lisongmin/lxc,ojkastl/lxc_Patches,Pelagicore/lxc,lisongmin/lxc,lisongmin/lxc,DarknessBeforeDawn/lxc,szaszg/lxc,szaszg/lxc,ysbnim/lxc,fwilson42/lxc,smoser/lxc,rowhit/lxc,virajs/lxc,smoser/lxc,aeris/lxc,ioops/lxc,abstrakraft/lxc-android-lxc,glensc/lxc,hfuCN/lxc,armcc/lxc,glensc/lxc,virajs/lxc,jirislaby/lxc,lazy404/lxc,glensc/lxc,ksperis/lxc,abstrakraft/lxc-android-lxc,yubo/lxc,fwilson42/lxc,bostjan/lxc,thmo/lxc,abstrakraft/lxc-android-lxc,akshaykarle/lxc,ioops/lxc,christiaan/lxc,bmoar/lxc,federicobriata/lxc,federicobriata/lxc,terceiro/lxc,DarknessBeforeDawn/lxc,raspberrypython/lxc,ecarrara/lxc,LynxChaus/lxc,hfuCN/lxc,Ponce/lxc,DarknessBeforeDawn/lxc,GreatFruitOmsk/lxc,tych0/lxc,QingweiPeterLan/cs188-lxc,rowhit/lxc,efiop/lxc,caglar10ur/lxc,lazy404/lxc,hkjolhede/lxc,akshaykarle/lxc,regit/lxc,jirislaby/lxc