[lxc-devel] 回复 :Re: How to change to lxc internal PID to system wide PID

Cedric Le Goater legoater at free.fr
Tue Dec 13 08:10:21 UTC 2011


On 12/13/2011 02:49 AM, yinxb at neusoft.com wrote:
> Hi Gregory Kurz
> 
>    From the google search,SCM_CREDENTIALS contains the PID of the 
> sender process,in the sender's
> PID namespace.
>    So if the lxc App acts as the sender, the PID is 2 which is also 
> invalid for the host. 
> (lxc has its own PID namesapce)
>    Correct me if wrong,thanks.

the pid in 'struct ucred' will be translated in the pid namespace of
the receiving side.

on the host, run the receiving side  : 

	http://man7.org/tlpi/code/online/dist/sockets/scm_cred_recv.c.html

	$ ./scm_cred_recv 
	Receiving via stream socket
	recvmsg() returned 4
	Received data = 12345
	Received credentials pid=20333, uid=1017, gid=100
	Credentials from SO_PEERCRED: pid=20333, euid=1017, egid=100


and in an lxc (application) container, run the sending side : 

	http://man7.org/tlpi/code/online/dist/sockets/scm_cred_send.c.html

	$ lxc-execute -n foo -- ./scm_cred_send
	Send credentials pid=2, uid=1017, gid=100
	sendmsg() returned 4

Regards,

C.




More information about the lxc-devel mailing list