SO_PEERCRED
returns peer socket credentials. SCM_CREDENTIALS
allows SCM_CREDENTIALS
to transfer any credentials that you have. This is especially valuable because the kernel will translate identifiers, so a task in one pid namespace can send pid for processing to another namespace and be sure that the resulting pid will refer to the same process that it was planning.
If you want to have a peer account, use SO_PEERCRED
. SCM_CREDENTIAL
is the credentials that the caller indicated (to which he should have privilege), not necessarily equal.
source share