Exemplo n.º 1
0
        //send peer credentials null byte
        //different platforms do this in different ways
#if HAVE_CMSGCRED
        unsafe void WriteBsdCred()
        {
            //null credentials byte
            byte buf = 0;

            IOVector iov = new IOVector();

            //iov.Base = (IntPtr)(&buf);
            iov.Base   = &buf;
            iov.Length = 1;

            msghdr msg = new msghdr();

            msg.msg_iov    = &iov;
            msg.msg_iovlen = 1;

            cmsg cm = new cmsg();

            msg.msg_control    = (IntPtr)(&cm);
            msg.msg_controllen = (uint)sizeof(cmsg);
            cm.hdr.cmsg_len    = (uint)sizeof(cmsg);
            cm.hdr.cmsg_level  = 0xffff;         //SOL_SOCKET
            cm.hdr.cmsg_type   = 0x03;           //SCM_CREDS

            int written = socket.SendMsg(&msg, 0);

            if (written != 1)
            {
                throw new Exception("Failed to write credentials");
            }
        }
        //send peer credentials null byte
        //different platforms do this in different ways
#if HAVE_CMSGCRED
        unsafe void WriteBsdCred()
        {
            //null credentials byte
            byte buf = 0;

            IOVector iov = new IOVector();

            iov.Base   = (IntPtr)(&buf);
            iov.Length = 1;

            msghdr msg = new msghdr();

            msg.msg_iov    = &iov;
            msg.msg_iovlen = 1;

            cmsg cm = new cmsg();

            msg.msg_control    = (IntPtr)(&cm);
            msg.msg_controllen = (uint)sizeof(cmsg);
            cm.hdr.cmsg_len    = (uint)sizeof(cmsg);
            cm.hdr.cmsg_level  = 0xffff;         //SOL_SOCKET
            cm.hdr.cmsg_type   = 0x03;           //SCM_CREDS

            int written = UnixSocket.sendmsg(socket.Handle, (IntPtr)(&msg), 0);

            UnixMarshal.ThrowExceptionForLastErrorIf(written);
            if (written != 1)
            {
                throw new Exception("Failed to write credentials");
            }
        }
		//send peer credentials null byte
		//different platforms do this in different ways
#if HAVE_CMSGCRED
		unsafe void WriteBsdCred ()
		{
			//null credentials byte
			byte buf = 0;

			IOVector iov = new IOVector ();
			//iov.Base = (IntPtr)(&buf);
			iov.Base = &buf;
			iov.Length = 1;

			msghdr msg = new msghdr ();
			msg.msg_iov = &iov;
			msg.msg_iovlen = 1;

			cmsg cm = new cmsg ();
			msg.msg_control = (IntPtr)(&cm);
			msg.msg_controllen = (uint)sizeof (cmsg);
			cm.hdr.cmsg_len = (uint)sizeof (cmsg);
			cm.hdr.cmsg_level = 0xffff; //SOL_SOCKET
			cm.hdr.cmsg_type = 0x03; //SCM_CREDS

			int written = socket.SendMsg (&msg, 0);
			if (written != 1)
				throw new Exception ("Failed to write credentials");
		}
Exemplo n.º 4
0
		//send peer credentials null byte
		//different platforms do this in different ways
#if HAVE_CMSGCRED
		unsafe void WriteBsdCred ()
		{
			//null credentials byte
			byte buf = 0;

			IOVector iov = new IOVector ();
			iov.Base = (IntPtr)(&buf);
			iov.Length = 1;

			msghdr msg = new msghdr ();
			msg.msg_iov = &iov;
			msg.msg_iovlen = 1;

			cmsg cm = new cmsg ();
			msg.msg_control = (IntPtr)(&cm);
			msg.msg_controllen = (uint)sizeof (cmsg);
			cm.hdr.cmsg_len = (uint)sizeof (cmsg);
			cm.hdr.cmsg_level = 0xffff; //SOL_SOCKET
			cm.hdr.cmsg_type = 0x03; //SCM_CREDS

			int written = UnixSocket.sendmsg (socket.Handle, (IntPtr)(&msg), 0);
			UnixMarshal.ThrowExceptionForLastErrorIf (written);
			if (written != 1)
				throw new Exception ("Failed to write credentials");
		}