On Sun, 2015-09-20 at 20:28 +0200, Samuel Thibault wrote: > Samuel Thibault, le Sun 20 Sep 2015 13:17:36 +0200, a écrit : > > I'll have a stab at cleaning your patches. > > I have pushed the result on the t/sendmsg-SCM_CREDS branch. Note that I > have refactored the t/sendmsg-SCM_RIGHTS branch, so make sure to update > your SCM_RIGHTS patch from that branch. > > I'll probably try to upload a glibc soon.
Working on a patch for a piece of software using SCM_CREDS code I tried the old tests for SCM_RIGHTS and SCM_CREDS again with a recent glibc. Running the code reveals that the current implementation in glibc is buggy: ./scm_rights+creds_recv Number of SCM_RIGHTS [<=3], SCM_CREDS [<=2]: [1,1] Input error: Using defaults: NRIGHTS = 1, NCREDS = 1 scm_rights+creds_send.c: msgh.msg_controllen = 112 (from control_un) Receiving via datagram socket recvmsg: (os/kern) invalid right ./scm_rights+creds_send Number of SCM_RIGHTS [<=3], SCM_CREDS [<=2]: [1,1] Input error: Using defaults: NRIGHTS = 1, NCREDS = 1 scm_rights+creds_send.c: msgh.msg_controllen = 112 (from control_un) Sent data = 12345 scm_rights+creds_send.c: Sending SCM_RIGHTS data scm_rights+creds_send.c: cmhp[0]->cmsg_len = 16 scm_rights+creds_send.c: CMSG_SPACE (sizeof(int))[0] = 16 scm_rights+creds_send.c: fd[0]=3 scm_rights+creds_send.c: Sending SCM_CREDS data scm_rights+creds_send.c: cmhp[1]->cmsg_len = 96 scm_rights+creds_send.c: CMSG_SPACE (sz)[1] = 96 Sent credentials: cmcred_pid=11071, cmcred_uid=1000, cmcred_euid=1000, cmcred_gid=1000 scm_rights+creds_send.c: msgh.msg_controllen = 112 Sending via datagram socket sendmsg() sent 4 bytes Case 0,1 works, 0,2 does not. Neither does x,1 where x=1,2,3 Attached is the test code packaged into a small tar file.
test_SCM_RIGHTS+CREDS.tar.gz
Description: application/compressed-tar