iov[0].iov_base = buf; iov[0].iov_len = cnt;
cred.pid = __getpid (); cred.uid = __geteuid (); cred.gid = __getegid ();
__msgwrite (int sock, void *buf, size_t cnt){#ifndef SCM_CREDENTIALS  /* We cannot implement this reliably.  */  __set_errno (ENOSYS);  return -1;#else  struct iovec iov[1];  struct msghdr msg;  iov[0].iov_base = buf;  iov[0].iov_len = cnt;  cm.cmsg.cmsg_type = SCM_CREDENTIALS;  cm.cmsg.cmsg_level = SOL_SOCKET;  cm.cmsg.cmsg_len = sizeof (struct cmessage);  /* XXX I'm not sure, if we really should use gete?id(), or get?id().     It would be much better, if the kernel could pass both to the     client. */  cm.cmcred.pid = __getpid ();  cm.cmcred.uid = __geteuid ();  cm.cmcred.gid = __getegid ();  msg.msg_iov = iov;  msg.msg_iovlen = 1;  msg.msg_name = NULL;  msg.msg_namelen = 0;  msg.msg_control = (caddr_t) &cm;  msg.msg_controllen = sizeof (struct cmessage);  msg.msg_flags = 0;  return sendmsg (sock, &msg, 0);#endif}